From 58e6b87f51ba31b4a2954d0babe6b3cf7019c985 Mon Sep 17 00:00:00 2001 From: Justin Brewer Date: Tue, 27 Mar 2018 13:47:29 -0500 Subject: Remove redundant NULL checks free(NULL) is a valid NOP. Most of the hiredis free functions behave the same way. redisReaderFree is updated to also be NULL-safe. There is one redundant NULL check at sds.c:1036, but it's left as is since sds is imported from upstream. Signed-off-by: Justin Brewer --- net.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'net.c') diff --git a/net.c b/net.c index 7ce9ef4..5d50f7c 100644 --- a/net.c +++ b/net.c @@ -285,8 +285,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port, * This is a bit ugly, but atleast it works and doesn't leak memory. **/ if (c->tcp.host != addr) { - if (c->tcp.host) - free(c->tcp.host); + free(c->tcp.host); c->tcp.host = strdup(addr); } @@ -299,8 +298,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port, memcpy(c->timeout, timeout, sizeof(struct timeval)); } } else { - if (c->timeout) - free(c->timeout); + free(c->timeout); c->timeout = NULL; } @@ -452,8 +450,7 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time memcpy(c->timeout, timeout, sizeof(struct timeval)); } } else { - if (c->timeout) - free(c->timeout); + free(c->timeout); c->timeout = NULL; } -- cgit v1.2.3