diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-08-14 02:22:36 +0000 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-15 10:58:35 -0300 |
commit | 6e81c74cbf4b64620170da14844f1dc8a9a5950f (patch) | |
tree | ce4d4d23f34959965a4cae5e48355de1b40f4063 /tools/perf/util/util.c | |
parent | 5f03cba41590b5e7db5b66d2b2aa3e146ff8a84f (diff) | |
download | lwn-6e81c74cbf4b64620170da14844f1dc8a9a5950f.tar.gz lwn-6e81c74cbf4b64620170da14844f1dc8a9a5950f.zip |
perf util: Replace strerror with strerror_r for thread-safety
Replaces all strerror with strerror_r in util for making the perf lib
thread-safe.
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/20140814022236.3545.3367.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 5 |
1 files changed, 3 insertions, 2 deletions
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) size_t size = 0, alloc_size = 0; void *bf = NULL, *nbf; int fd, n, err = 0; + char sbuf[STRERR_BUFSIZE]; fd = open(filename, O_RDONLY); if (fd < 0) @@ -476,8 +477,8 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep) n = read(fd, bf + size, alloc_size - size); if (n < 0) { if (size) { - pr_warning("read failed %d: %s\n", - errno, strerror(errno)); + pr_warning("read failed %d: %s\n", errno, + strerror_r(errno, sbuf, sizeof(sbuf))); err = 0; } else err = -errno; |