Skip to content

Commit

Permalink
apparmor: fix zero-length compiler warning in AA_BUG()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
John Johansen committed Nov 3, 2021
1 parent d0d845a commit 4d47fbb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion security/apparmor/include/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@

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

#define AA_BUG(X, args...) AA_BUG_FMT((X), "" args)
#define AA_BUG(X, args...) \
do { \
_Pragma("GCC diagnostic ignored \"-Wformat-zero-length\""); \
AA_BUG_FMT((X), "" args); \
_Pragma("GCC diagnostic warning \"-Wformat-zero-length\""); \
} while (0)
#ifdef CONFIG_SECURITY_APPARMOR_DEBUG_ASSERTS
#define AA_BUG_FMT(X, fmt, args...) \
WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
Expand Down

0 comments on commit 4d47fbb

Please sign in to comment.