]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: hide the drainbamaged fallthrough macro from xfslibs
authorDarrick J. Wong <djwong@kernel.org>
Mon, 6 Dec 2021 19:26:04 +0000 (14:26 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 6 Dec 2021 19:26:04 +0000 (14:26 -0500)
Back in mid-2021, Kees and Gustavo rammed into the kernel a bunch of
static checker "improvements" that redefined '/* fallthrough */'
comments for switch statements as a macro that virtualizes either that
same comment, a do-while loop, or a compiler __attribute__.  This was
necessary to work around the poor decision-making of the clang, gcc, and
C language standard authors, who collectively came up with four mutually
incompatible ways to document a lack of branching in a code flow.

Having received ZERO HELP porting this to userspace, Eric and I
foolishly dumped that crap into linux.h, which was a poor decision
because we keep forgetting that linux.h is exported as a userspace
header.  This has now caused downstream regressions in Debian[1] and
will probably cause more problems in the other distros.

Move it to platform_defs.h since that's not shipped publicly and leave a
warning to anyone else who dare modify linux.h.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000974

Fixes: df9c7d8d ("xfs: Fix fall-through warnings for Clang")
Cc: 1000974@bugs.debian.org, gustavoars@kernel.org, keescook@chromium.org
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
[sandeen: add comment to top of linux.h  per Dave's suggestion]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/linux.h
include/platform_defs.h.in

index 246502285b15af4c23474c6a20dd3ec80a09d6de..de8a71221146c9dda5cb9bbfe9b2dd6dcdf6bd2c 100644 (file)
@@ -5,6 +5,11 @@
 #ifndef __XFS_LINUX_H__
 #define __XFS_LINUX_H__
 
+/*
+ * Reminder: anything added to this file will be compiled into downstream
+ * userspace projects!
+ */
+
 #include <uuid/uuid.h>
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
@@ -360,24 +365,8 @@ fsmap_advance(
 #endif /* HAVE_MAP_SYNC */
 
 /*
- * Add the pseudo keyword 'fallthrough' so case statement blocks
- * must end with any of these keywords:
- *   break;
- *   fallthrough;
- *   continue;
- *   goto <label>;
- *   return [expression];
- *
- *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ * Reminder: anything added to this file will be compiled into downstream
+ * userspace projects!
  */
-#if defined __has_attribute
-#  if __has_attribute(__fallthrough__)
-#    define fallthrough                    __attribute__((__fallthrough__))
-#  else
-#    define fallthrough                    do {} while (0)  /* fallthrough */
-#  endif
-#else
-#    define fallthrough                    do {} while (0)  /* fallthrough */
-#endif
 
 #endif /* __XFS_LINUX_H__ */
index 7c6b3ada0bb4132579e4d8d883c36bb3f0d54d3d..6e6f26ef5f8e4e5a388e922e1e979b1c554103d4 100644 (file)
@@ -113,4 +113,25 @@ static inline size_t __ab_c_size(size_t a, size_t b, size_t c)
                sizeof(*(p)->member) + __must_be_array((p)->member),    \
                sizeof(*(p)))
 
+/*
+ * Add the pseudo keyword 'fallthrough' so case statement blocks
+ * must end with any of these keywords:
+ *   break;
+ *   fallthrough;
+ *   continue;
+ *   goto <label>;
+ *   return [expression];
+ *
+ *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ */
+#if defined __has_attribute
+#  if __has_attribute(__fallthrough__)
+#    define fallthrough                    __attribute__((__fallthrough__))
+#  else
+#    define fallthrough                    do {} while (0)  /* fallthrough */
+#  endif
+#else
+#    define fallthrough                    do {} while (0)  /* fallthrough */
+#endif
+
 #endif /* __XFS_PLATFORM_DEFS_H__ */