]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - tools/perf/perf.c
tools: Introduce str_error_r()
[mirror_ubuntu-hirsute-kernel.git] / tools / perf / perf.c
index 15982cee5ef3f3b85b51f470777df5a2ac5ee3d1..f7d7dbbd2af670669ff89e6ab6a3c19f91d0bcb4 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "util/env.h"
 #include <subcmd/exec-cmd.h>
-#include "util/cache.h"
+#include "util/config.h"
 #include "util/quote.h"
 #include <subcmd/run-command.h>
 #include "util/parse-events.h"
@@ -139,8 +139,6 @@ struct option options[] = {
        OPT_ARGUMENT("html-path", "html-path"),
        OPT_ARGUMENT("paginate", "paginate"),
        OPT_ARGUMENT("no-pager", "no-pager"),
-       OPT_ARGUMENT("perf-dir", "perf-dir"),
-       OPT_ARGUMENT("work-tree", "work-tree"),
        OPT_ARGUMENT("debugfs-dir", "debugfs-dir"),
        OPT_ARGUMENT("buildid-dir", "buildid-dir"),
        OPT_ARGUMENT("list-cmds", "list-cmds"),
@@ -200,35 +198,6 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                        use_pager = 0;
                        if (envchanged)
                                *envchanged = 1;
-               } else if (!strcmp(cmd, "--perf-dir")) {
-                       if (*argc < 2) {
-                               fprintf(stderr, "No directory given for --perf-dir.\n");
-                               usage(perf_usage_string);
-                       }
-                       setenv(PERF_DIR_ENVIRONMENT, (*argv)[1], 1);
-                       if (envchanged)
-                               *envchanged = 1;
-                       (*argv)++;
-                       (*argc)--;
-                       handled++;
-               } else if (!prefixcmp(cmd, CMD_PERF_DIR)) {
-                       setenv(PERF_DIR_ENVIRONMENT, cmd + strlen(CMD_PERF_DIR), 1);
-                       if (envchanged)
-                               *envchanged = 1;
-               } else if (!strcmp(cmd, "--work-tree")) {
-                       if (*argc < 2) {
-                               fprintf(stderr, "No directory given for --work-tree.\n");
-                               usage(perf_usage_string);
-                       }
-                       setenv(PERF_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
-                       if (envchanged)
-                               *envchanged = 1;
-                       (*argv)++;
-                       (*argc)--;
-               } else if (!prefixcmp(cmd, CMD_WORK_TREE)) {
-                       setenv(PERF_WORK_TREE_ENVIRONMENT, cmd + strlen(CMD_WORK_TREE), 1);
-                       if (envchanged)
-                               *envchanged = 1;
                } else if (!strcmp(cmd, "--debugfs-dir")) {
                        if (*argc < 2) {
                                fprintf(stderr, "No directory given for --debugfs-dir.\n");
@@ -363,11 +332,6 @@ const char perf_version_string[] = PERF_VERSION;
 
 #define RUN_SETUP      (1<<0)
 #define USE_PAGER      (1<<1)
-/*
- * require working tree to be present -- anything uses this needs
- * RUN_SETUP for reading from the configuration file.
- */
-#define NEED_WORK_TREE (1<<2)
 
 static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 {
@@ -391,6 +355,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
        perf_env__set_cmdline(&perf_env, argc, argv);
        status = p->fn(argc, argv, prefix);
+       perf_config__exit();
        exit_browser(status);
        perf_env__exit(&perf_env);
        bpf__clear();
@@ -409,7 +374,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
        /* Check for ENOSPC and EIO errors.. */
        if (fflush(stdout)) {
                fprintf(stderr, "write failure on standard output: %s",
-                       strerror_r(errno, sbuf, sizeof(sbuf)));
+                       str_error_r(errno, sbuf, sizeof(sbuf)));
                goto out;
        }
        if (ferror(stdout)) {
@@ -418,7 +383,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
        }
        if (fclose(stdout)) {
                fprintf(stderr, "close failed on standard output: %s",
-                       strerror_r(errno, sbuf, sizeof(sbuf)));
+                       str_error_r(errno, sbuf, sizeof(sbuf)));
                goto out;
        }
        status = 0;
@@ -558,6 +523,7 @@ int main(int argc, const char **argv)
 
        srandom(time(NULL));
 
+       perf_config__init();
        perf_config(perf_default_config, NULL);
        set_buildid_dir(NULL);
 
@@ -649,7 +615,7 @@ int main(int argc, const char **argv)
        }
 
        fprintf(stderr, "Failed to run command '%s': %s\n",
-               cmd, strerror_r(errno, sbuf, sizeof(sbuf)));
+               cmd, str_error_r(errno, sbuf, sizeof(sbuf)));
 out:
        return 1;
 }