forked from Minki/linux
perf config: Do not die when parsing u64 or int config values
Just warn the user and ignore those values. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-tbf60nj3ierm6hrkhpothymx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
62d94b00f8
commit
25ce4bb8c5
@ -1302,7 +1302,10 @@ static int diff__config(const char *var, const char *value,
|
||||
void *cb __maybe_unused)
|
||||
{
|
||||
if (!strcmp(var, "diff.order")) {
|
||||
sort_compute = perf_config_int(var, value);
|
||||
int ret;
|
||||
if (perf_config_int(&ret, var, value) < 0)
|
||||
return -1;
|
||||
sort_compute = ret;
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "diff.compute")) {
|
||||
|
@ -94,10 +94,9 @@ static int report__config(const char *var, const char *value, void *cb)
|
||||
symbol_conf.cumulate_callchain = perf_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "report.queue-size")) {
|
||||
rep->queue_size = perf_config_u64(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "report.queue-size"))
|
||||
return perf_config_u64(&rep->queue_size, var, value);
|
||||
|
||||
if (!strcmp(var, "report.sort_order")) {
|
||||
default_sort_order = strdup(value);
|
||||
return 0;
|
||||
|
@ -335,32 +335,42 @@ static int perf_parse_long(const char *value, long *ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void die_bad_config(const char *name)
|
||||
static void bad_config(const char *name)
|
||||
{
|
||||
if (config_file_name)
|
||||
die("bad config value for '%s' in %s", name, config_file_name);
|
||||
die("bad config value for '%s'", name);
|
||||
pr_warning("bad config value for '%s' in %s, ignoring...\n", name, config_file_name);
|
||||
else
|
||||
pr_warning("bad config value for '%s', ignoring...\n", name);
|
||||
}
|
||||
|
||||
u64 perf_config_u64(const char *name, const char *value)
|
||||
int perf_config_u64(u64 *dest, const char *name, const char *value)
|
||||
{
|
||||
long long ret = 0;
|
||||
|
||||
if (!perf_parse_llong(value, &ret))
|
||||
die_bad_config(name);
|
||||
return (u64) ret;
|
||||
if (!perf_parse_llong(value, &ret)) {
|
||||
bad_config(name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*dest = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int perf_config_int(const char *name, const char *value)
|
||||
int perf_config_int(int *dest, const char *name, const char *value)
|
||||
{
|
||||
long ret = 0;
|
||||
if (!perf_parse_long(value, &ret))
|
||||
die_bad_config(name);
|
||||
return ret;
|
||||
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;
|
||||
|
||||
*is_bool = 1;
|
||||
if (!value)
|
||||
return 1;
|
||||
@ -371,7 +381,7 @@ static int perf_config_bool_or_int(const char *name, const char *value, int *is_
|
||||
if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "off"))
|
||||
return 0;
|
||||
*is_bool = 0;
|
||||
return perf_config_int(name, value);
|
||||
return perf_config_int(&ret, name, value) < 0 ? -1 : ret;
|
||||
}
|
||||
|
||||
int perf_config_bool(const char *name, const char *value)
|
||||
|
@ -27,8 +27,8 @@ extern const char *config_exclusive_filename;
|
||||
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(const char *, const char *);
|
||||
u64 perf_config_u64(const char *, const char *);
|
||||
int perf_config_int(int *dest, const char *, const char *);
|
||||
int perf_config_u64(u64 *dest, const char *, const char *);
|
||||
int perf_config_bool(const char *, const char *);
|
||||
int config_error_nonbool(const char *);
|
||||
const char *perf_etc_perfconfig(void);
|
||||
|
@ -1444,10 +1444,8 @@ static int convert__config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
struct convert *c = cb;
|
||||
|
||||
if (!strcmp(var, "convert.queue-size")) {
|
||||
c->queue_size = perf_config_u64(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "convert.queue-size"))
|
||||
return perf_config_u64(&c->queue_size, var, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ static int perf_unknown_cmd_config(const char *var, const char *value,
|
||||
void *cb __maybe_unused)
|
||||
{
|
||||
if (!strcmp(var, "help.autocorrect"))
|
||||
autocorrect = perf_config_int(var,value);
|
||||
return perf_config_int(&autocorrect, var,value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user