Make parse-xml callbacks be type-safe
Linus Torvalds
torvalds at linux-foundation.org
Sat Jun 7 14:45:38 PDT 2014
On Sat, 7 Jun 2014, Linus Torvalds wrote:
>
> Also, from a theoretical portability standpoint, the _real_ portability
> problem comes from casting the function pointer, but no sane ABI changes
> calling conventions when it's just the difference between one data pointer
> and another.
>
> Long story short: pretty it ain't, but working it is.
Forgot to mention one thing. I left the "utf8_string()" without type
checking - so it still uses "void *_res" for the result type, with the
cast happening inside the function.
That's because the result destination ends up being a bit mixed-up wrt
"const char **" and just plain "char **". Note that the thing we modify
itself isn't const (it's not "char *const *"), but the pointer, but we
basically sometimes assign a "const char *", and sometimes a "char *".
I considered making two different versions of the callback, but it just
wasn't worth it. So "utf8_string()" users still aren't type-checked, and
you'd better give it a pointer to something that is some kind of "char *".
Linus
More information about the subsurface
mailing list