lkml.org 
[lkml]   [2001]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: if (a & X || b & ~Y) in dasd.c
At 08:38 PM 11/19/2001 +0100, Peter T. Breuer wrote:

>"bill davidsen wrote:"
> > If the code does what I think it does, it works as written. However, I
> > usually would throw in parenthesis on something like this to be sure
> > that the next person reading the code won't waste time thinking about
>
>Which is WHY you do not put in parentheses.

<snip snip>

So instead of using extra parentheses, we should include a copy of your
response in every potentially ambiguous location instead?

Two C constructs that have bitten me in the glutinous maximus on more than
one occasion:


mem_address = mem_base + page_index << 12; // Wrong!

if ( bit_mask & BIT_FLAG == 0) { flag_not_set(); } // Wrong!

Of course C has precedence. It's not always obvious. And the difference
between this

x = y + z << 2;

and

x = (y + z) << 2;

is that the 2nd doesn't make me have to remember the relative precedences
of + and <<.


--
Stevie-O

REAL kernel hackers use
# cat > /vmlinuz
and
# insmod /dev/stdin

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:13    [W:0.040 / U:4.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site