[syslog-ng] 2.0RC4 make warning on OS X 10.4.8 PPC G4
Balazs Scheidler
bazsi at balabit.hu
Fri Oct 27 11:08:37 CEST 2006
On Thu, 2006-10-26 at 13:38 -0400, Valdis.Kletnieks at vt.edu wrote:
> On Thu, 26 Oct 2006 12:41:50 +0200, Balazs Scheidler said:
> >
> > > affile.c: In function 'affile_dd_init':
> > > affile.c:456: warning: comparison is always false due to limited range
> > > of data type
> > > affile.c:462: warning: comparison is always false due to limited range
> > > of data type
> >
> > This might be a problem if the compiler optimizes the if statement out.
> > I have added casts to fix this issue.
>
> You need to be careful here... sometimes this sort of thing is a "fix"
> rather than a real fix...
>
> > - if (self->file_perm == -1)
> > + if (self->file_perm == (mode_t) -1)
> > self->file_perm = cfg->file_perm;
>
> The reason the compiler complains is that if proper type safety has been
> followed *elsewhere*, it can't have been equal to -1. In other words, if
> this is the only place you had to add the cast, it's *still* buggy.
I know. -1 is used as an extremal value, and this is explicitly assigned
to the variable elsewhere. -1 basically means: "use default", any other
value means that the user overrode the default.
Instead of -1 I could have been used MAXINT, but I feel -1 more readable
and more consistent with the rest of the code.
--
Bazsi
More information about the syslog-ng
mailing list