Messages in this thread | | | Date | Mon, 5 Jul 2004 01:10:10 -0400 | From | Daniel Jacobowitz <> | Subject | Re: Some cleanup patches for: '...lvalues is deprecated' |
| |
On Sat, Jul 03, 2004 at 10:56:21PM +0200, Vojtech Pavlik wrote: > On Sat, Jul 03, 2004 at 12:53:21PM +0000, Joel Soete wrote: > > Hi Marcelo, > > > > Please appolgies first for wrong presentation of previous post (that was > > the first and certainly the last time that I used the 'forwarding' option > > of this webmail interface :( ). > > > > Here are some backport to clean up some warning of type: use of cast > > experssion > > as lvalues is deprecated. > > --- linux-2.4.27-rc2-pa4mm/kernel/sysctl.c.Orig 2004-06-29 > > 09:03:42.000000000 +0200 > > +++ linux-2.4.27-rc2-pa4mm/kernel/sysctl.c 2004-06-29 > > 10:10:31.588030256 +0200 > > @@ -890,7 +890,7 @@ > > if (!isspace(c)) > > break; > > left--; > > - ((char *) buffer)++; > > + buffer += sizeof(char); > > This (although correct in the end) is a wrong thing to do. > > It seems to look like the intention is to move the pointer by a char's > size, however your change is equivalent to: > > buffer += 1; > > And if buffer wasn't void*, which it fortunately is, it would, unlike > the older construction, move the pointer by a different size. > > So just use > > buffer++; > > here, and the intent is then clear.
Except C does not actually allow incrementing a void pointer, since void does not have a size. You can't do arithmetic on one either. GNU C allows this as an extension.
It's actually this, IIRC: buffer = ((char *) buffer) + 1;
-- Daniel Jacobowitz - 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/
| |