Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (occ) Mark occ_init_attribute() as __printf

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20260203163440.2674340-1-arnd@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Arnd Bergmann and committed by
Guenter Roeck
831a2b27 52fb36a5

+1
+1
drivers/hwmon/occ/common.c
··· 749 749 * are dynamically allocated, we cannot use the existing kernel macros which 750 750 * stringify the name argument. 751 751 */ 752 + __printf(7, 8) 752 753 static void occ_init_attribute(struct occ_attribute *attr, int mode, 753 754 ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf), 754 755 ssize_t (*store)(struct device *dev, struct device_attribute *attr,