diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-08-13 22:22:36 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-15 09:58:35 -0400 |
commit | 6e81c74cbf4b64620170da14844f1dc8a9a5950f (patch) | |
tree | ce4d4d23f34959965a4cae5e48355de1b40f4063 /tools/perf/util/util.c | |
parent | 5f03cba41590b5e7db5b66d2b2aa3e146ff8a84f (diff) |
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) | |||
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; |