#5 Improve const-correctness

closed
nobody
None
5
2012-02-11
2007-02-09
Markus Elfring
No

Would you like to apply the advices from the article "http://en.wikipedia.org/wiki/Const-correctness" to more places in your sources?
I suggest to add the key word "const" to the type specifiers for parameters like the following.
- http://libvncserver.cvs.sourceforge.net/libvncserver/libvncserver/libvncserver/font.c?revision=1.6&view=markup
filename (function "rfbLoadConsoleFont")

- http://libvncserver.cvs.sourceforge.net/libvncserver/libvncserver/libvncserver/vncauth.c?revision=1.4&view=markup
passwd, fname (function "rfbEncryptAndStorePasswd")

Discussion

  • Logged In: YES
    user_id=27066
    Originator: NO

    Patches welcome.

     
    • status: open --> pending
     
  • Markus Elfring
    Markus Elfring
    2007-03-31

    Logged In: YES
    user_id=572001
    Originator: YES

    Would you like to integrate the appended update suggestion into your source files?
    File Added: const1655902a.diff.gz

     
  • Markus Elfring
    Markus Elfring
    2007-03-31

    • status: pending --> open
     
  • Markus Elfring
    Markus Elfring
    2007-04-01

    Logged In: YES
    user_id=572001
    Originator: YES

    File Added: const1655902a.diff.gz

     
  • Logged In: YES
    user_id=27066
    Originator: NO

    C99 is not that widespread, and I am not willing to force everybody and her
    dog to upgrade, if that is even possible.

    So, C99 is not an option. (Especially since I have to be convinced that
    these changes are actually useful, i.e. they do something besides pleasing
    standards people.)

     
  • Logged In: YES
    user_id=27066
    Originator: NO

    Frankly, I do not see why this should be forced down my throat. I would have
    liked to have a look at the const-patch, but together with "restrict",
    there is no way I will apply it.

    Your patch no longer applies, and besides, even what applies does not
    compile here, so unless I get a patch which applies, together with a
    convincing explanation why it is good (my time is precious, you know?),
    I _will_ reject this patch _for good_.

     
  • Markus Elfring
    Markus Elfring
    2007-04-06

    Logged In: YES
    user_id=572001
    Originator: YES

    POSIX APIs consider the technical details "const" and "restrict" in its interface design. I suggest to adjust your own application APIs to this current practice.

     
  • Logged In: YES
    user_id=27066
    Originator: NO

    elfring,

    you are missing the point. If it does not compile to begin with, and then
    also fails to achieve anything, it is not worth it.

    Unfortunately, sourceforge's compile farm is down, but I would bet on
    Sun's CC, or at least AIX's, to be unable to compile with your patch.

    Heck, even my venerable -- not really up-to-date -- Linux box went on
    strike over this patch.

    However, you put it, at least for one user (me!) you did not improve
    things, but did the opposite.

    Do not expect me to apply anything which breaks the build!

     
    • status: open --> pending
     
  • Markus Elfring
    Markus Elfring
    2007-04-09

    Logged In: YES
    user_id=572001
    Originator: YES

    Is the appended update acceptable on your system now, too?
    File Added: const1655902b.patch.gz

     
  • Markus Elfring
    Markus Elfring
    2007-04-09

    • status: pending --> open
     
  • Markus Elfring
    Markus Elfring
    2007-04-09

    Logged In: YES
    user_id=572001
    Originator: YES

    How do you think about the adjusted autoconf settings?
    File Added: const1655902b.patch.gz

     
  • Markus Elfring
    Markus Elfring
    2007-04-09

    API polish proposal

     
    • status: open --> closed