Skip to content

Commit

Permalink
perf llvm: Use strerror_r instead of the thread unsafe strerror one
Browse files Browse the repository at this point in the history
Cc: Adrian Hunter <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Mar 23, 2016
1 parent 7847826 commit 7626714
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/perf/util/llvm-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)
void *buf = NULL;
FILE *file = NULL;
size_t read_sz = 0, buf_sz = 0;
char serr[STRERR_BUFSIZE];

file = popen(cmd, "r");
if (!file) {
pr_err("ERROR: unable to popen cmd: %s\n",
strerror(errno));
strerror_r(errno, serr, sizeof(serr)));
return -EINVAL;
}

Expand Down Expand Up @@ -136,7 +137,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)

if (ferror(file)) {
pr_err("ERROR: error occurred when reading from pipe: %s\n",
strerror(errno));
strerror_r(errno, serr, sizeof(serr)));
err = -EIO;
goto errout;
}
Expand Down Expand Up @@ -370,7 +371,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
if (nr_cpus_avail <= 0) {
pr_err(
"WARNING:\tunable to get available CPUs in this system: %s\n"
" \tUse 128 instead.\n", strerror(errno));
" \tUse 128 instead.\n", strerror_r(errno, serr, sizeof(serr)));
nr_cpus_avail = 128;
}
snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
Expand Down

0 comments on commit 7626714

Please sign in to comment.