summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Brewer <jzb0012@auburn.edu>2018-04-17 15:04:37 -0500
committerJustin Brewer <jzb0012@auburn.edu>2018-04-30 21:45:13 -0500
commitd1c1b668c14dced57026aca936a57c2567f65107 (patch)
treec64a1f229262084675d19f8017d1f59a49c1577a
parent49bbaacc79dc73ed797450aa94463106b18d2a5d (diff)
Drop __redis_strerror_r
Since _GNU_SOURCE is now guaranteed to be unset, it is no longer necessary to support the GNU-specific version of strerror_r. Drop __redis_strerror_r from the header, and call strerror_r directly. This breaks any external users of this macro, but they shouldn't have been using it in the first place. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
-rw-r--r--hiredis.c2
-rw-r--r--hiredis.h24
-rw-r--r--net.c2
3 files changed, 2 insertions, 26 deletions
diff --git a/hiredis.c b/hiredis.c
index b344962..f119d50 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -581,7 +581,7 @@ void __redisSetError(redisContext *c, int type, const char *str) {
} else {
/* Only REDIS_ERR_IO may lack a description! */
assert(type == REDIS_ERR_IO);
- __redis_strerror_r(errno, c->errstr, sizeof(c->errstr));
+ strerror_r(errno, c->errstr, sizeof(c->errstr));
}
}
diff --git a/hiredis.h b/hiredis.h
index 77d5797..a743760 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -80,30 +80,6 @@
* SO_REUSEADDR is being used. */
#define REDIS_CONNECT_RETRIES 10
-/* strerror_r has two completely different prototypes and behaviors
- * depending on system issues, so we need to operate on the error buffer
- * differently depending on which strerror_r we're using. */
-#ifndef _GNU_SOURCE
-/* "regular" POSIX strerror_r that does the right thing. */
-#define __redis_strerror_r(errno, buf, len) \
- do { \
- strerror_r((errno), (buf), (len)); \
- } while (0)
-#else
-/* "bad" GNU strerror_r we need to clean up after. */
-#define __redis_strerror_r(errno, buf, len) \
- do { \
- char *err_str = strerror_r((errno), (buf), (len)); \
- /* If return value _isn't_ the start of the buffer we passed in, \
- * then GNU strerror_r returned an internal static buffer and we \
- * need to copy the result into our private buffer. */ \
- if (err_str != (buf)) { \
- strncpy((buf), err_str, ((len) - 1)); \
- (buf)[(len)-1] = '\0'; \
- } \
- } while (0)
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/net.c b/net.c
index 44f2575..4551f3e 100644
--- a/net.c
+++ b/net.c
@@ -71,7 +71,7 @@ static void __redisSetErrorFromErrno(redisContext *c, int type, const char *pref
if (prefix != NULL)
len = snprintf(buf,sizeof(buf),"%s: ",prefix);
- __redis_strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len);
+ strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len);
__redisSetError(c,type,buf);
}