perf tools: Replace error() with pr_err()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 27 Jun 2017 14:22:31 +0000 (11:22 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 27 Jun 2017 14:22:31 +0000 (11:22 -0300)
To consolidate the error reporting facility.

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-b41iot1094katoffdf19w9zk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-c2c.c
tools/perf/builtin-help.c
tools/perf/builtin-kmem.c
tools/perf/builtin-record.c
tools/perf/builtin-sched.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/util/config.c
tools/perf/util/sort.c
tools/perf/util/usage.c
tools/perf/util/util.h

index 620a467ee3043c5cadfedd02c87c0195bb681413..475999e48f6699dd3e61619351f656b23ba659b5 100644 (file)
@@ -1725,10 +1725,10 @@ static int c2c_hists__init_sort(struct perf_hpp_list *hpp_list, char *name)
                                tok; tok = strtok_r(NULL, ", ", &tmp)) {        \
                        ret = _fn(hpp_list, tok);                               \
                        if (ret == -EINVAL) {                                   \
-                               error("Invalid --fields key: `%s'", tok);       \
+                               pr_err("Invalid --fields key: `%s'", tok);      \
                                break;                                          \
                        } else if (ret == -ESRCH) {                             \
-                               error("Unknown --fields key: `%s'", tok);       \
+                               pr_err("Unknown --fields key: `%s'", tok);      \
                                break;                                          \
                        }                                                       \
                }                                                               \
index 64a10101fc71e07fa69d093d8803a3be165233cf..530a7f2fa0f3e5326e9d7ea5886f97411046417f 100644 (file)
@@ -245,8 +245,10 @@ static int add_man_viewer_info(const char *var, const char *value)
        const char *name = var + 4;
        const char *subkey = strrchr(name, '.');
 
-       if (!subkey)
-               return error("Config with no key for man viewer: %s", name);
+       if (!subkey) {
+               pr_err("Config with no key for man viewer: %s", name);
+               return -1;
+       }
 
        if (!strcmp(subkey, ".path")) {
                if (!value)
@@ -330,7 +332,7 @@ static void setup_man_path(void)
                setenv("MANPATH", new_path, 1);
                free(new_path);
        } else {
-               error("Unable to setup man path");
+               pr_err("Unable to setup man path");
        }
 }
 
index 9409c9464667023c60841e3fb4e7a2364bc23167..0a8a1c45af87dc32ddaec90a29dcad3d3ecaec14 100644 (file)
@@ -1715,7 +1715,7 @@ static int setup_slab_sorting(struct list_head *sort_list, const char *arg)
                if (!tok)
                        break;
                if (slab_sort_dimension__add(tok, sort_list) < 0) {
-                       error("Unknown slab --sort key: '%s'", tok);
+                       pr_err("Unknown slab --sort key: '%s'", tok);
                        free(str);
                        return -1;
                }
@@ -1741,7 +1741,7 @@ static int setup_page_sorting(struct list_head *sort_list, const char *arg)
                if (!tok)
                        break;
                if (page_sort_dimension__add(tok, sort_list) < 0) {
-                       error("Unknown page --sort key: '%s'", tok);
+                       pr_err("Unknown page --sort key: '%s'", tok);
                        free(str);
                        return -1;
                }
index ee7d0a82ccd073cb52a49cea6b15e14d827436ad..17a14bcce34accf2ce1cf9a466cee97cf8b72b36 100644 (file)
@@ -453,7 +453,7 @@ try_again:
        }
 
        if (perf_evlist__apply_filters(evlist, &pos)) {
-               error("failed to set filter \"%s\" on event %s with %d (%s)\n",
+               pr_err("failed to set filter \"%s\" on event %s with %d (%s)\n",
                        pos->filter, perf_evsel__name(pos), errno,
                        str_error_r(errno, msg, sizeof(msg)));
                rc = -1;
@@ -461,7 +461,7 @@ try_again:
        }
 
        if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) {
-               error("failed to set config \"%s\" on event %s with %d (%s)\n",
+               pr_err("failed to set config \"%s\" on event %s with %d (%s)\n",
                      err_term->val.drv_cfg, perf_evsel__name(pos), errno,
                      str_error_r(errno, msg, sizeof(msg)));
                rc = -1;
index 39996c53995a2f57b982536a09b420020cd9e256..322b4def8411f8aa9d50e1fd9f015a09eeaee968 100644 (file)
@@ -2066,7 +2066,7 @@ static void save_task_callchain(struct perf_sched *sched,
        if (thread__resolve_callchain(thread, cursor, evsel, sample,
                                      NULL, NULL, sched->max_stack + 2) != 0) {
                if (verbose > 0)
-                       error("Failed to resolve callchain. Skipping\n");
+                       pr_err("Failed to resolve callchain. Skipping\n");
 
                return;
        }
index 324363054c3fe1b8380acba5899d75473626a189..48ac53b199fcb978be4b72f2c585d92cbc238421 100644 (file)
@@ -636,14 +636,14 @@ try_again:
        }
 
        if (perf_evlist__apply_filters(evsel_list, &counter)) {
-               error("failed to set filter \"%s\" on event %s with %d (%s)\n",
+               pr_err("failed to set filter \"%s\" on event %s with %d (%s)\n",
                        counter->filter, perf_evsel__name(counter), errno,
                        str_error_r(errno, msg, sizeof(msg)));
                return -1;
        }
 
        if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) {
-               error("failed to set config \"%s\" on event %s with %d (%s)\n",
+               pr_err("failed to set config \"%s\" on event %s with %d (%s)\n",
                      err_term->val.drv_cfg, perf_evsel__name(counter), errno,
                      str_error_r(errno, msg, sizeof(msg)));
                return -1;
index 2bcfa46913c84a9e698d6b5fbc698daa61eaf7de..6052376634c058e735de5c398dd716b1317f48af 100644 (file)
@@ -958,7 +958,7 @@ static int __cmd_top(struct perf_top *top)
 
        ret = perf_evlist__apply_drv_configs(evlist, &pos, &err_term);
        if (ret) {
-               error("failed to set config \"%s\" on event %s with %d (%s)\n",
+               pr_err("failed to set config \"%s\" on event %s with %d (%s)\n",
                        err_term->val.drv_cfg, perf_evsel__name(pos), errno,
                        str_error_r(errno, msg, sizeof(msg)));
                goto out_delete;
index 1498f38ea7ad561036f788d351b9ecacf018a770..586afeab2352fc8db39909c3ee522e5146a40635 100644 (file)
@@ -793,7 +793,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)
index 5762ae4e9e912e30dc158ee293c503373d80cc1f..8b327c955a4f274a214c6c3449248046507b78ce 100644 (file)
@@ -2532,12 +2532,12 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str,
                        ret = sort_dimension__add(list, tok, evlist, level);
                        if (ret == -EINVAL) {
                                if (!cacheline_size && !strncasecmp(tok, "dcacheline", strlen(tok)))
-                                       error("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system");
+                                       pr_err("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be determined on this system");
                                else
-                                       error("Invalid --sort key: `%s'", tok);
+                                       pr_err("Invalid --sort key: `%s'", tok);
                                break;
                        } else if (ret == -ESRCH) {
-                               error("Unknown --sort key: `%s'", tok);
+                               pr_err("Unknown --sort key: `%s'", tok);
                                break;
                        }
                }
@@ -2594,7 +2594,7 @@ static int setup_sort_order(struct perf_evlist *evlist)
                return 0;
 
        if (sort_order[1] == '\0') {
-               error("Invalid --sort key: `+'");
+               pr_err("Invalid --sort key: `+'");
                return -EINVAL;
        }
 
@@ -2604,7 +2604,7 @@ static int setup_sort_order(struct perf_evlist *evlist)
         */
        if (asprintf(&new_sort_order, "%s,%s",
                     get_default_sort_order(evlist), sort_order + 1) < 0) {
-               error("Not enough memory to set up --sort");
+               pr_err("Not enough memory to set up --sort");
                return -ENOMEM;
        }
 
@@ -2668,7 +2668,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
 
        str = strdup(sort_keys);
        if (str == NULL) {
-               error("Not enough memory to setup sort keys");
+               pr_err("Not enough memory to setup sort keys");
                return -ENOMEM;
        }
 
@@ -2678,7 +2678,7 @@ static int __setup_sorting(struct perf_evlist *evlist)
        if (!is_strict_order(field_order)) {
                str = setup_overhead(str);
                if (str == NULL) {
-                       error("Not enough memory to setup overhead keys");
+                       pr_err("Not enough memory to setup overhead keys");
                        return -ENOMEM;
                }
        }
@@ -2834,10 +2834,10 @@ static int setup_output_list(struct perf_hpp_list *list, char *str)
                        tok; tok = strtok_r(NULL, ", ", &tmp)) {
                ret = output_field_add(list, tok);
                if (ret == -EINVAL) {
-                       error("Invalid --fields key: `%s'", tok);
+                       pr_err("Invalid --fields key: `%s'", tok);
                        break;
                } else if (ret == -ESRCH) {
-                       error("Unknown --fields key: `%s'", tok);
+                       pr_err("Unknown --fields key: `%s'", tok);
                        break;
                }
        }
@@ -2877,7 +2877,7 @@ static int __setup_output_field(void)
 
        strp = str = strdup(field_order);
        if (str == NULL) {
-               error("Not enough memory to setup output fields");
+               pr_err("Not enough memory to setup output fields");
                return -ENOMEM;
        }
 
@@ -2885,7 +2885,7 @@ static int __setup_output_field(void)
                strp++;
 
        if (!strlen(strp)) {
-               error("Invalid --fields key: `+'");
+               pr_err("Invalid --fields key: `+'");
                goto out;
        }
 
index 37225dc727380a07d040d7193c6017a05ff2d103..bf185f28b19eafc2367b19598e81f89ba218d20b 100644 (file)
@@ -28,15 +28,9 @@ static __noreturn void die_builtin(const char *err, va_list params)
        exit(128);
 }
 
-static void error_builtin(const char *err, va_list params)
-{
-       report(" Error: ", err, params);
-}
-
 /* If we are in a dlopen()ed .so write to a global variable would segfault
  * (ugh), so keep things static. */
 static void (*usage_routine)(const char *err) __noreturn = usage_builtin;
-static void (*error_routine)(const char *err, va_list params) = error_builtin;
 
 void usage(const char *err)
 {
@@ -51,13 +45,3 @@ void die(const char *err, ...)
        die_builtin(err, params);
        va_end(params);
 }
-
-int error(const char *err, ...)
-{
-       va_list params;
-
-       va_start(params, err);
-       error_routine(err, params);
-       va_end(params);
-       return -1;
-}
index 3927ab8df5ac94ba7fe9fe8c040a1153b83b5bce..2c9e58a45310446eeb5b1af2859b8ef70e2d8089 100644 (file)
@@ -16,7 +16,6 @@
 /* General helper functions */
 void usage(const char *err) __noreturn;
 void die(const char *err, ...) __noreturn __printf(1, 2);
-int error(const char *err, ...) __printf(1, 2);
 
 static inline void *zalloc(size_t size)
 {