From b4fe40532a3d1d4b89bafa315746b318232106fb Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Sun, 24 May 2015 11:26:04 +0200 Subject: [PATCH] Simplify log_syserr() (no need to be thread-safe) Using strerror_r() w/ proper error checking is impossible, if the system uses GNUisms (and losing _GNU_SOURCE's extensions is equally painful) Also, this change probably fixes a "abort() instead of error" bug. --- src/log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/log.c b/src/log.c index ca2a471..1793685 100644 --- a/src/log.c +++ b/src/log.c @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -110,8 +109,9 @@ log_syserr(enum log_levels lvl, int error, const char *pfx) char errbuf[1024]; int ret; - if (0 != strerror_r(error, errbuf, sizeof(errbuf))) - abort(); + if (!error) + return (0); + (void)snprintf(errbuf, sizeof(errbuf), "%s", strerror(error)); ret = _log(lvl, "%s%s%s", pfx ? pfx : "", pfx ? ": " : "",