Menu

#2 Improve "const correctness"

closed
nobody
None
5
2020-06-13
2005-07-09
No

Would you like to apply the advices from the article
"http://en.wikipedia.org/wiki/Const_correctness" to
your sources?
I suggest to add the key word "const" to the type
specifiers for parameters like the following.
- msg (function "ipmi_request"), addr (function
"ipmi_validate_addr")

http://cvs.sourceforge.net/viewcvs.py/openipmi/OpenIPMI/include/linux/ipmi.h?rev=1.6&view=markup

- heap (function "print")

http://cvs.sourceforge.net/viewcvs.py/openipmi/OpenIPMI/unix/heap.h?rev=1.1&view=markup

Related

Commit: [03c5b6]
Commit: [04ba15]
Commit: [367a35]
Commit: [5d6460]
Commit: [67556d]
Commit: [99e597]
Commit: [afc9f6]
Commit: [b425e5]
Commit: [dba744]

Discussion

  • Corey Minyard

    Corey Minyard - 2005-07-14
    • status: open --> closed
     
  • Corey Minyard

    Corey Minyard - 2005-07-14

    Logged In: YES
    user_id=236278

    Ok, I've done this in the 2.0 releases. I'm not sure I'm
    willing to backport this to 1.4, though, as the side-effects
    may be too much.

     
  • Markus Elfring

    Markus Elfring - 2005-07-14
    • status: closed --> open
     
  • Markus Elfring

    Markus Elfring - 2005-07-14

    Logged In: YES
    user_id=572001

    Are you going to check other files in the current release, too?

     
  • Corey Minyard

    Corey Minyard - 2005-07-14

    Logged In: YES
    user_id=236278

    I'm not sure what you mean. The changes are checked in to
    the CVS head, but not into the 1.4 branch. There's a few
    more things I want to deal with that are internal, and a
    backwards compatibility problem with posix_vlog that I'm
    going to fix a different way.

    I'll look at doing just the changes you wanted to 1.4.

     
  • Markus Elfring

    Markus Elfring - 2005-07-14

    Logged In: YES
    user_id=572001

    I pointed just to two files for review.
    Do you know more candidates for improvement already?

     
  • Corey Minyard

    Corey Minyard - 2005-07-14

    Logged In: YES
    user_id=236278

    Does the attached patch do what you suggest?

     
  • Corey Minyard

    Corey Minyard - 2005-07-14
     
  • Markus Elfring

    Markus Elfring - 2005-07-14

    Logged In: YES
    user_id=572001

    Yes, this change list looks great. (Are the files "ipmi.h"
    and "heap.h" excluded?)
    I hope that new functions will be const-correctly designed
    and developed from the beginning.

     
  • Corey Minyard

    Corey Minyard - 2005-07-15
    • status: open --> closed
     
  • Corey Minyard

    Corey Minyard - 2005-07-15

    Logged In: YES
    user_id=236278

    Yes, I will keep this in mind for future updates. Thanks.
    The 1.4.18 release has these changes.

    ipmi.h is a kernel interface and heap.h is an internal
    interface, so they are no as important. There's a few other
    things, too, that need fixing. I'll do those over time,
    probably.

     
  • Markus Elfring

    Markus Elfring - 2005-07-16

    Logged In: YES
    user_id=572001

    I suggest that this issue should be kept open until all
    files will be fixed without exception.

     
  • Markus Elfring

    Markus Elfring - 2005-07-16
    • status: closed --> open
     
  • Markus Elfring

    Markus Elfring - 2005-07-22

    Logged In: YES
    user_id=572001

    Do you notice any difference in the generated object code if
    all proposed refactorings will be applied?

     
  • Corey Minyard

    Corey Minyard - 2005-07-22

    Logged In: YES
    user_id=236278

    I didn't look to see if anything changed. From this, I kind
    of doubt it made much difference. The compiler can make
    more optimizations with const types, but almost all the uses
    of this are "Put the data into this container and pass it
    in/on and don't use it any more". Not many new
    optimizations that could be done there.

     
  • Markus Elfring

    Markus Elfring - 2005-07-23

    Logged In: YES
    user_id=572001

    Are you interested to know any measureable effects like
    object file sizes if a const-correct design will become
    available for your software?

     
  • Corey Minyard

    Corey Minyard - 2005-07-23

    Logged In: YES
    user_id=236278

    It would be interesting to know. If it made a difference,
    it would be incentive to keep going :-).

     
  • Corey Minyard

    Corey Minyard - 2006-02-06

    Logged In: YES
    user_id=236278

    I've gone over all the interface and I'm try to use const
    whenever possible. Thanks for the heads-up.

     
  • Corey Minyard

    Corey Minyard - 2006-02-06
    • status: open --> closed
     
  • Markus Elfring

    Markus Elfring - 2006-02-06
    • status: closed --> open
     
  • Markus Elfring

    Markus Elfring - 2006-02-06

    Logged In: YES
    user_id=572001

    Thanks for this accepted correction.

    Would you like to add a reference (case number) to this
    issue to the change log or any comments?

     
  • Corey Minyard

    Corey Minyard - 2020-06-13
    • status: open --> closed
    • Group: --> Next_Release_(example)
     
  • Corey Minyard

    Corey Minyard - 2020-06-13

    This has been a while and I missed the last comment. I assume everything is ok, I'm not sure there's anything else I need to do.

     

Log in to post a comment.