[Linux-ha-dev] deadtime_ms etc. long vs. unsigned long
Lars Marowsky-Bree
lmb at suse.de
Mon Oct 25 14:56:11 MDT 2004
On 2004-10-24T22:42:21, Alan Robertson <alanr at unix.sh> wrote:
> >sure.
> >but what do you need signed deadtime for?
> >and I think it was you who said "compiles without warnings on linux -
> >not negotiable" :)
>
> Yes. But, not with -pedantic. I tried this flag so long ago, but zero of
> the warnings it issued were of any potential value in finding bugs, and
> there were so *many* of them. So, I deliberately chose at that time to not
> include the flag in our set of warning flags.
Actually, signed vs unsigned comparions are always a bug indeed, because
the C language does not specify what should happen, and the result of
unsinged long a = 0;
signed long b = -1;
if (b < a) { }
is actually quite unspecified; if a is converted to signed, it'll likely
do what is desired, but it might as well be that b is converted to
unsigned w/underflow -> 2^32-1.
Actually I'm kind of surprised, I'd have assumed those should have been
caught already. They are definetely bugs and should be fixed on
principles.
Sincerely,
Lars Marowsky-Brée <lmb at suse.de>
--
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX AG - A Novell company
More information about the Linux-HA-Dev
mailing list