Skip to content

Commit 942a91e

Browse files
mhiramathitachiacmel
authored andcommitted
perf trace: Use strerror_r instead of strerror
Use strerror_r instead of strerror in error message for thead-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/20140814022241.3545.97543.stgit@kbuild-fedora.novalocal Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 809adea commit 942a91e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎tools/perf/builtin-trace.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
17501750
signed_print:
17511751
fprintf(trace->output, ") = %d", ret);
17521752
} else if (ret < 0 && sc->fmt->errmsg) {
1753-
char bf[256];
1753+
char bf[STRERR_BUFSIZE];
17541754
const char *emsg = strerror_r(-ret, bf, sizeof(bf)),
17551755
*e = audit_errno_to_name(-ret);
17561756

@@ -2044,6 +2044,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
20442044
int err = -1, i;
20452045
unsigned long before;
20462046
const bool forks = argc > 0;
2047+
char sbuf[STRERR_BUFSIZE];
20472048

20482049
trace->live = true;
20492050

@@ -2105,7 +2106,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
21052106

21062107
err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false);
21072108
if (err < 0) {
2108-
fprintf(trace->output, "Couldn't mmap the events: %s\n", strerror(errno));
2109+
fprintf(trace->output, "Couldn't mmap the events: %s\n",
2110+
strerror_r(errno, sbuf, sizeof(sbuf)));
21092111
goto out_delete_evlist;
21102112
}
21112113

0 commit comments

Comments
 (0)