[PATCH] lib/vsprintf: include stdarg.h from sprintf.h to provide va_list

Dmitry Torokhov posted 1 patch 3 months, 1 week ago
include/linux/sprintf.h | 1 +
1 file changed, 1 insertion(+)
[PATCH] lib/vsprintf: include stdarg.h from sprintf.h to provide va_list
Posted by Dmitry Torokhov 3 months, 1 week ago
Declarations in sprintf.h use va_list so it needs to include stdarg.h,
otherwise we may be getting warnings like this:

./include/linux/sprintf.h:11:54: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   11 | __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
      |                                                      ^
      |                                                      int

Fixes: 39ced19b9e60 ("lib/vsprintf: split out sprintf() and friends")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

Can I take it through my tree if acked?

 include/linux/sprintf.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h
index 51cab2def9ec..9ec0033f4106 100644
--- a/include/linux/sprintf.h
+++ b/include/linux/sprintf.h
@@ -3,6 +3,7 @@
 #define _LINUX_KERNEL_SPRINTF_H_
 
 #include <linux/compiler_attributes.h>
+#include <linux/stdarg.h>
 #include <linux/types.h>
 
 int num_to_str(char *buf, int size, unsigned long long num, unsigned int width);
-- 
2.50.0.727.gbf7dc18ff4-goog


-- 
Dmitry
Re: [PATCH] lib/vsprintf: include stdarg.h from sprintf.h to provide va_list
Posted by Andy Shevchenko 3 months, 1 week ago
On Tue, Jul 01, 2025 at 09:27:24PM -0700, Dmitry Torokhov wrote:
> Declarations in sprintf.h use va_list so it needs to include stdarg.h,
> otherwise we may be getting warnings like this:
> 
> ./include/linux/sprintf.h:11:54: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
>    11 | __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
>       |                                                      ^
>       |                                                      int

Ah, thanks for a good catch!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko