Code

error: Actually check for strerror in configure and fix GNU-specific code.
[sysdb.git] / src / utils / error.c
index 2bc99013ebe719199b7f53b2665f5e43dd7a95ae..6d23c6bcf68b8e32661e7c49943ccb0c19d9b8b0 100644 (file)
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 
 /*
  * private data types
@@ -297,10 +298,12 @@ sdb_error_parse_priority(char *prio)
 char *
 sdb_strerror(int errnum, char *strerrbuf, size_t buflen)
 {
+       *strerrbuf = '\0';
+
 #if STRERROR_R_CHAR_P
        {
                char *tmp = strerror_r(errnum, strerrbuf, buflen);
-               if (*strerrbuf = '\0') {
+               if (*strerrbuf == '\0') {
                        if (tmp && (tmp != strerrbuf) && (*tmp != '\0'))
                                strncpy(strerrbuf, tmp, buflen);
                        else