Browse code

use just mutex+strerror

git-svn: trunk@4935

Török Edvin authored on 2009/03/13 00:52:36
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Mar 12 17:52:31 EET 2009 (edwin)
2
+------------------------------------
3
+ * libclamav/others_common.c: use just mutex+strerror
4
+
1 5
 Thu Mar 12 16:22:36 CET 2009 (tk)
2 6
 ---------------------------------
3 7
  * libclamav, clamd, clamscan: replace cl_engine_(set|get) with
... ...
@@ -23,10 +23,6 @@
23 23
 #include "clamav-config.h"
24 24
 #endif
25 25
 
26
-#ifdef C_LINUX
27
-#define _XOPEN_SOURCE 600
28
-#endif
29
-
30 26
 #include <stdio.h>
31 27
 #include <stdarg.h>
32 28
 #include <string.h>
... ...
@@ -693,19 +689,11 @@ static int cli_ftw_dir(const char *dirname, int flags, int maxdepth, cli_ftw_cb
693 693
  * used */
694 694
 const char* cli_strerror(int errnum, char *buf, size_t len)
695 695
 {
696
-#ifdef HAVE_STRERROR_R
697
-    if (strerror_r(errnum, buf, len) == -1)
698
-	return "strerror_r failed";
696
+    char *err;
697
+    pthread_mutex_lock(&cli_strerror_mutex);
698
+    err = strerror(errnum);
699
+    strncpy(buf, err, len);
700
+    pthread_mutex_unlock(&cli_strerror_mutex);
699 701
     return buf;
700
-#else
701
-    {
702
-	char *err;
703
-	pthread_mutex_lock(&cli_strerror_mutex);
704
-	err = strerror(errnum);
705
-	strncpy(buf, err, len);
706
-	pthread_mutex_unlock(&cli_strerror_mutex);
707
-	return buf;
708
-    }
709
-#endif
710 702
 }
711 703