audit: Mark audit_log_vformat() with __printf() attribute
PATCH 1/1 audit: Mark audit_log_vformat() with __printf() attribute
audit_log_vformat() is using printf() type of format, and compiler is not happy about this:
kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
Fix the compilation errors by adding __printf() attribute.
--- kernel/audit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/audit.c +2 -2
@@ -1956,8 +1956,8 @@ static inline int audit_expand(struct audit_buffer *ab, int extra)* will be called a second time. Currently, we assume that a printk * can't format message larger than 1024 bytes, so we don't either. */ -static void audit_log_vformat (struct audit_buffer *ab,const char *fmt, -va_list args) +static __printf(2, 0) +void audit_log_vformat(struct audit_buffer *ab, const char *fmt, va_list args) { int len, avail;struct sk_buff *skb;
Signature · 1 line
2.47.2
Paul Moore
maintainerQuoted 7 lines · Andy Shevchenko
audit_log_vformat()is usingprintf()type of format, and compiler is not happy about this:
kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
Quoted 6 lines
Fix the compilation errors by adding
__printf()attribute.Signed-off-by Andy Shevchenko <[email protected]>--- kernel/audit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
It would be good to list the compiler version/flags that triggers this error in the patch description as I've compiled the audit code quite a bit and haven't seen these errors :)
Quoted 17 lines
kernel/audit.c +2
-3@@ -1956,8 +1956,8 @@ static inline int audit_expand(struct audit_buffer *ab, int extra)* will be called a second time. Currently, we assume that a printk * can't format message larger than 1024 bytes, so we don't either. */ -static void audit_log_vformat (struct audit_buffer *ab,const char *fmt, -va_list args) +static __printf(2, 0) +void audit_log_vformat(struct audit_buffer *ab, const char *fmt, va_list args) { int len, avail;struct sk_buff *skb; --2.47.2
Signature · 1 line
paul-moore.com
Quoted 6 lines · Paul Moore
Quoted 4 lines · Andy Shevchenko
audit_log_vformat()is usingprintf()type of format, and compiler is not happy about this:
Quoted 7 lines
Quoted 4 lines
kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]Fix the compilation errors by adding
__printf()attribute.It would be good to list the compiler version/flags that triggers this error in the patch description
CONFIG_WERROR=y (this is default), gcc (Debian 14.2.0-17) 14.2.0, make W=1.
Quoted 1 line
as I've compiled the audit code quite a bit and haven't seen these errors :)
Good for you, I have 100% reproducibility of this :-)
I'll do a v2 today.
Signature · 2 lines
With Best Regards, Andy Shevchenko