perf llvm: Use strerror_r instead of the thread unsafe strerror one

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5njrq9dltckgm624omw9ljgu@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 78478269
...@@ -98,11 +98,12 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz) ...@@ -98,11 +98,12 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)
void *buf = NULL; void *buf = NULL;
FILE *file = NULL; FILE *file = NULL;
size_t read_sz = 0, buf_sz = 0; size_t read_sz = 0, buf_sz = 0;
char serr[STRERR_BUFSIZE];
file = popen(cmd, "r"); file = popen(cmd, "r");
if (!file) { if (!file) {
pr_err("ERROR: unable to popen cmd: %s\n", pr_err("ERROR: unable to popen cmd: %s\n",
strerror(errno)); strerror_r(errno, serr, sizeof(serr)));
return -EINVAL; return -EINVAL;
} }
...@@ -136,7 +137,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz) ...@@ -136,7 +137,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)
if (ferror(file)) { if (ferror(file)) {
pr_err("ERROR: error occurred when reading from pipe: %s\n", pr_err("ERROR: error occurred when reading from pipe: %s\n",
strerror(errno)); strerror_r(errno, serr, sizeof(serr)));
err = -EIO; err = -EIO;
goto errout; goto errout;
} }
...@@ -370,7 +371,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf, ...@@ -370,7 +371,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
if (nr_cpus_avail <= 0) { if (nr_cpus_avail <= 0) {
pr_err( pr_err(
"WARNING:\tunable to get available CPUs in this system: %s\n" "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; nr_cpus_avail = 128;
} }
snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d", snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册