linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] printk: add __printf attributes to internal functions
@ 2017-05-20  9:18 Nicolas Iooss
  2017-05-22  2:48 ` Sergey Senozhatsky
  2017-05-22 15:22 ` Petr Mladek
  0 siblings, 2 replies; 6+ messages in thread
From: Nicolas Iooss @ 2017-05-20  9:18 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky, Steven Rostedt
  Cc: linux-kernel, Nicolas Iooss

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.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 kernel/printk/printk_safe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 033e50a7d706..2e27a31941f4 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -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);
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] printk: add __printf attributes to internal functions
  2017-05-20  9:18 [PATCH 1/1] printk: add __printf attributes to internal functions Nicolas Iooss
@ 2017-05-22  2:48 ` Sergey Senozhatsky
  2017-05-22 15:22 ` Petr Mladek
  1 sibling, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2017-05-22  2:48 UTC (permalink / raw)
  To: Nicolas Iooss
  Cc: Petr Mladek, Sergey Senozhatsky, Steven Rostedt, linux-kernel

On (05/20/17 11:18), Nicolas Iooss wrote:
> 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.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>

no objections from my side.

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] printk: add __printf attributes to internal functions
  2017-05-20  9:18 [PATCH 1/1] printk: add __printf attributes to internal functions Nicolas Iooss
  2017-05-22  2:48 ` Sergey Senozhatsky
@ 2017-05-22 15:22 ` Petr Mladek
  2017-05-24  5:49   ` [PATCH v2 " Nicolas Iooss
  1 sibling, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2017-05-22 15:22 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: Sergey Senozhatsky, Steven Rostedt, linux-kernel

On Sat 2017-05-20 11:18:53, Nicolas Iooss wrote:
> 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.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> ---
>  kernel/printk/printk_safe.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
> index 033e50a7d706..2e27a31941f4 100644
> --- a/kernel/printk/printk_safe.c
> +++ b/kernel/printk/printk_safe.c
> @@ -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)

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:

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/1] printk: add __printf attributes to internal functions
  2017-05-22 15:22 ` Petr Mladek
@ 2017-05-24  5:49   ` Nicolas Iooss
  2017-05-25 11:29     ` Petr Mladek
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Iooss @ 2017-05-24  5:49 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky, Steven Rostedt
  Cc: linux-kernel, Nicolas Iooss

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.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Acked-by: Petr Mladek <pmladek@suse.com>
---
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(-)

diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 033e50a7d706..f96d1ecd85ac 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -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);
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] printk: add __printf attributes to internal functions
  2017-05-24  5:49   ` [PATCH v2 " Nicolas Iooss
@ 2017-05-25 11:29     ` Petr Mladek
  2017-05-25 12:02       ` Sergey Senozhatsky
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2017-05-25 11:29 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: Nicolas Iooss, Steven Rostedt, linux-kernel

On Wed 2017-05-24 07:49:50, Nicolas Iooss wrote:
> 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.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> Acked-by: Petr Mladek <pmladek@suse.com>
> ---
> v2: add __printf attribute to the definition of vprintk_nmi() which is
> used when CONFIG_PRINTK_NMI is 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] printk: add __printf attributes to internal functions
  2017-05-25 11:29     ` Petr Mladek
@ 2017-05-25 12:02       ` Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2017-05-25 12:02 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Nicolas Iooss, Steven Rostedt, linux-kernel

On (05/25/17 13:29), Petr Mladek wrote:
> On Wed 2017-05-24 07:49:50, Nicolas Iooss wrote:
> > 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.
> > 
> > Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> > Acked-by: Petr Mladek <pmladek@suse.com>
> > ---
> > v2: add __printf attribute to the definition of vprintk_nmi() which is
> > used when CONFIG_PRINTK_NMI is 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!

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-25 12:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20  9:18 [PATCH 1/1] printk: add __printf attributes to internal functions Nicolas Iooss
2017-05-22  2:48 ` Sergey Senozhatsky
2017-05-22 15:22 ` Petr Mladek
2017-05-24  5:49   ` [PATCH v2 " Nicolas Iooss
2017-05-25 11:29     ` Petr Mladek
2017-05-25 12:02       ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).