* [PATCH v3 1/7] perf config: Handle errors from {show_spec, set}_config() in the loop
@ 2017-05-09 11:04 Taeung Song
0 siblings, 0 replies; only message in thread
From: Taeung Song @ 2017-05-09 11:04 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Jiri Olsa, Namhyung Kim
show_spec_config() and set_config() can be called multiple times
in the loop in cmd_config(). However, the return values from them did not checked.
Even though one of the return values means a error (i.e. -1),
it can be just skipped. It is a bug, so fix it.
Check each return value from show_spec_config() and set_config()
in the loop in cmd_config() and if the return value means a error, handle it.
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/builtin-config.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 7545966..bb1be79 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -225,10 +225,23 @@ int cmd_config(int argc, const char **argv)
break;
}
- if (value == NULL)
+ if (value == NULL) {
ret = show_spec_config(set, var);
- else
+ if (ret < 0) {
+ pr_err("%s is not configured: %s\n",
+ var, config_filename);
+ free(arg);
+ break;
+ }
+ } else {
ret = set_config(set, config_filename, var, value);
+ if (ret < 0) {
+ pr_err("Failed to set '%s=%s' on %s\n",
+ var, value, config_filename);
+ free(arg);
+ break;
+ }
+ }
free(arg);
}
}
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-09 11:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 11:04 [PATCH v3 1/7] perf config: Handle errors from {show_spec, set}_config() in the loop Taeung Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®