aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>2015-07-17 19:23:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-17 19:39:53 -0400
commit8db1486065141e619e4855b84e350ef32064f7e1 (patch)
tree438cace62ece1251656b38fbf428cf5aa5184fb8 /include/linux/device.h
parent7f9be77555bb2e52de84e9dddf7b4eb20cc6e171 (diff)
include, lib: add __printf attributes to several function prototypes
Using __printf attributes helps to detect several format string issues at compile time (even though -Wformat-security is currently disabled in Makefile). For example it can detect when formatting a pointer as a number, like the issue fixed in commit a3fa71c40f18 ("wl18xx: show rx_frames_per_rates as an array as it really is"), or when the arguments do not match the format string, c.f. for example commit 5ce1aca81435 ("reiserfs: fix __RASSERT format string"). To prevent similar bugs in the future, add a __printf attribute to every function prototype which needs one in include/linux/ and lib/. These functions were mostly found by using gcc's -Wsuggest-attribute=format flag. Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Felipe Balbi <balbi@ti.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 5a31bf3a4024..a2b4ea70a946 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -637,8 +637,9 @@ extern int devres_release_group(struct device *dev, void *id);
637 637
638/* managed devm_k.alloc/kfree for device drivers */ 638/* managed devm_k.alloc/kfree for device drivers */
639extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp); 639extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
640extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, 640extern __printf(3, 0)
641 va_list ap); 641char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
642 va_list ap);
642extern __printf(3, 4) 643extern __printf(3, 4)
643char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...); 644char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
644static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) 645static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
@@ -1011,12 +1012,10 @@ extern int __must_check device_reprobe(struct device *dev);
1011/* 1012/*
1012 * Easy functions for dynamically creating devices on the fly 1013 * Easy functions for dynamically creating devices on the fly
1013 */ 1014 */
1014extern struct device *device_create_vargs(struct class *cls, 1015extern __printf(5, 0)
1015 struct device *parent, 1016struct device *device_create_vargs(struct class *cls, struct device *parent,
1016 dev_t devt, 1017 dev_t devt, void *drvdata,
1017 void *drvdata, 1018 const char *fmt, va_list vargs);
1018 const char *fmt,
1019 va_list vargs);
1020extern __printf(5, 6) 1019extern __printf(5, 6)
1021struct device *device_create(struct class *cls, struct device *parent, 1020struct device *device_create(struct class *cls, struct device *parent,
1022 dev_t devt, void *drvdata, 1021 dev_t devt, void *drvdata,