aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2023-01-27 15:35:12 -0500
committerTheodore Ts'o <tytso@mit.edu>2023-01-27 15:46:45 -0500
commitd6ed24794e408a51cee2429841cc452323da4af8 (patch)
tree64df7fc4bc423172ad494f46a42fd682e46ed8af
parent4d91d64b5a97a27b9e5fbc6cff11ca69ea887cf6 (diff)
downloade2fsprogs-d6ed24794e408a51cee2429841cc452323da4af8.tar.gz
e2fsck: double cast a pointer to suppress a bogus compiler warning in kfree()
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>
-rw-r--r--e2fsck/jfs_user.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h
index 1167c80d3..5928a8a8e 100644
--- a/e2fsck/jfs_user.h
+++ b/e2fsck/jfs_user.h
@@ -179,7 +179,17 @@ _INLINE_ void *kmalloc(size_t size, gfp_t flags EXT2FS_ATTR((unused)))
_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 */