[Toybox] [PATCH] patch: avoid upsetting the compiler.
Rob Landley
rob at landley.net
Fri Feb 28 04:35:34 PST 2020
On 2/27/20 11:59 PM, enh via Toybox wrote:
> external/toybox/toys/posix/patch.c:129:45: error: pointer type mismatch
> ('int (*)(char *, char *)' and 'void *')
> int (*lcmp)(char *aa, char *bb) = FLAG(l) ? loosecmp : (void *)strcmp;
> ^ ~~~~~~~~ ~~~~~~~~~~~~~~
This is what the void * typecast is for? (Is it because I didn't (void *) both
of them? I can do that.)
I don't want to add const because it's gratuitous nonsense. (The compiler does
liveness analysis! This isn't moving stuff between rodata and data, they're both
on the stack!)
"cost" is danegeld. If you add "const" anywhere you wind up propagating it down
through dozens of layers of calls and spend half your time making the "const"
annotations line up, and it serves NO PURPOSE. String constants are in rodata
without being "const".
Rob
More information about the Toybox
mailing list