Skip to content

Commit

Permalink
printk: add __printf attributes to internal functions
Browse files Browse the repository at this point in the history
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.

Link: http://lkml.kernel.org/r/[email protected]
Cc: Steven Rostedt <[email protected]>
Cc: [email protected]
Signed-off-by: Nicolas Iooss <[email protected]>
Reviewed-by: Sergey Senozhatsky <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
  • Loading branch information
fishilico authored and pmladek committed Jun 13, 2017
1 parent 719f6a7 commit f4e981c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kernel/printk/printk_safe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -330,7 +330,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;
}
Expand All @@ -342,7 +342,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);

Expand Down

0 comments on commit f4e981c

Please sign in to comment.