lkml.org 
[lkml]   [2000]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Patch to remove undefined C code
On Tue, 17 Oct 2000, Bernd Schmidt wrote:

> On Tue, 17 Oct 2000, Richard Guenther wrote:
>
> > On Mon, 16 Oct 2000, Bernd Schmidt wrote:
> >
> > > I've been playing with some gcc patches to detect code with undefined
> > > behaviour of the i = i++ variety. The patch below fixes all places in
> > > the kernel that I could find. Note that in some cases, it wasn't
> > > entirely clear what the code intended, so I had to guess.
> > >
> > > I haven't tested this patch at all other than to make sure it compiles.
> >
> > The following one is wrong, tho - should be rather
> > str[i] = dn[i]; i++;
>
> Nope. (Well, at least you need to add extra braces.) The comma is a
> sequence point.

Umm, I thought, dn[i], i++ evaluates to i and dn[i++] evaluates
to dn[i], so it should be either i++, dn[i-1] or the one I showed
above?

Richard.

> > > diff -x log.build -x .* -dru linux-2.4/drivers/isdn/sc/debug.c linux-2.4-fixed/drivers/isdn/sc/debug.c
> > > --- linux-2.4/drivers/isdn/sc/debug.c Thu Apr 2 01:21:04 1998
> > > +++ linux-2.4-fixed/drivers/isdn/sc/debug.c Mon Oct 16 14:53:49 2000
> > > @@ -70,6 +70,6 @@
> > > int i = 0;
> > >
> > > while(dn[i] != ',')
> > > - str[i] = dn[i++];
> > > + str[i] = dn[i], i++;
> > > str[i] = 0x0;
> > > }
>
>
> Bernd
>

--
Richard Guenther <richard.guenther@student.uni-tuebingen.de>
WWW: http://www.anatom.uni-tuebingen.de/~richi/
The GLAME Project: http://www.glame.de/

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

\
 
 \ /
  Last update: 2005-03-22 12:41    [from the cache]
©2003-2011 Jasper Spaans