[gnutls-dev] RE: constification patch
ZIGLIO, Frediano, VF-IT
Frediano.Ziglio at vodafone.com
Tue Jan 3 11:31:12 CET 2006
....
> >
> > static inline const node_asn *
> > _asn1_find_up_const(const node_asn *node)
> > {
> > return _asn1_find_up((node_asn*) node);
> > }
> >
> > to
> >
> > #if defined(__GNUC__) && __GNUC__ >= 3
> > static inline const node_asn *
> > _asn1_find_up_const(const node_asn *node)
> > {
> > return _asn1_find_up((node_asn*) node);
> > }
> > #else
> > #define _asn1_find_up_const(node) _asn1_find_up((node_asn*) (node))
> > #endif
>
> How about changing the prototype of _asn1_find_up to include the const
> keyword instead? That seem more correct.
>
> Using typecasts like you do hide problems: what if _asn1_find_up does
> not preserve const? That would lead to a disaster, and the compiler
> will not warn about it.
>
> Further, it has not been written down, but the coding style for
> minitasn1 is slightly different than GnuTLS. Minitasn1 should be
> portable C89 code, and #if's like that make the code unreadable.
> Unless profiling show that you'd gain a non-negligible amount of time
> making that particular function inline (I highly doubt that), then it
> is worth the extra CPU cycles to have readable code. Optimize only
> when you need. In contrast, in GnuTLS we can use 'inline'
> unconditionally because there is a gnulib M4 test that make sure
> 'inline' is defined to "" if it is not available.
>
> If you update the patch, to change the prototype of the existing
> functions to use 'const' too, I'll review it. I know there is a lot
> of missing 'const' keywords in various places.
>
Happy New Year !!
I revised a bit the patch.
Attached an update. This make constification in minitasn library
portable C without #define and others uglyness.
Regards,
Frediano Ziglio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnutls.diff.gz
Type: application/x-gzip
Size: 4027 bytes
Desc: gnutls.diff.gz
URL: </pipermail/attachments/20060103/c9682e91/attachment.bin>
More information about the Gnutls-devel
mailing list