Re: [PATCH] bpf: add missing __printf attributes
From: Alexei Starovoitov
Date: Tue Feb 03 2026 - 19:34:14 EST
On Tue, Feb 3, 2026 at 3:21 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Tue, Feb 3, 2026, at 19:11, Alexei Starovoitov wrote:
> > On Tue, Feb 3, 2026 at 9:44 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> >> On Tue, Feb 3, 2026, at 18:24, Alexei Starovoitov wrote:
> >> I also see the comment about bstr_printf() mention that it
> >> uses a vsnprintf() compatible format, which would indicate that
> >> marking the format argument isn't wrong, though I agree it is
> >> not actually useful if there are no callers that pass a string
> >> literal.
> >
> > In general I don't think it's a good idea to add nop annotations
> > just to shut up over eager compiler warning.
>
> I've tried removing these three below, which now gives me
> a clean build with -Wsuggest-attribute=format, after the
> other three patches I posted for unrelated code.
Nice. lgtm. Ack.
> Arnd
>
> diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
> index d6ebf0596510..2fb266ea69fa 100644
> --- a/include/linux/seq_file.h
> +++ b/include/linux/seq_file.h
> @@ -181,7 +181,6 @@ int seq_open_private(struct file *, const struct seq_operations *, int);
> int seq_release_private(struct inode *, struct file *);
>
> #ifdef CONFIG_BINARY_PRINTF
> -__printf(2, 0)
> void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary);
> #endif
>
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 1b564c36d721..b850bd91b3d8 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -336,8 +336,8 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s);
> #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
>
> #ifdef CONFIG_BINARY_PRINTF
> -__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
> -__printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
> +int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
> +int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
> #endif
>
> extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,