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 commita3fa71c40f
("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 commit5ce1aca814
("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>
This commit is contained in:
parent
7f9be77555
commit
8db1486065
12 changed files with 36 additions and 30 deletions
|
@ -637,8 +637,9 @@ extern int devres_release_group(struct device *dev, void *id);
|
|||
|
||||
/* managed devm_k.alloc/kfree for device drivers */
|
||||
extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
|
||||
extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
|
||||
va_list ap);
|
||||
extern __printf(3, 0)
|
||||
char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
|
||||
va_list ap);
|
||||
extern __printf(3, 4)
|
||||
char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
|
||||
static 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);
|
|||
/*
|
||||
* Easy functions for dynamically creating devices on the fly
|
||||
*/
|
||||
extern struct device *device_create_vargs(struct class *cls,
|
||||
struct device *parent,
|
||||
dev_t devt,
|
||||
void *drvdata,
|
||||
const char *fmt,
|
||||
va_list vargs);
|
||||
extern __printf(5, 0)
|
||||
struct device *device_create_vargs(struct class *cls, struct device *parent,
|
||||
dev_t devt, void *drvdata,
|
||||
const char *fmt, va_list vargs);
|
||||
extern __printf(5, 6)
|
||||
struct device *device_create(struct class *cls, struct device *parent,
|
||||
dev_t devt, void *drvdata,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue