TNF don’t like cast (const type *) to (type *) directly, and they often enables -Wcast-qual with -Werror.
they defines __UNCONST macro in sys/cdefs.h:
const type *a;
type *b;
a = __UNCONST(a);
but in this patch, they dont use it for portability(and maybe its implementation is broken future 128bit pointer era), so use intptr_t like:
const type *a;
type *b;
a = (type *)(intptr_t)a;
in terms of C specification, cast
const *typetotype *is completely legal, but sometimes const qualifier is used for memory protection, see following examples taken from GCC’s manual:so -Wcast-qual may help to detect assignment of read-only location error.
but TNF, they blindly uses __UNCONST macro and never checks these memories can really be writable.
so they work hard, but they got nothing, it is only same result -Wno-cast-qual how idiot!(same as F*BSD, they do as same by __DECONST macro)
O*BSD keeps avoid to use -Wcast-qual, it seems that they believe -Wcast-qual is harmful, i think.