public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: root@chaos.analogic.com
Cc: Jan Hudec <bulb@ucw.cz>, linux-kernel@vger.kernel.org
Subject: Re: [BUG] Bad #define, nonportable C, missing {}
Date: 21 Nov 2001 07:33:31 -0700	[thread overview]
Message-ID: <m17ksk19dw.fsf@frodo.biederman.org> (raw)
In-Reply-To: <Pine.LNX.3.95.1011121085737.21389A-100000@chaos.analogic.com>
In-Reply-To: <Pine.LNX.3.95.1011121085737.21389A-100000@chaos.analogic.com>

"Richard B. Johnson" <root@chaos.analogic.com> writes:

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

Nope.  In particular it isn't defined if [*a] is evaluated before
or after a++ is evaluated.  

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

True, but not significant.  You can find a set of people whose opinion
matters (say core kernel maintainers) and not have that looks ugly in
their eyes.   In any case broken code is broken.

Eric

  reply	other threads:[~2001-11-21 14:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-21 12:40 [BUG] Bad #define, nonportable C, missing {} vda
2001-11-21 11:10 ` Andreas Schwab
2001-11-21 11:16 ` Tim Waugh
2001-11-21 12:31 ` Ragnar Hojland Espinosa
2001-11-21 13:40   ` Jan Hudec
2001-11-21 14:19     ` Andreas Schwab
2001-11-21 14:52       ` Alexander Viro
2001-11-21 18:23     ` Neil Booth
2001-11-21 12:35 ` Vincent Sweeney
2001-11-21 13:37   ` Jan Hudec
2001-11-21 13:52     ` Mathijs Mohlmann
2001-11-21 17:12       ` vda
2001-11-26 20:28         ` Alan Cox
2001-11-27 18:03           ` vda
2001-11-27 18:38             ` Andreas Dilger
2001-11-28 13:19               ` vda
2001-11-21 14:12     ` Richard B. Johnson
2001-11-21 14:33       ` Eric W. Biederman [this message]
2001-11-21 14:56       ` Alexander Viro
2001-11-21 14:59       ` Andreas Schwab
2001-11-21 15:48         ` Momchil Velikov
2001-11-21 16:52       ` vda
2001-11-21 14:24     ` Sean Hunter
2001-11-21 14:25   ` Andreas Schwab
2001-11-22 20:43   ` Chris Gray
2001-11-22  4:24 ` Stevie O
2001-11-22 11:46   ` Horst von Brand
2001-11-22 12:03     ` Alexander Viro
2001-11-22 20:08   ` J.A. Magallon
     [not found]     ` <01112311540300.00886@manta>
2001-11-23 14:43       ` J.A. Magallon
  -- strict thread matches above, loose matches on Subject: below --
2001-11-27 19:03 Nathan Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m17ksk19dw.fsf@frodo.biederman.org \
    --to=ebiederm@xmission.com \
    --cc=bulb@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox