clang-22 started warning about functions that take printf format
strings:
drivers/scsi/esas2r/esas2r_log.c:160:50: error: diagnostic behavior may be improved by adding the 'format(printf, 3, 0)' attribute to the declaration of 'esas2r_log_master' [-Werror,-Wmissing-format-attribute]
121 | retval = vsnprintf(buffer, buflen, format, args);
| ^
drivers/scsi/esas2r/esas2r_log.c:121:12: note: 'esas2r_log_master' declared here
121 | static int esas2r_log_master(const long level,
| ^
The warning already got silenced for gcc but not clang in the past.
Rather than modify that hack to turn it off for both, just add the
attribute as suggested and remove the pragma again.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260323100027.1975646-1-arnd@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
}
}
-#pragma GCC diagnostic push
-#ifndef __clang__
-#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
-#endif
-
/*
* the master logging function. this function will format the message as
* outlined by the formatting string, the input device information and the
*
* @return 0 on success, or -1 if an error occurred.
*/
-static int esas2r_log_master(const long level,
- const struct device *dev,
- const char *format,
- va_list args)
+static __printf(3, 0)
+int esas2r_log_master(const long level, const struct device *dev,
+ const char *format, va_list args)
{
if (level <= event_log_level) {
unsigned long flags = 0;
return 0;
}
-#pragma GCC diagnostic pop
-
/*
* formats and logs a message to the system log.
*