printk: add __printf attributes to internal functions
PATCH 1/1 printk: add __printf attributes to internal functions
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in kernel/printk/printk_safe.c transmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant __printf attributes.
--- kernel/printk/printk_safe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/printk/printk_safe.c +4 -4
@@ -80,8 +80,8 @@ static void queue_flush_work(struct printk_safe_seq_buf *s)* happen, printk_safe_log_store() will notice the buffer->len mismatch * and repeat the write. */ -static int printk_safe_log_store (struct printk_safe_seq_buf *s, -const char *fmt,va_list args) +static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, + const char *fmt, va_list args) { int add;size_t len;
@@ -299,7 +299,7 @@ void printk_safe_flush_on_panic(void)* one writer running. But the buffer might get flushed from another * CPU, so we need to be careful. */ -static int vprintk_nmi (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args) { struct printk_safe_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
@@ -330,7 +330,7 @@ static int vprintk_nmi(const char *fmt, va_list args)* into itself. It uses a per-CPU buffer to store the message, just like * NMI. */ -static int vprintk_safe (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_safe(const char *fmt, va_list args) { struct printk_safe_seq_buf *s = this_cpu_ptr(&safe_print_seq);
Signature · 1 line
2.12.2
Quoted 6 lines · Nicolas Iooss
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in
kernel/printk/printk_safe.ctransmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant__printfattributes.Signed-off-by Nicolas Iooss <[email protected]>
no objections from my side.
-ss
Quoted 26 lines · Nicolas Iooss
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in
kernel/printk/printk_safe.ctransmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant__printfattributes.Signed-off-by Nicolas Iooss <[email protected]>--- kernel/printk/printk_safe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)kernel/printk/printk_safe.c +2
-2@@ -80,8 +80,8 @@ static void queue_flush_work(struct printk_safe_seq_buf *s)* happen, printk_safe_log_store() will notice the buffer->len mismatch * and repeat the write. */ -static int printk_safe_log_store (struct printk_safe_seq_buf *s, -const char *fmt,va_list args) +static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, + const char *fmt, va_list args) { int add;size_t len;
kernel/printk/printk_safe.c void printk_safe_flush_on_panic(void) · line 302
Quoted 5 lines
kernel/printk/printk_safe.c +1
-1@@ -299,7 +299,7 @@ void printk_safe_flush_on_panic(void)* one writer running. But the buffer might get flushed from another * CPU, so we need to be careful. */ -static int vprintk_nmi (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args)
There is one more variant of this function used when CONFIG_PRINTK_NMI is not defined. Feel free to send updated patch as a reply. Or I could add this trivial change when pushing this patch to printk.git if nobody complains.
Otherwise, the patch looks fine to me. Therefore with patching the other vprintk_nmi() variant:
Best Regards,
Petr
PATCH v2 1/1 printk: add __printf attributes to internal functions
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in kernel/printk/printk_safe.c transmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant __printf attributes.
---
v2: add __printf attribute to the definition of vprintk_nmi() which is used when CONFIG_PRINTK_NMI is not defined.
kernel/printk/printk_safe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/printk/printk_safe.c +5 -5
@@ -80,8 +80,8 @@ static void queue_flush_work(struct printk_safe_seq_buf *s)* happen, printk_safe_log_store() will notice the buffer->len mismatch * and repeat the write. */ -static int printk_safe_log_store (struct printk_safe_seq_buf *s, -const char *fmt,va_list args) +static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, + const char *fmt, va_list args) { int add;size_t len;
@@ -299,7 +299,7 @@ void printk_safe_flush_on_panic(void)* one writer running. But the buffer might get flushed from another * CPU, so we need to be careful. */ -static int vprintk_nmi (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args) { struct printk_safe_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
@@ -318,7 +318,7 @@ void printk_nmi_exit(void)#else -static int vprintk_nmi (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args) {return 0 ; }
@@ -330,7 +330,7 @@ static int vprintk_nmi(const char *fmt, va_list args)* into itself. It uses a per-CPU buffer to store the message, just like * NMI. */ -static int vprintk_safe (const char *fmt,va_list args) +static __printf(1, 0) int vprintk_safe(const char *fmt, va_list args) { struct printk_safe_seq_buf *s = this_cpu_ptr(&safe_print_seq);
Signature · 1 line
2.13.0
Petr Mladek
maintainerQuoted 10 lines · Nicolas Iooss
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in
kernel/printk/printk_safe.ctransmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant__printfattributes.Signed-off-by Nicolas Iooss <[email protected]>Acked-by Petr Mladek <[email protected]>---
v2: add__printfattribute to the definition ofvprintk_nmi()which is used whenCONFIG_PRINTK_NMIis not defined.
Sergey, I believe that that your Reviewed-by is still valid even after this small update. Is that true, please?
Best Regards,
Petr
Sergey Senozhatsky
Reviewed-byQuoted 6 lines · Petr Mladek
Quoted 5 lines · Nicolas Iooss
When compiling with -Wsuggest-attribute=format, gcc complains that some functions in
kernel/printk/printk_safe.ctransmit their argument to printf-like functions without having a printf attribute. Silence these warnings by adding relevant__printfattributes.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Nicolas Iooss <[email protected]>Acked-by Petr Mladek <[email protected]>---
v2: add__printfattribute to the definition ofvprintk_nmi()which is used whenCONFIG_PRINTK_NMIis not defined.Sergey, I believe that that your Reviewed-by is still valid even after this small update. Is that true, please?
sure. sorry about that!
-ss