Skip to contentSkip to conversation

scsi: libsas: Add __printf attribute to sas_ata_printk()

PATCH Applied Adrián García Casado 3 participants 4 messages Oct 20 – Oct 31

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 61368e55bf..53eac56c3a 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Adrián García Casado

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 +0 -0
index 61368e55bf..53eac56c3a 100644

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, ...)
  {
maintainer Applied
#2 lore raw
In reply to Adrián García Casado

Adrián,

Quoted 2 lines

sas_ata_printk() formats its variadic arguments via struct va_format and %pV before passing them to printk().

Applied to 7.4/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
maintainer Applied
#3 lore raw
In reply to Adrián García Casado
Quoted 8 lines · Adrián García Casado

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.

[...]

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