]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: use the condition in AA_BUG_FMT even with debug disabled
authorMateusz Guzik <mjguzik@gmail.com>
Mon, 27 Jan 2025 20:54:04 +0000 (21:54 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Mon, 10 Feb 2025 19:17:59 +0000 (11:17 -0800)
This follows the established practice and fixes a build failure for me:
security/apparmor/file.c: In function ‘__file_sock_perm’:
security/apparmor/file.c:544:24: error: unused variable ‘sock’ [-Werror=unused-variable]
  544 |         struct socket *sock = (struct socket *) file->private_data;
      |                        ^~~~

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/include/lib.h

index 256f4577c65356cd800ab897b5ff0d95f478a708..d947998262b261c5daed8f6a567f507a320c5d51 100644 (file)
@@ -60,7 +60,11 @@ do {                                                                 \
 #define AA_BUG_FMT(X, fmt, args...)                                    \
        WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
 #else
-#define AA_BUG_FMT(X, fmt, args...) no_printk(fmt, ##args)
+#define AA_BUG_FMT(X, fmt, args...)                                    \
+       do {                                                            \
+               BUILD_BUG_ON_INVALID(X);                                \
+               no_printk(fmt, ##args);                                 \
+       } while (0)
 #endif
 
 int aa_parse_debug_params(const char *str);