scsi: libsas: Add __printf attribute to sas_ata_printk()
Subsystems (2)
PATCH 1/1 scsi: libsas: Add __printf attribute to sas_ata_printk()
sas_ata_printk() formats its variadic arguments via struct va_format and %pV before passing them to printk().
Because %pV hides the format string from the compiler, GCC does not suggest the format attribute under -Wsuggest-attribute=format, and callers do not get compile-time format string validation.
Add the __printf(3, 4) attribute to sas_ata_printk() to enable compile-time format string checking for its callers.
--- drivers/scsi/libsas/sas_ata.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/libsas/sas_ata.c +1 -0
@@ -372,6 +372,7 @@ static int local_ata_check_ready(struct ata_link *link) } } +__printf(3, 4)static int sas_ata_printk (const char *level,const struct domain_device *ddev,const char *fmt, ...) {
Signature · 1 line
2.39.5
Quoted 20 lines · Adrián García Casado
sas_ata_printk()formats its variadic arguments via structva_formatand %pV before passing them toprintk().Because %pV hides the format string from the compiler, GCC does not suggest the format attribute under -Wsuggest-attribute=format, and callers do not get compile-time format string validation.
Add the
__printf(3, 4)attribute tosas_ata_printk()to enable compile-time format string checking for its callers.Signed-off-by Adrián García Casado <[email protected]>--- drivers/scsi/libsas/sas_ata.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/libsas/sas_ata.c +0
-0
drivers/scsi/libsas/sas_ata.c static int local_ata_check_ready(struct ata_link *link) · line 373
Quoted 2 lines
drivers/scsi/libsas/sas_ata.c +0
-0@@ -372,6 +372,7 @@ static int local_ata_check_ready(struct ata_link *link) } }
I checked https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#Common-Function-Attributes format section, and this looks sane, so:
Quoted 5 lines
drivers/scsi/libsas/sas_ata.c +1
-0+__printf(3, 4)static int sas_ata_printk (const char *level,const struct domain_device *ddev,const char *fmt, ...) {
Adrián,
Quoted 2 lines
sas_ata_printk()formats its variadic arguments via structva_formatand %pV before passing them toprintk().
Applied to 7.4/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Quoted 8 lines · Adrián García Casado
sas_ata_printk()formats its variadic arguments via structva_formatand %pV before passing them toprintk().Because %pV hides the format string from the compiler, GCC does not suggest the format attribute under -Wsuggest-attribute=format, and callers do not get compile-time format string validation.
[...]
Applied to 7.4/scsi-queue, thanks!
[1/1] scsi: libsas: Add __printf attribute to sas_ata_printk()
https://git.kernel.org/mkp/scsi/c/503e6172fa74
Signature · 1 line
Martin K. Petersen