lkml.org 
[lkml]   [2001]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [BUG] Bad #define, nonportable C, missing {}
On Wed, 21 Nov 2001, Jan Hudec wrote:

> > > *a++ = byte_rev[*a]
> > It looks perferctly okay to me. Anyway, whenever would you listen to a
> > C++ book talking about good C coding :p
>

It's simple. If any object is modified twice without an intervening
sequence point, the results are undefined. The sequence-point in

*a++ = byte_rev[*a];

... is the ';'.

So, we look at 'a' and see if it's modified twice. It isn't. It
gets modified once with '++'. Now we look at the object to which
'a' points. Is it modified twice? No, it's read once in [*a], and
written once in "*a++ =".

So, it's perfectly good code with a well defined behavior as far as
'C' is concerned. I think it is ugly, however, the writer probably
thought it was beautiful. If somebody went around and fixed all
the ugly code, it would still be ugly in someone else's eyes.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.


-
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.208 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site