Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: Adopt __scanf from kernel sources

To have a more compact way to ask the compiler to perform scanf like
argument validation.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-yzqrhfjrn26lqqtwf55egg0h@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+3 -2
+1
tools/include/linux/compiler-gcc.h
··· 23 23 #define __noreturn __attribute__((noreturn)) 24 24 25 25 #define __printf(a, b) __attribute__((format(printf, a, b))) 26 + #define __scanf(a, b) __attribute__((format(scanf, a, b)))
+2 -2
tools/perf/util/pmu.h
··· 2 2 #define __PMU_H 3 3 4 4 #include <linux/bitmap.h> 5 + #include <linux/compiler.h> 5 6 #include <linux/perf_event.h> 6 7 #include <stdbool.h> 7 8 #include "evsel.h" ··· 84 83 bool long_desc, bool details_flag); 85 84 bool pmu_have_event(const char *pname, const char *name); 86 85 87 - int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, 88 - ...) __attribute__((format(scanf, 3, 4))); 86 + int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4); 89 87 90 88 int perf_pmu__test(void); 91 89