aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-options.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/parse-options.c')
-rw-r--r--tools/perf/util/parse-options.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index b05d51df2ce7..36d955e49422 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -59,6 +59,7 @@ static int get_value(struct parse_opt_ctx_t *p,
59 case OPTION_GROUP: 59 case OPTION_GROUP:
60 case OPTION_STRING: 60 case OPTION_STRING:
61 case OPTION_INTEGER: 61 case OPTION_INTEGER:
62 case OPTION_UINTEGER:
62 case OPTION_LONG: 63 case OPTION_LONG:
63 case OPTION_U64: 64 case OPTION_U64:
64 default: 65 default:
@@ -126,6 +127,22 @@ static int get_value(struct parse_opt_ctx_t *p,
126 return opterror(opt, "expects a numerical value", flags); 127 return opterror(opt, "expects a numerical value", flags);
127 return 0; 128 return 0;
128 129
130 case OPTION_UINTEGER:
131 if (unset) {
132 *(unsigned int *)opt->value = 0;
133 return 0;
134 }
135 if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
136 *(unsigned int *)opt->value = opt->defval;
137 return 0;
138 }
139 if (get_arg(p, opt, flags, &arg))
140 return -1;
141 *(unsigned int *)opt->value = strtol(arg, (char **)&s, 10);
142 if (*s)
143 return opterror(opt, "expects a numerical value", flags);
144 return 0;
145
129 case OPTION_LONG: 146 case OPTION_LONG:
130 if (unset) { 147 if (unset) {
131 *(long *)opt->value = 0; 148 *(long *)opt->value = 0;
@@ -463,7 +480,10 @@ int usage_with_options_internal(const char * const *usagestr,
463 switch (opts->type) { 480 switch (opts->type) {
464 case OPTION_ARGUMENT: 481 case OPTION_ARGUMENT:
465 break; 482 break;
483 case OPTION_LONG:
484 case OPTION_U64:
466 case OPTION_INTEGER: 485 case OPTION_INTEGER:
486 case OPTION_UINTEGER:
467 if (opts->flags & PARSE_OPT_OPTARG) 487 if (opts->flags & PARSE_OPT_OPTARG)
468 if (opts->long_name) 488 if (opts->long_name)
469 pos += fprintf(stderr, "[=<n>]"); 489 pos += fprintf(stderr, "[=<n>]");
@@ -503,8 +523,6 @@ int usage_with_options_internal(const char * const *usagestr,
503 case OPTION_INCR: 523 case OPTION_INCR:
504 case OPTION_SET_INT: 524 case OPTION_SET_INT:
505 case OPTION_SET_PTR: 525 case OPTION_SET_PTR:
506 case OPTION_LONG:
507 case OPTION_U64:
508 break; 526 break;
509 } 527 }
510 528