Skip to contentSkip to conversation

backing: silence compiler warning using __printf

PATCH Applied Mathieu Malaterre 3 participants 3 messages Apr 6, 2018 – Apr 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backing: silence compiler warning using __printf

__printf marker was added in commit d2cc4dde9206 ("bdi_register: add __printf verification, fix arg mismatch") for function bdi_register since it is useful to verify format and arguments. Apply equivalent gcc attribute to bdi_register_va.

Remove warning triggered with W=1:

mm/backing-dev.c:881:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]

---
 include/linux/backing-dev.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/backing-dev.h +1 -0
index 3e4ce54d84ab..0e9c0f71f726 100644
@@ -28,6 +28,7 @@ void bdi_put(struct backing_dev_info *bdi);
 
 __printf(2, 3)
 int bdi_register(struct backing_dev_info *bdi, const char *fmt, ...);
+__printf(2, 0)
 int bdi_register_va(struct backing_dev_info *bdi, const char *fmt,
 		    va_list args);
 int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Mathieu Malaterre

__printf marker was added in commit d2cc4dde9206 ("bdi_register: add __printf verification, fix arg mismatch") for function bdi_register since it is useful to verify format and arguments. Apply equivalent gcc attribute to bdi_register_va.

Quoted 8 lines

Remove warning triggered with W=1:

mm/backing-dev.c:881:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]

---
 include/linux/backing-dev.h | 1 +
 1 file changed, 1 insertion(+)

Yeah, the patch looks good. You can add:

Honza

Quoted 16 lines
include/linux/backing-dev.h +1 -0
index 3e4ce54d84ab..0e9c0f71f726 100644
@@ -28,6 +28,7 @@ void bdi_put(struct backing_dev_info *bdi);
 
 __printf(2, 3)
 int bdi_register(struct backing_dev_info *bdi, const char *fmt, ...);
+__printf(2, 0)
 int bdi_register_va(struct backing_dev_info *bdi, const char *fmt,
 		    va_list args);
 int bdi_register_owner(struct backing_dev_info *bdi, struct device *owner);
Signature · 1 line
2.11.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Applied
#2 lore raw
In reply to Mathieu Malaterre
Quoted 8 lines · Mathieu Malaterre

__printf marker was added in commit d2cc4dde9206 ("bdi_register: add __printf verification, fix arg mismatch") for function bdi_register since it is useful to verify format and arguments. Apply equivalent gcc attribute to bdi_register_va.

Remove warning triggered with W=1:

mm/backing-dev.c:881:2: warning: function might be possible candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]

Applied, thanks.

Signature · 1 line
Jens Axboe