]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - tools/perf/util/config.c
Merge tag 'hsi-for-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi
[karo-tx-linux.git] / tools / perf / util / config.c
index 1498f38ea7ad561036f788d351b9ecacf018a770..31a7dea248d03323ce238281dd54d5554eb62520 100644 (file)
@@ -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)
@@ -793,7 +803,8 @@ void perf_config_set__delete(struct perf_config_set *set)
  */
 int config_error_nonbool(const char *var)
 {
-       return error("Missing value for '%s'", var);
+       pr_err("Missing value for '%s'", var);
+       return -1;
 }
 
 void set_buildid_dir(const char *dir)