[SLOF] [PATCH] libc: The arguments of puts() can be marked as "const"
Segher Boessenkool
segher at kernel.crashing.org
Thu Jul 13 05:24:07 AEST 2017
On Wed, Jul 12, 2017 at 02:56:41PM +0200, Thomas Huth wrote:
> >>>>>> /home/aik/p/slof/slof/paflof.c: In function ‘engine’:
> >>>>>> /home/aik/p/slof/slof/paflof.c:84:23: warning: array subscript is below
> >>>>>> array bounds [-Warray-bounds]
> >>>>>> dp = the_data_stack - 1;
> >>>>>> ~~~~~~~~~~~~~~~^~~
> Ugh, ok.
>
> What about:
>
> dp = the_data_stack;
> rp = handler_stack;
> barrier();
> dp--;
> rp--;
>
> ?
>
> That should hopefully shut up the compiler, too, and result in the same
> initial setting of dp and rp.
I don't know what "barrier" is, but it cannot work :-) Decrementing dp
is not valid C here, either (exactly the same problem as the original).
You could do just
dp = (cell *)((uintptr_t)the_data_stack - CELLSIZE);
etc. -- that is valid C, standard C even, and will work just fine.
It's ugly, but at least it is correct ;-)
Segher
More information about the SLOF
mailing list