Skip to contentSkip to conversation

ACPI: OSL: add __printf format attribute to acpi_os_vprintf

PATCH In review Su Hui 2 participants 2 messages Aug 31, 2023 – Sep 21, 2023

Subsystems (2)
lore
Share & tools
lore

Su Hui

author
#0 lore raw

PATCH 2/2 ACPI: OSL: add __printf format attribute to acpi_os_vprintf

With gcc and W=1 option to compile kernel, warning happends:

drivers/acpi/osl.c:156:2: error:
function ‘acpi_os_vprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format].

Allow the compiler to recognize and check format strings is safer.

---
 drivers/acpi/osl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/osl.c +1 -1
index f725813d0cce..357f1325485d 100644
@@ -149,7 +149,7 @@ void acpi_os_printf(const char *fmt, ...)
 }
 EXPORT_SYMBOL(acpi_os_printf);
 
-void acpi_os_vprintf(const char *fmt, va_list args)
+void __printf(1, 0) acpi_os_vprintf(const char *fmt, va_list args)
 {
 	static char buffer[512];
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 19 lines · Su Hui

With gcc and W=1 option to compile kernel, warning happends:

drivers/acpi/osl.c:156:2: error:
function ‘acpi_os_vprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format].

Allow the compiler to recognize and check format strings is safer.

---
 drivers/acpi/osl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/osl.c +0 -0
index f725813d0cce..357f1325485d 100644

drivers/acpi/osl.c void acpi_os_printf(const char *fmt, ...)

Quoted 9 lines
drivers/acpi/osl.c +1 -2
@@ -149,7 +149,7 @@ void acpi_os_printf(const char *fmt, ...)
 }
 EXPORT_SYMBOL(acpi_os_printf);
 
-void acpi_os_vprintf(const char *fmt, va_list args)
+void __printf(1, 0) acpi_os_vprintf(const char *fmt, va_list args)
 {
        static char buffer[512];
 
--

Applied (with some subject and changelog edits) as 6.7 material, thanks!