Skip to content

Commit

Permalink
Renamed redisContext struct member 'unix' to 'unix_sock' to avoid enc…
Browse files Browse the repository at this point in the history
…ountering defined constant 'unix' in GNU C environment (see commit d8145d7).

Not all code using hiredis can compile using '-std=c99', and/or not all users are able to easily make that change to the build process of various open-source projects, so it is more pragmatic to choose a different identifier that does not impose this requirement.
  • Loading branch information
abalashov committed Apr 30, 2015
1 parent b9f907f commit d132d67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions hiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ static redisContext *redisContextInit(void) {
c->reader = redisReaderCreate();
c->tcp.host = NULL;
c->tcp.source_addr = NULL;
c->unix.path = NULL;
c->unix_sock.path = NULL;
c->timeout = NULL;

if (c->obuf == NULL || c->reader == NULL) {
Expand All @@ -626,8 +626,8 @@ void redisFree(redisContext *c) {
free(c->tcp.host);
if (c->tcp.source_addr)
free(c->tcp.source_addr);
if (c->unix.path)
free(c->unix.path);
if (c->unix_sock.path)
free(c->unix_sock.path);
if (c->timeout)
free(c->timeout);
free(c);
Expand Down Expand Up @@ -658,7 +658,7 @@ int redisReconnect(redisContext *c) {
return redisContextConnectBindTcp(c, c->tcp.host, c->tcp.port,
c->timeout, c->tcp.source_addr);
} else if (c->connection_type == REDIS_CONN_UNIX) {
return redisContextConnectUnix(c, c->unix.path, c->timeout);
return redisContextConnectUnix(c, c->unix_sock.path, c->timeout);
} else {
/* Something bad happened here and shouldn't have. There isn't
enough information in the context to reconnect. */
Expand Down
2 changes: 1 addition & 1 deletion hiredis.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef struct redisContext {

struct {
char *path;
} unix;
} unix_sock;

} redisContext;

Expand Down
4 changes: 2 additions & 2 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time
return REDIS_ERR;

c->connection_type = REDIS_CONN_UNIX;
if (c->unix.path != path)
c->unix.path = strdup(path);
if (c->unix_sock.path != path)
c->unix_sock.path = strdup(path);

if (timeout) {
if (c->timeout != timeout) {
Expand Down

0 comments on commit d132d67

Please sign in to comment.