Skip to content

Commit 35550da

Browse files
mhiramathitachiacmel
authored andcommitted
perf record: Use strerror_r instead of strerror
Use strerror_r instead of strerror in error messages for thread-safety. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naohiro Aota <naota@elisp.net> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20140814022243.3545.7411.stgit@kbuild-fedora.novalocal Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 942a91e commit 35550da

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎tools/perf/builtin-record.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int record__open(struct record *rec)
161161

162162
if (perf_evlist__apply_filters(evlist)) {
163163
error("failed to set filter with %d (%s)\n", errno,
164-
strerror(errno));
164+
strerror_r(errno, msg, sizeof(msg)));
165165
rc = -1;
166166
goto out;
167167
}
@@ -175,7 +175,8 @@ static int record__open(struct record *rec)
175175
"(current value: %u)\n", opts->mmap_pages);
176176
rc = -errno;
177177
} else {
178-
pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno));
178+
pr_err("failed to mmap with %d (%s)\n", errno,
179+
strerror_r(errno, msg, sizeof(msg)));
179180
rc = -errno;
180181
}
181182
goto out;
@@ -480,7 +481,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
480481
}
481482

482483
if (forks && workload_exec_errno) {
483-
char msg[512];
484+
char msg[STRERR_BUFSIZE];
484485
const char *emsg = strerror_r(workload_exec_errno, msg, sizeof(msg));
485486
pr_err("Workload failed: %s\n", emsg);
486487
err = -1;

0 commit comments

Comments
 (0)