diff options
-rw-r--r-- | include/linux/compiler-gcc.h | 3 | ||||
-rw-r--r-- | include/linux/kernel.h | 8 | ||||
-rw-r--r-- | include/xen/xenbus.h | 4 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 6 |
4 files changed, 14 insertions, 7 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 3fd17c249221..e5834aa24b9e 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -87,7 +87,8 @@ | |||
87 | */ | 87 | */ |
88 | #define __pure __attribute__((pure)) | 88 | #define __pure __attribute__((pure)) |
89 | #define __aligned(x) __attribute__((aligned(x))) | 89 | #define __aligned(x) __attribute__((aligned(x))) |
90 | #define __printf(a,b) __attribute__((format(printf,a,b))) | 90 | #define __printf(a, b) __attribute__((format(printf, a, b))) |
91 | #define __scanf(a, b) __attribute__((format(scanf, a, b))) | ||
91 | #define noinline __attribute__((noinline)) | 92 | #define noinline __attribute__((noinline)) |
92 | #define __attribute_const__ __attribute__((__const__)) | 93 | #define __attribute_const__ __attribute__((__const__)) |
93 | #define __maybe_unused __attribute__((unused)) | 94 | #define __maybe_unused __attribute__((unused)) |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d801acb5e680..f2085b541a24 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -328,10 +328,10 @@ extern __printf(2, 3) | |||
328 | char *kasprintf(gfp_t gfp, const char *fmt, ...); | 328 | char *kasprintf(gfp_t gfp, const char *fmt, ...); |
329 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); | 329 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
330 | 330 | ||
331 | extern int sscanf(const char *, const char *, ...) | 331 | extern __scanf(2, 3) |
332 | __attribute__ ((format (scanf, 2, 3))); | 332 | int sscanf(const char *, const char *, ...); |
333 | extern int vsscanf(const char *, const char *, va_list) | 333 | extern __scanf(2, 0) |
334 | __attribute__ ((format (scanf, 2, 0))); | 334 | int vsscanf(const char *, const char *, va_list); |
335 | 335 | ||
336 | extern int get_option(char **str, int *pint); | 336 | extern int get_option(char **str, int *pint); |
337 | extern char *get_options(const char *str, int nints, int *ints); | 337 | extern char *get_options(const char *str, int nints, int *ints); |
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index e8c599b237c2..0a7515c1e3a4 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h | |||
@@ -139,9 +139,9 @@ int xenbus_transaction_start(struct xenbus_transaction *t); | |||
139 | int xenbus_transaction_end(struct xenbus_transaction t, int abort); | 139 | int xenbus_transaction_end(struct xenbus_transaction t, int abort); |
140 | 140 | ||
141 | /* Single read and scanf: returns -errno or num scanned if > 0. */ | 141 | /* Single read and scanf: returns -errno or num scanned if > 0. */ |
142 | __scanf(4, 5) | ||
142 | int xenbus_scanf(struct xenbus_transaction t, | 143 | int xenbus_scanf(struct xenbus_transaction t, |
143 | const char *dir, const char *node, const char *fmt, ...) | 144 | const char *dir, const char *node, const char *fmt, ...); |
144 | __attribute__((format(scanf, 4, 5))); | ||
145 | 145 | ||
146 | /* Single printf and write: returns -errno or 0. */ | 146 | /* Single printf and write: returns -errno or 0. */ |
147 | __printf(4, 5) | 147 | __printf(4, 5) |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a3b9782441f9..89d24b3ea438 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -3123,6 +3123,12 @@ sub process { | |||
3123 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr); | 3123 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr); |
3124 | } | 3124 | } |
3125 | 3125 | ||
3126 | # Check for __attribute__ format(scanf, prefer __scanf | ||
3127 | if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { | ||
3128 | WARN("PREFER_SCANF", | ||
3129 | "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr); | ||
3130 | } | ||
3131 | |||
3126 | # check for sizeof(&) | 3132 | # check for sizeof(&) |
3127 | if ($line =~ /\bsizeof\s*\(\s*\&/) { | 3133 | if ($line =~ /\bsizeof\s*\(\s*\&/) { |
3128 | WARN("SIZEOF_ADDRESS", | 3134 | WARN("SIZEOF_ADDRESS", |