The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 7b43b6970474757da68e89efb76e892219dea9d8 Gitweb: https://git.kernel.org/tip/7b43b6970474757da68e89efb76e892219dea9d8 Author: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx> AuthorDate: Thu, 13 Feb 2020 12:13:02 +05:30 Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> CommitterDate: Thu, 27 Feb 2020 10:44:54 -03:00 perf config: Introduce perf_config_u8() Introduce perf_config_u8() utility function to convert char * input into u8 destination. We will utilize it in followup patch. Signed-off-by: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> Cc: Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx> Cc: Changbin Du <changbin.du@xxxxxxxxx> Cc: Ian Rogers <irogers@xxxxxxxxxx> Cc: Jin Yao <yao.jin@xxxxxxxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: Leo Yan <leo.yan@xxxxxxxxxx> Cc: Namhyung Kim <namhyung@xxxxxxxxxx> Cc: Song Liu <songliubraving@xxxxxx> Cc: Taeung Song <treeze.taeung@xxxxxxxxx> Cc: Thomas Richter <tmricht@xxxxxxxxxxxxx> Cc: Yisheng Xie <xieyisheng1@xxxxxxxxxx> Link: http://lore.kernel.org/lkml/20200213064306.160480-5-ravi.bangoria@xxxxxxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> --- tools/perf/util/config.c | 12 ++++++++++++ tools/perf/util/config.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 0bc9c4d..ef38eba 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -374,6 +374,18 @@ int perf_config_int(int *dest, const char *name, const char *value) return 0; } +int perf_config_u8(u8 *dest, const char *name, const char *value) +{ + long ret = 0; + + if (!perf_parse_long(value, &ret)) { + bad_config(name); + return -1; + } + *dest = ret; + return 0; +} + static int perf_config_bool_or_int(const char *name, const char *value, int *is_bool) { int ret; diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h index bd0a589..c10b66d 100644 --- a/tools/perf/util/config.h +++ b/tools/perf/util/config.h @@ -29,6 +29,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *); int perf_default_config(const char *, const char *, void *); int perf_config(config_fn_t fn, void *); int perf_config_int(int *dest, const char *, const char *); +int perf_config_u8(u8 *dest, const char *name, const char *value); int perf_config_u64(u64 *dest, const char *, const char *); int perf_config_bool(const char *, const char *); int config_error_nonbool(const char *);