Skip to content

Commit 4d47fbb

Browse files
committed
apparmor: fix zero-length compiler warning in AA_BUG()
Uses of AA_BUG() without a message can result in the compiler warning warning: zero-length gnu_printf format string [-Wformat-zero-length] Fix this with a pragma for now. A larger rework of AA_BUG() will follow. Signed-off-by: John Johansen <[email protected]>
1 parent d0d845a commit 4d47fbb

File tree

1 file changed

+6
-1
lines changed
  • security/apparmor/include

1 file changed

+6
-1
lines changed

security/apparmor/include/lib.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131

3232
#define AA_WARN(X) WARN((X), "APPARMOR WARN %s: %s\n", __func__, #X)
3333

34-
#define AA_BUG(X, args...) AA_BUG_FMT((X), "" args)
34+
#define AA_BUG(X, args...) \
35+
do { \
36+
_Pragma("GCC diagnostic ignored \"-Wformat-zero-length\""); \
37+
AA_BUG_FMT((X), "" args); \
38+
_Pragma("GCC diagnostic warning \"-Wformat-zero-length\""); \
39+
} while (0)
3540
#ifdef CONFIG_SECURITY_APPARMOR_DEBUG_ASSERTS
3641
#define AA_BUG_FMT(X, fmt, args...) \
3742
WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)

0 commit comments

Comments
 (0)