diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-02-14 20:12:43 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-02-14 21:19:17 +0300 |
commit | 16cab3226fc91fd8060a3d15d1f27051a7b189fb (patch) | |
tree | aa8e8a5767c50544faf9f277dac5c4105e3d3cd9 /tools/perf/bench/futex.h | |
parent | b98897166280c4cfb9bc5a6c1b5682528eb4abff (diff) | |
download | linux-16cab3226fc91fd8060a3d15d1f27051a7b189fb.tar.xz |
Revert "perf bench futex: Sanitize numeric parameters"
This reverts commit 60758d6668b3e2fa8e5fd143d24d0425203d007e.
Now that libsubcmd makes sure that OPT_UINTEGER options will not
return negative values, we can revert this patch while addressing
the problem it solved:
# perf bench futex hash -t -4
# Running 'futex/hash' benchmark:
Error: switch `t' expects an unsigned numerical value
Usage: perf bench futex hash <options>
-t, --threads <n> Specify amount of threads
# perf bench futex hash -t-4
# Running 'futex/hash' benchmark:
Error: switch `t' expects an unsigned numerical value
Usage: perf bench futex hash <options>
-t, --threads <n> Specify amount of threads
#
IMO it is more reasonable to flat out refuse to process a negative
number than to silently turn it into an absolute value.
This also helps in silencing clang's complaint about asking for an
absolute value of an unsigned integer:
bench/futex-hash.c:133:10: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
nsecs = futexbench_sanitize_numeric(nsecs);
^
bench/futex.h:104:42: note: expanded from macro 'futexbench_sanitize_numeric'
#define futexbench_sanitize_numeric(__n) abs((__n))
^
bench/futex-hash.c:133:10: note: remove the call to 'abs' since unsigned values cannot be negative
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-2kl68v22or31vw643m2exz8x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/futex.h')
-rw-r--r-- | tools/perf/bench/futex.h | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h index ba7c735c0c62..b2e06d1190d0 100644 --- a/tools/perf/bench/futex.h +++ b/tools/perf/bench/futex.h @@ -7,7 +7,6 @@ #ifndef _FUTEX_H #define _FUTEX_H -#include <stdlib.h> #include <unistd.h> #include <sys/syscall.h> #include <sys/types.h> @@ -100,7 +99,4 @@ static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr, } #endif -/* User input sanitation */ -#define futexbench_sanitize_numeric(__n) abs((__n)) - #endif /* _FUTEX_H */ |