enum value overflows INT_MAX

Bjoern Jacke bj at sernet.de
Tue Mar 4 14:09:15 GMT 2008


Hi Jelmer,

which way do you like to fix this finally? With the #ifndef
HAVE_UINT_ENUMS or the unconditional cast? As these warnings flood the
compile warnings on many machines and we don't see the interesting
warnings. I'd really like to see this fixed. Can you please have a look?

Thanks...
Björn

On Fri, Jan 05, 2007 at 02:55:09PM +0100, Jelmer Vernooij wrote:
> On Fri, 2007-01-05 at 14:38 +1100, tridge at samba.org wrote:
> >  > #ifndef HAVE_UINT_ENUMS
> >  > #define STYPE_HIDDEN    ( 0x80000000 )
> >  > ...
> >  > #else
> >  > #define STYPE_HIDDEN	-1
> >  > #endif
> > 
> > except that the value is wrong (0x80000000 is not -1).
> > 
> > What if we generated this:
> > 
> > #define STYPE_HIDDEN (ENUM_CAST)(0x80000000)
> Sorry, I made a mistake in the code fragment above. It should be
> something like this:
> 
> #ifndef HAVE_UINT_ENUMS
> #define STYPE_HIDDEN (unsigned short)(0x8000000)
> ...
> #else
> enum stype {
>   STYPE_HIDDEN=0x8000000,
>   ...
> }
> #endif
> 
> I'd like to keep the enum {} bit as that allows compilers like gcc to
> warn us when we're using values for the enum that aren't defined.
> 
> Cheers,
> 
> jelmer
> -- 
> Jelmer Vernooij <jelmer at samba.org> - http://samba.org/~jelmer/




More information about the samba-technical mailing list