The C standard is wrong[1] with respect to the function signature of
free(), while the kernel's kfree() is correct. Unfortunately, this
leads to compiler warnings.
Sayeth Dennis Ritchie: "Noalias must go. This is non-negotiable"[2].
Noalias went. The confusion around const, alas, still remains.
[1] https://yarchive.net/comp/const.html
[2] https://www.lysator.liu.se/c/dmr-on-noalias.html
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
_INLINE_ void kfree(const void *objp)
{
+#ifdef HAVE_INTPTR_T
+ /*
+ * Work around a botch in the C standard, which triggers
+ * compiler warnings. For better or for worse, the kernel
+ * uses const void * for kfree, while the C standard mandates
+ * the use of void *. See: https://yarchive.net/comp/const.html
+ */
+ free((void *)(intptr_t)objp);
+#else
free((void *)objp);
+#endif
}
/* generic hashing taken from the Linux kernel */