mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
tools lib subcmd: Make it an error to pass a signed value to OPTION_UINTEGER
Options marked OPTION_UINTEGER or OPTION_U64 clearly indicates that an
unsigned value is expected, so just error out when a negative value is
passed, instead of returning something undesired to the tool.
E.g.:
# 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
#
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
49b3cd306e
commit
b988971662
1 changed files with 4 additions and 0 deletions
|
|
@ -270,6 +270,8 @@ static int get_value(struct parse_opt_ctx_t *p,
|
|||
}
|
||||
if (get_arg(p, opt, flags, &arg))
|
||||
return -1;
|
||||
if (arg[0] == '-')
|
||||
return opterror(opt, "expects an unsigned numerical value", flags);
|
||||
*(unsigned int *)opt->value = strtol(arg, (char **)&s, 10);
|
||||
if (*s)
|
||||
return opterror(opt, "expects a numerical value", flags);
|
||||
|
|
@ -302,6 +304,8 @@ static int get_value(struct parse_opt_ctx_t *p,
|
|||
}
|
||||
if (get_arg(p, opt, flags, &arg))
|
||||
return -1;
|
||||
if (arg[0] == '-')
|
||||
return opterror(opt, "expects an unsigned numerical value", flags);
|
||||
*(u64 *)opt->value = strtoull(arg, (char **)&s, 10);
|
||||
if (*s)
|
||||
return opterror(opt, "expects a numerical value", flags);
|
||||
|
|
|
|||
Loading…
Reference in a new issue