From d1660672c0ba88e75b27af85449a0d39abed8408 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 9 Jan 2014 15:15:53 +0100 Subject: Use re-entrant version of strerror() for thread safety --- src/hardware/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/hardware/utils.c') diff --git a/src/hardware/utils.c b/src/hardware/utils.c index 305cc1e..fdce75d 100644 --- a/src/hardware/utils.c +++ b/src/hardware/utils.c @@ -132,6 +132,7 @@ short run_command(const char *command, char ***buffer, unsigned *buffer_size) { FILE *fp = NULL; short ret = -1; + char errbuf[STRERROR_BUF_LEN]; /* if command is empty */ if (!command || strlen(command) < 1) { @@ -144,7 +145,7 @@ short run_command(const char *command, char ***buffer, unsigned *buffer_size) fp = popen(command, "r"); if (!fp) { warn("Failed to run command: \"%s\"; Error: %s", - command, strerror(errno)); + command, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -159,7 +160,7 @@ done: int ret_code = pclose(fp); if (ret_code == -1) { warn("Failed to run command: \"%s\"; Error: %s", - command, strerror(errno)); + command, strerror_r(errno, errbuf, sizeof(errbuf))); if (ret == 0) { ret = -1; } -- cgit