Re: Some cleanup patches for: '...lvalues is deprecated'

From: Vojtech Pavlik
Date: Sat Jul 03 2004 - 16:46:29 EST


On Sat, Jul 03, 2004 at 09:39:24PM +0000, Joel Soete wrote:

> Very interesting but well I am not enough fluent in C to understand this
> fine detail :(
> Can you explain me by an example (let say a long*) what would did "((char
> *) buffer)++;" versus "buffer += sizeof(char);"
> (Don't worry, if don't have time, I will perfectly understand and will
> experiment by myself)

Ok. Let's assume

int *buffer;

just for this example.

((char *) buffer)++;

increments buffer by 1, while

buffer += sizeof(char);

increments buffer by 4, because an int* is always
increased/decreased by multiples of sizeof(int).

So

buffer += 2;

would increment the pointer by 8.

Similarly for other pointer types.

> >So just use
> >
> > buffer++;
> >
> >here, and the intent is then clear.
> >
> Yes ;)

--
Vojtech Pavlik
SuSE Labs, SuSE CR
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/