perf config: Check error cases of {show_spec, set}_config()
authorTaeung Song <[email protected]>
Sat, 17 Jun 2017 03:46:37 +0000 (12:46 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Tue, 20 Jun 2017 01:05:54 +0000 (22:05 -0300)
show_spec_config() and set_config() can be called multiple times
in the loop in cmd_config().

However, The error cases of them wasn't checked, so fix it.

Reported-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Taeung Song <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-config.c

index 75459668edb248b1d86bfc04082174d6aeae95e4..bb1be79bceda5978680cf63b0c41ed86aaafea94 100644 (file)
@@ -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);
                }
        }