tools lib subcmd: Use str_error_r()

To make it portable to non-glibc systems, that follow the XSI variant
instead of the GNU specific one that gets in place when _GNU_SOURCE is
defined.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-bozcszy93tpgw9ad6qm3dhpx@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 61a6445e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <linux/string.h>
#include <errno.h> #include <errno.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "subcmd-util.h" #include "subcmd-util.h"
...@@ -109,7 +110,7 @@ int start_command(struct child_process *cmd) ...@@ -109,7 +110,7 @@ int start_command(struct child_process *cmd)
if (cmd->dir && chdir(cmd->dir)) if (cmd->dir && chdir(cmd->dir))
die("exec %s: cd to %s failed (%s)", cmd->argv[0], die("exec %s: cd to %s failed (%s)", cmd->argv[0],
cmd->dir, strerror_r(errno, sbuf, sizeof(sbuf))); cmd->dir, str_error_r(errno, sbuf, sizeof(sbuf)));
if (cmd->env) { if (cmd->env) {
for (; *cmd->env; cmd->env++) { for (; *cmd->env; cmd->env++) {
if (strchr(*cmd->env, '=')) if (strchr(*cmd->env, '='))
...@@ -173,7 +174,7 @@ static int wait_or_whine(pid_t pid) ...@@ -173,7 +174,7 @@ static int wait_or_whine(pid_t pid)
if (errno == EINTR) if (errno == EINTR)
continue; continue;
fprintf(stderr, " Error: waitpid failed (%s)", fprintf(stderr, " Error: waitpid failed (%s)",
strerror_r(errno, sbuf, sizeof(sbuf))); str_error_r(errno, sbuf, sizeof(sbuf)));
return -ERR_RUN_COMMAND_WAITPID; return -ERR_RUN_COMMAND_WAITPID;
} }
if (waiting != pid) if (waiting != pid)
......
...@@ -5,9 +5,14 @@ objtool-y += special.o ...@@ -5,9 +5,14 @@ objtool-y += special.o
objtool-y += objtool.o objtool-y += objtool.o
objtool-y += libstring.o objtool-y += libstring.o
objtool-y += str_error_r.o
CFLAGS += -I$(srctree)/tools/lib CFLAGS += -I$(srctree)/tools/lib
$(OUTPUT)libstring.o: ../lib/string.c FORCE $(OUTPUT)libstring.o: ../lib/string.c FORCE
$(call rule_mkdir) $(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)str_error_r.o: ../lib/str_error_r.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment