Skip to contentSkip to conversation

hwmon: (occ) Mark occ_init_attribute() as __printf

PATCH Applied Arnd Bergmann 2 participants 2 messages Feb 3 – Feb 4 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (occ) Mark occ_init_attribute() as __printf

From: Arnd Bergmann <[email protected]>

This is a printf-style function, which gcc -Werror=suggest-attribute=format correctly points out:

drivers/hwmon/occ/common.c: In function 'occ_init_attribute':
drivers/hwmon/occ/common.c:761:9: error: function 'occ_init_attribute' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]

Add the attribute to avoid this warning and ensure any incorrect format strings are detected here.

Fixes 744c2fe950e9 ("hwmon: (occ) Rework attribute registration for stack usage")
---
 drivers/hwmon/occ/common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/occ/common.c +1 -0
index b3694a4209b9..89928d38831b 100644
@@ -749,6 +749,7 @@ static ssize_t occ_show_extended(struct device *dev,
  * are dynamically allocated, we cannot use the existing kernel macros which
  * stringify the name argument.
  */
+__printf(7, 8)
 static void occ_init_attribute(struct occ_attribute *attr, int mode,
 	ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf),
 	ssize_t (*store)(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This is a printf-style function, which gcc -Werror=suggest-attribute=format correctly points out:

Quoted 8 lines

drivers/hwmon/occ/common.c: In function 'occ_init_attribute':
drivers/hwmon/occ/common.c:761:9: error: function 'occ_init_attribute' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]

Add the attribute to avoid this warning and ensure any incorrect format strings are detected here.

Fixes 744c2fe950e9 ("hwmon: (occ) Rework attribute registration for stack usage")

Applied.

Thanks,
Guenter