Re: [PATCH] net/ipv4/*, net/core/neighbour.c jiffies cleanup

David S. Miller (davem@redhat.com)
Wed, 07 Nov 2001 16:44:26 -0800 (PST)


From: Andreas Dilger <adilger@turbolabs.com>
Date: Wed, 7 Nov 2001 17:36:27 -0700

No, only a limited number of them cast to a signed value, which means
that a large number of them get the comparison wrong in the case of
jiffies wrap (where the difference is a large unsigned value, and not
a small negative number).

Why do they these cases that are actually in the code need to cast to
a signed value to get a correct answer? They are not like your
example.

Almost all of these cases are:

(jiffies - SOME_VALUE_KNOWN_TO_BE_IN_THE_PAST) > 5 * HZ

So you say if we don't cast to signed, this won't get it right on
wrap-around? I disagree, let's say "long" is 32-bits and jiffies
wrapped around to "0x2" and SOME_VALUE... is 0xfffffff8. The
subtraction above yields 10, and that is what we want.

Please show me a bad case where casting to signed is necessary.

I actually ran through the tree the other night myself starting to
convert these things, then I noticed that I couldn't even convince
myself that the code was incorrect.

Franks a lot,
David S. Miller
davem@redhat.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/