Re: Patch to remove undefined C code

From: Horst von Brand (vonbrand@inf.utfsm.cl)
Date: Tue Oct 17 2000 - 11:24:53 EST


Richard Guenther <richard.guenther@student.uni-tuebingen.de> said:
> On Mon, 16 Oct 2000, Bernd Schmidt wrote:
> The following one is wrong, tho - should be rather
> str[i] = dn[i]; i++;

> > diff -x log.build -x .* -dru linux-2.4/drivers/isdn/sc/debug.c linux-2.4-fixe
> d/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;

What is wrong with plain and simple:

       for(i = 0; dn[i] != ','; i++)
                       str[i] = dn[i];
       str[i] = '\0';

This one even has a chance of being understood... if you want fancy fooling
around, even this is more readable than the original:

      char *p = dn, *q = str;

      while((*q++ = *p++) != ',')
                      ;
      *q = '\0';

Even so, all 3 _will_ break when a ','-less dn comes along...

-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
-
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/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:11 EST