[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnutls-dev] RE: constification patch
From: |
ZIGLIO, Frediano, VF-IT |
Subject: |
[gnutls-dev] RE: constification patch |
Date: |
Tue, 3 Jan 2006 11:31:12 +0100 |
....
> >
> > 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
gnutls.diff.gz
Description: gnutls.diff.gz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnutls-dev] RE: constification patch,
ZIGLIO, Frediano, VF-IT <=