Skip to content

Commit af54a3a

Browse files
committed
Merge tag 'printk-for-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull more printk updates from Petr Mladek: - Silence warnings about candidates for ‘gnu_print’ format attribute * tag 'printk-for-6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: vsnprintf: Silence false positive GCC warning for va_format() vsnprintf: Drop unused const char fmt * in va_format() vsnprintf: Mark binary printing functions with __printf() attribute tracing: Mark binary printing functions with __printf() attribute seq_file: Mark binary printing functions with __printf() attribute seq_buf: Mark binary printing functions with __printf() attribute
2 parents da0512b + bd67c1c commit af54a3a

File tree

8 files changed

+30
-27
lines changed

8 files changed

+30
-27
lines changed

include/linux/seq_buf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ extern int seq_buf_hex_dump(struct seq_buf *s, const char *prefix_str,
167167
const void *buf, size_t len, bool ascii);
168168

169169
#ifdef CONFIG_BINARY_PRINTF
170-
extern int
171-
seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
170+
__printf(2, 0)
171+
int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
172172
#endif
173173

174174
void seq_buf_do_printk(struct seq_buf *s, const char *lvl);

include/linux/seq_file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ int seq_open_private(struct file *, const struct seq_operations *, int);
181181
int seq_release_private(struct inode *, struct file *);
182182

183183
#ifdef CONFIG_BINARY_PRINTF
184+
__printf(2, 0)
184185
void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary);
185186
#endif
186187

include/linux/string.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s);
336336
#define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
337337

338338
#ifdef CONFIG_BINARY_PRINTF
339-
int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
340-
int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
339+
__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
340+
__printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
341341
#endif
342342

343343
extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,

include/linux/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ static inline int unregister_ftrace_export(struct trace_export *export)
7272
static inline void trace_printk_init_buffers(void)
7373
{
7474
}
75-
static inline int trace_array_printk(struct trace_array *tr, unsigned long ip,
76-
const char *fmt, ...)
75+
static inline __printf(3, 4)
76+
int trace_array_printk(struct trace_array *tr, unsigned long ip, const char *fmt, ...)
7777
{
7878
return 0;
7979
}

include/linux/trace_seq.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ extern __printf(2, 3)
8888
void trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
8989
extern __printf(2, 0)
9090
void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
91-
extern void
92-
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
91+
extern __printf(2, 0)
92+
void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
9393
extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
9494
extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
9595
int cnt);
@@ -113,8 +113,8 @@ static inline __printf(2, 3)
113113
void trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
114114
{
115115
}
116-
static inline void
117-
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
116+
static inline __printf(2, 0)
117+
void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
118118
{
119119
}
120120

kernel/trace/trace.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,10 +3341,9 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
33413341
}
33423342
EXPORT_SYMBOL_GPL(trace_vbprintk);
33433343

3344-
__printf(3, 0)
3345-
static int
3346-
__trace_array_vprintk(struct trace_buffer *buffer,
3347-
unsigned long ip, const char *fmt, va_list args)
3344+
static __printf(3, 0)
3345+
int __trace_array_vprintk(struct trace_buffer *buffer,
3346+
unsigned long ip, const char *fmt, va_list args)
33483347
{
33493348
struct ring_buffer_event *event;
33503349
int len = 0, size;
@@ -3394,7 +3393,6 @@ __trace_array_vprintk(struct trace_buffer *buffer,
33943393
return len;
33953394
}
33963395

3397-
__printf(3, 0)
33983396
int trace_array_vprintk(struct trace_array *tr,
33993397
unsigned long ip, const char *fmt, va_list args)
34003398
{
@@ -3424,7 +3422,6 @@ int trace_array_vprintk(struct trace_array *tr,
34243422
* Note, trace_array_init_printk() must be called on @tr before this
34253423
* can be used.
34263424
*/
3427-
__printf(3, 0)
34283425
int trace_array_printk(struct trace_array *tr,
34293426
unsigned long ip, const char *fmt, ...)
34303427
{
@@ -3469,7 +3466,6 @@ int trace_array_init_printk(struct trace_array *tr)
34693466
}
34703467
EXPORT_SYMBOL_GPL(trace_array_init_printk);
34713468

3472-
__printf(3, 4)
34733469
int trace_array_printk_buf(struct trace_buffer *buffer,
34743470
unsigned long ip, const char *fmt, ...)
34753471
{
@@ -3485,7 +3481,6 @@ int trace_array_printk_buf(struct trace_buffer *buffer,
34853481
return ret;
34863482
}
34873483

3488-
__printf(2, 0)
34893484
int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
34903485
{
34913486
return trace_array_vprintk(printk_trace, ip, fmt, args);

kernel/trace/trace.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,15 @@ static inline void __init disable_tracing_selftest(const char *reason)
852852

853853
extern void *head_page(struct trace_array_cpu *data);
854854
extern unsigned long long ns2usecs(u64 nsec);
855-
extern int
856-
trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
857-
extern int
858-
trace_vprintk(unsigned long ip, const char *fmt, va_list args);
859-
extern int
860-
trace_array_vprintk(struct trace_array *tr,
861-
unsigned long ip, const char *fmt, va_list args);
855+
856+
__printf(2, 0)
857+
int trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
858+
__printf(2, 0)
859+
int trace_vprintk(unsigned long ip, const char *fmt, va_list args);
860+
__printf(3, 0)
861+
int trace_array_vprintk(struct trace_array *tr,
862+
unsigned long ip, const char *fmt, va_list args);
863+
__printf(3, 4)
862864
int trace_array_printk_buf(struct trace_buffer *buffer,
863865
unsigned long ip, const char *fmt, ...);
864866
void trace_printk_seq(struct trace_seq *s);

lib/vsprintf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,12 @@ char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
16991699
return buf;
17001700
}
17011701

1702+
#pragma GCC diagnostic push
1703+
#ifndef __clang__
1704+
#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
1705+
#endif
17021706
static char *va_format(char *buf, char *end, struct va_format *va_fmt,
1703-
struct printf_spec spec, const char *fmt)
1707+
struct printf_spec spec)
17041708
{
17051709
va_list va;
17061710

@@ -1713,6 +1717,7 @@ static char *va_format(char *buf, char *end, struct va_format *va_fmt,
17131717

17141718
return buf;
17151719
}
1720+
#pragma GCC diagnostic pop
17161721

17171722
static noinline_for_stack
17181723
char *uuid_string(char *buf, char *end, const u8 *addr,
@@ -2466,7 +2471,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
24662471
case 'U':
24672472
return uuid_string(buf, end, ptr, spec, fmt);
24682473
case 'V':
2469-
return va_format(buf, end, ptr, spec, fmt);
2474+
return va_format(buf, end, ptr, spec);
24702475
case 'K':
24712476
return restricted_pointer(buf, end, ptr, spec);
24722477
case 'N':

0 commit comments

Comments
 (0)