• Arnaldo Carvalho de Melo's avatar
    Revert "perf bench futex: Sanitize numeric parameters" · 16cab322
    Arnaldo Carvalho de Melo authored
    This reverts commit 60758d66.
    
    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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    16cab322
futex-requeue.c 5.75 KB