perf tools: Consolidate --control option parsing into one function
Consolidate --control option parsing into one function, in preparation for adding FIFO file name options. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Alexey Budankov <alexey.budankov@linux.intel.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lore.kernel.org/lkml/20200901093758.32293-2-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
ed21d6d7c4
commit
9864a66def
@@ -1045,27 +1045,9 @@ static int parse_control_option(const struct option *opt,
|
||||
const char *str,
|
||||
int unset __maybe_unused)
|
||||
{
|
||||
char *comma = NULL, *endptr = NULL;
|
||||
struct perf_stat_config *config = (struct perf_stat_config *)opt->value;
|
||||
struct perf_stat_config *config = opt->value;
|
||||
|
||||
if (strncmp(str, "fd:", 3))
|
||||
return -EINVAL;
|
||||
|
||||
config->ctl_fd = strtoul(&str[3], &endptr, 0);
|
||||
if (endptr == &str[3])
|
||||
return -EINVAL;
|
||||
|
||||
comma = strchr(str, ',');
|
||||
if (comma) {
|
||||
if (endptr != comma)
|
||||
return -EINVAL;
|
||||
|
||||
config->ctl_fd_ack = strtoul(comma + 1, &endptr, 0);
|
||||
if (endptr == comma + 1 || *endptr != '\0')
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return evlist__parse_control(str, &config->ctl_fd, &config->ctl_fd_ack);
|
||||
}
|
||||
|
||||
static struct option stat_options[] = {
|
||||
|
Reference in New Issue
Block a user