Re: bit-wise vs. conditional or (kernel bugs found using inspect)

From: Q (Q@ping.be)
Date: Thu Feb 24 2000 - 19:36:03 EST


On Thu, Feb 24, 2000 at 09:04:36AM -0600, Amy Rupp wrote:
>
> If a bit-wise operation is performed on anything but a bit-field
> type (eg :1), one risks a future editor adding additional values
> for the variable to take on. The fact that a bit-wise or is
> equivalent to ? 1 : 0 ONLY HOLDS if the variable can only be
> assigned the value of 1 or 0. Without a strictly enforced
> boolean type, or, even better, a bitfield definition, you can
> set any data type to a value that's not 0 or 1.

To make it a little bit more clear:

It's not because something returns the value 0, that is is represented by
all 0 bits. The value of a comparision is the value 0 (false) or 1 (true),
but you can't assume anything on how it is represented in hardware.
Therefor using a bit-wise operation just makes no sense, and only does for
data where you manipulate bits itself, like in bitfields.

Q

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:11 EST