aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/cloexec.c6
-rw-r--r--tools/perf/util/data.c8
-rw-r--r--tools/perf/util/dso.c8
-rw-r--r--tools/perf/util/evlist.c2
-rw-r--r--tools/perf/util/evsel.c7
-rw-r--r--tools/perf/util/parse-events.c5
-rw-r--r--tools/perf/util/run-command.c9
-rw-r--r--tools/perf/util/util.c5
8 files changed, 36 insertions, 14 deletions
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index 4945aa56a017..47b78b3f0325 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -3,6 +3,7 @@
3#include "../perf.h" 3#include "../perf.h"
4#include "cloexec.h" 4#include "cloexec.h"
5#include "asm/bug.h" 5#include "asm/bug.h"
6#include "debug.h"
6 7
7static unsigned long flag = PERF_FLAG_FD_CLOEXEC; 8static unsigned long flag = PERF_FLAG_FD_CLOEXEC;
8 9
@@ -18,6 +19,7 @@ static int perf_flag_probe(void)
18 int err; 19 int err;
19 int cpu; 20 int cpu;
20 pid_t pid = -1; 21 pid_t pid = -1;
22 char sbuf[STRERR_BUFSIZE];
21 23
22 cpu = sched_getcpu(); 24 cpu = sched_getcpu();
23 if (cpu < 0) 25 if (cpu < 0)
@@ -42,7 +44,7 @@ static int perf_flag_probe(void)
42 44
43 WARN_ONCE(err != EINVAL && err != EBUSY, 45 WARN_ONCE(err != EINVAL && err != EBUSY,
44 "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n", 46 "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n",
45 err, strerror(err)); 47 err, strerror_r(err, sbuf, sizeof(sbuf)));
46 48
47 /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ 49 /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */
48 fd = sys_perf_event_open(&attr, pid, cpu, -1, 0); 50 fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
@@ -50,7 +52,7 @@ static int perf_flag_probe(void)
50 52
51 if (WARN_ONCE(fd < 0 && err != EBUSY, 53 if (WARN_ONCE(fd < 0 && err != EBUSY,
52 "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n", 54 "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n",
53 err, strerror(err))) 55 err, strerror_r(err, sbuf, sizeof(sbuf))))
54 return -1; 56 return -1;
55 57
56 close(fd); 58 close(fd);
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 29d720cf5844..1921942fc2e0 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -50,12 +50,14 @@ static int open_file_read(struct perf_data_file *file)
50{ 50{
51 struct stat st; 51 struct stat st;
52 int fd; 52 int fd;
53 char sbuf[STRERR_BUFSIZE];
53 54
54 fd = open(file->path, O_RDONLY); 55 fd = open(file->path, O_RDONLY);
55 if (fd < 0) { 56 if (fd < 0) {
56 int err = errno; 57 int err = errno;
57 58
58 pr_err("failed to open %s: %s", file->path, strerror(err)); 59 pr_err("failed to open %s: %s", file->path,
60 strerror_r(err, sbuf, sizeof(sbuf)));
59 if (err == ENOENT && !strcmp(file->path, "perf.data")) 61 if (err == ENOENT && !strcmp(file->path, "perf.data"))
60 pr_err(" (try 'perf record' first)"); 62 pr_err(" (try 'perf record' first)");
61 pr_err("\n"); 63 pr_err("\n");
@@ -88,6 +90,7 @@ static int open_file_read(struct perf_data_file *file)
88static int open_file_write(struct perf_data_file *file) 90static int open_file_write(struct perf_data_file *file)
89{ 91{
90 int fd; 92 int fd;
93 char sbuf[STRERR_BUFSIZE];
91 94
92 if (check_backup(file)) 95 if (check_backup(file))
93 return -1; 96 return -1;
@@ -95,7 +98,8 @@ static int open_file_write(struct perf_data_file *file)
95 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); 98 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
96 99
97 if (fd < 0) 100 if (fd < 0)
98 pr_err("failed to open %s : %s\n", file->path, strerror(errno)); 101 pr_err("failed to open %s : %s\n", file->path,
102 strerror_r(errno, sbuf, sizeof(sbuf)));
99 103
100 return fd; 104 return fd;
101} 105}
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index bdafd306fb52..55e39dc1bcda 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -162,13 +162,15 @@ static void close_first_dso(void);
162static int do_open(char *name) 162static int do_open(char *name)
163{ 163{
164 int fd; 164 int fd;
165 char sbuf[STRERR_BUFSIZE];
165 166
166 do { 167 do {
167 fd = open(name, O_RDONLY); 168 fd = open(name, O_RDONLY);
168 if (fd >= 0) 169 if (fd >= 0)
169 return fd; 170 return fd;
170 171
171 pr_debug("dso open failed, mmap: %s\n", strerror(errno)); 172 pr_debug("dso open failed, mmap: %s\n",
173 strerror_r(errno, sbuf, sizeof(sbuf)));
172 if (!dso__data_open_cnt || errno != EMFILE) 174 if (!dso__data_open_cnt || errno != EMFILE)
173 break; 175 break;
174 176
@@ -530,10 +532,12 @@ static ssize_t cached_read(struct dso *dso, u64 offset, u8 *data, ssize_t size)
530static int data_file_size(struct dso *dso) 532static int data_file_size(struct dso *dso)
531{ 533{
532 struct stat st; 534 struct stat st;
535 char sbuf[STRERR_BUFSIZE];
533 536
534 if (!dso->data.file_size) { 537 if (!dso->data.file_size) {
535 if (fstat(dso->data.fd, &st)) { 538 if (fstat(dso->data.fd, &st)) {
536 pr_err("dso mmap failed, fstat: %s\n", strerror(errno)); 539 pr_err("dso mmap failed, fstat: %s\n",
540 strerror_r(errno, sbuf, sizeof(sbuf)));
537 return -1; 541 return -1;
538 } 542 }
539 dso->data.file_size = st.st_size; 543 dso->data.file_size = st.st_size;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 5dcd28c79c6e..a3e28b49128a 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1295,7 +1295,7 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
1295 int err, char *buf, size_t size) 1295 int err, char *buf, size_t size)
1296{ 1296{
1297 int printed, value; 1297 int printed, value;
1298 char sbuf[128], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); 1298 char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf));
1299 1299
1300 switch (err) { 1300 switch (err) {
1301 case EACCES: 1301 case EACCES:
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 01ce14c3575e..b38de5819323 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2027,6 +2027,8 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
2027int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, 2027int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
2028 int err, char *msg, size_t size) 2028 int err, char *msg, size_t size)
2029{ 2029{
2030 char sbuf[STRERR_BUFSIZE];
2031
2030 switch (err) { 2032 switch (err) {
2031 case EPERM: 2033 case EPERM:
2032 case EACCES: 2034 case EACCES:
@@ -2072,8 +2074,9 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
2072 } 2074 }
2073 2075
2074 return scnprintf(msg, size, 2076 return scnprintf(msg, size,
2075 "The sys_perf_event_open() syscall returned with %d (%s) for event (%s). \n" 2077 "The sys_perf_event_open() syscall returned with %d (%s) for event (%s).\n"
2076 "/bin/dmesg may provide additional information.\n" 2078 "/bin/dmesg may provide additional information.\n"
2077 "No CONFIG_PERF_EVENTS=y kernel support configured?\n", 2079 "No CONFIG_PERF_EVENTS=y kernel support configured?\n",
2078 err, strerror(err), perf_evsel__name(evsel)); 2080 err, strerror_r(err, sbuf, sizeof(sbuf)),
2081 perf_evsel__name(evsel));
2079} 2082}
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1e15df10a88c..e34c81a0bcf3 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -10,6 +10,7 @@
10#include "symbol.h" 10#include "symbol.h"
11#include "cache.h" 11#include "cache.h"
12#include "header.h" 12#include "header.h"
13#include "debug.h"
13#include <api/fs/debugfs.h> 14#include <api/fs/debugfs.h>
14#include "parse-events-bison.h" 15#include "parse-events-bison.h"
15#define YY_EXTRA_TYPE int 16#define YY_EXTRA_TYPE int
@@ -1006,9 +1007,11 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
1006 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1007 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
1007 char evt_path[MAXPATHLEN]; 1008 char evt_path[MAXPATHLEN];
1008 char dir_path[MAXPATHLEN]; 1009 char dir_path[MAXPATHLEN];
1010 char sbuf[STRERR_BUFSIZE];
1009 1011
1010 if (debugfs_valid_mountpoint(tracing_events_path)) { 1012 if (debugfs_valid_mountpoint(tracing_events_path)) {
1011 printf(" [ Tracepoints not available: %s ]\n", strerror(errno)); 1013 printf(" [ Tracepoints not available: %s ]\n",
1014 strerror_r(errno, sbuf, sizeof(sbuf)));
1012 return; 1015 return;
1013 } 1016 }
1014 1017
diff --git a/tools/perf/util/run-command.c b/tools/perf/util/run-command.c
index da8e9b285f51..34622b53e733 100644
--- a/tools/perf/util/run-command.c
+++ b/tools/perf/util/run-command.c
@@ -1,6 +1,7 @@
1#include "cache.h" 1#include "cache.h"
2#include "run-command.h" 2#include "run-command.h"
3#include "exec_cmd.h" 3#include "exec_cmd.h"
4#include "debug.h"
4 5
5static inline void close_pair(int fd[2]) 6static inline void close_pair(int fd[2])
6{ 7{
@@ -19,6 +20,7 @@ int start_command(struct child_process *cmd)
19{ 20{
20 int need_in, need_out, need_err; 21 int need_in, need_out, need_err;
21 int fdin[2], fdout[2], fderr[2]; 22 int fdin[2], fdout[2], fderr[2];
23 char sbuf[STRERR_BUFSIZE];
22 24
23 /* 25 /*
24 * In case of errors we must keep the promise to close FDs 26 * In case of errors we must keep the promise to close FDs
@@ -99,7 +101,7 @@ int start_command(struct child_process *cmd)
99 101
100 if (cmd->dir && chdir(cmd->dir)) 102 if (cmd->dir && chdir(cmd->dir))
101 die("exec %s: cd to %s failed (%s)", cmd->argv[0], 103 die("exec %s: cd to %s failed (%s)", cmd->argv[0],
102 cmd->dir, strerror(errno)); 104 cmd->dir, strerror_r(errno, sbuf, sizeof(sbuf)));
103 if (cmd->env) { 105 if (cmd->env) {
104 for (; *cmd->env; cmd->env++) { 106 for (; *cmd->env; cmd->env++) {
105 if (strchr(*cmd->env, '=')) 107 if (strchr(*cmd->env, '='))
@@ -153,6 +155,8 @@ int start_command(struct child_process *cmd)
153 155
154static int wait_or_whine(pid_t pid) 156static int wait_or_whine(pid_t pid)
155{ 157{
158 char sbuf[STRERR_BUFSIZE];
159
156 for (;;) { 160 for (;;) {
157 int status, code; 161 int status, code;
158 pid_t waiting = waitpid(pid, &status, 0); 162 pid_t waiting = waitpid(pid, &status, 0);
@@ -160,7 +164,8 @@ static int wait_or_whine(pid_t pid)
160 if (waiting < 0) { 164 if (waiting < 0) {
161 if (errno == EINTR) 165 if (errno == EINTR)
162 continue; 166 continue;
163 error("waitpid failed (%s)", strerror(errno)); 167 error("waitpid failed (%s)",
168 strerror_r(errno, sbuf, sizeof(sbuf)));
164 return -ERR_RUN_COMMAND_WAITPID; 169 return -ERR_RUN_COMMAND_WAITPID;
165 } 170 }
166 if (waiting != pid) 171 if (waiting != pid)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 25822bdf7bbf..24e8d871b74e 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -456,6 +456,7 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep)
456 size_t size = 0, alloc_size = 0; 456 size_t size = 0, alloc_size = 0;
457 void *bf = NULL, *nbf; 457 void *bf = NULL, *nbf;
458 int fd, n, err = 0; 458 int fd, n, err = 0;
459 char sbuf[STRERR_BUFSIZE];
459 460
460 fd = open(filename, O_RDONLY); 461 fd = open(filename, O_RDONLY);
461 if (fd < 0) 462 if (fd < 0)
@@ -476,8 +477,8 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep)
476 n = read(fd, bf + size, alloc_size - size); 477 n = read(fd, bf + size, alloc_size - size);
477 if (n < 0) { 478 if (n < 0) {
478 if (size) { 479 if (size) {
479 pr_warning("read failed %d: %s\n", 480 pr_warning("read failed %d: %s\n", errno,
480 errno, strerror(errno)); 481 strerror_r(errno, sbuf, sizeof(sbuf)));
481 err = 0; 482 err = 0;
482 } else 483 } else
483 err = -errno; 484 err = -errno;