From a9c21e4d48ecde49901e46e78ae87897fc182d52 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 9 Apr 2014 22:30:04 -0700 Subject: Fix const correctness --- async.c | 2 +- async.h | 2 +- hiredis.c | 8 ++++---- hiredis.h | 4 ++-- net.c | 5 +++-- net.h | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/async.c b/async.c index 7fd17f2..f7f343b 100644 --- a/async.c +++ b/async.c @@ -166,7 +166,7 @@ redisAsyncContext *redisAsyncConnect(const char *ip, int port) { } redisAsyncContext *redisAsyncConnectBind(const char *ip, int port, - char *source_addr) { + const char *source_addr) { redisContext *c = redisConnectBindNonBlock(ip,port,source_addr); redisAsyncContext *ac = redisAsyncInitialize(c); __redisAsyncCopyError(ac); diff --git a/async.h b/async.h index 1df2ff0..8a2cf1e 100644 --- a/async.h +++ b/async.h @@ -102,7 +102,7 @@ typedef struct redisAsyncContext { /* Functions that proxy to hiredis */ redisAsyncContext *redisAsyncConnect(const char *ip, int port); -redisAsyncContext *redisAsyncConnectBind(const char *ip, int port,char *source); +redisAsyncContext *redisAsyncConnectBind(const char *ip, int port, const char *source_addr); redisAsyncContext *redisAsyncConnectUnix(const char *path); int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn); int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn); diff --git a/hiredis.c b/hiredis.c index 4054de6..2afee56 100644 --- a/hiredis.c +++ b/hiredis.c @@ -1057,7 +1057,7 @@ redisContext *redisConnectNonBlock(const char *ip, int port) { } redisContext *redisConnectBindNonBlock(const char *ip, int port, - char *source_addr) { + const char *source_addr) { redisContext *c = redisContextInit(); c->flags &= ~REDIS_BLOCK; redisContextConnectBindTcp(c,ip,port,NULL,source_addr); @@ -1244,7 +1244,7 @@ int redisGetReply(redisContext *c, void **reply) { * is used, you need to call redisGetReply yourself to retrieve * the reply (or replies in pub/sub). */ -int __redisAppendCommand(redisContext *c, char *cmd, size_t len) { +int __redisAppendCommand(redisContext *c, const char *cmd, size_t len) { sds newbuf; newbuf = sdscatlen(c->obuf,cmd,len); @@ -1257,9 +1257,9 @@ int __redisAppendCommand(redisContext *c, char *cmd, size_t len) { return REDIS_OK; } -int redisAppendFormattedCommand(redisContext *c, char *format, size_t len) { +int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len) { - if (__redisAppendCommand(c, format, len) != REDIS_OK) { + if (__redisAppendCommand(c, cmd, len) != REDIS_OK) { return REDIS_ERR; } diff --git a/hiredis.h b/hiredis.h index 05bfc47..7700f4b 100644 --- a/hiredis.h +++ b/hiredis.h @@ -175,7 +175,7 @@ typedef struct redisContext { redisContext *redisConnect(const char *ip, int port); redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv); redisContext *redisConnectNonBlock(const char *ip, int port); -redisContext *redisConnectBindNonBlock(const char *ip, int port, char *source); +redisContext *redisConnectBindNonBlock(const char *ip, int port, const char *source_addr); redisContext *redisConnectUnix(const char *path); redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv); redisContext *redisConnectUnixNonBlock(const char *path); @@ -196,7 +196,7 @@ int redisGetReplyFromReader(redisContext *c, void **reply); /* Write a formatted command to the output buffer. Use these functions in blocking mode * to get a pipeline of commands. */ -int redisAppendFormattedCommand(redisContext *c, char *format, size_t len); +int redisAppendFormattedCommand(redisContext *c, const char *cmd, size_t len); /* Write a command to the output buffer. Use these functions in blocking mode * to get a pipeline of commands. */ diff --git a/net.c b/net.c index 7c787df..f7d291b 100644 --- a/net.c +++ b/net.c @@ -255,7 +255,7 @@ int redisContextSetTimeout(redisContext *c, const struct timeval tv) { static int _redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout, - char *source_addr) { + const char *source_addr) { int s, rv; char _port[6]; /* strlen("65535"); */ struct addrinfo hints, *servinfo, *bservinfo, *p, *b; @@ -347,7 +347,8 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, } int redisContextConnectBindTcp(redisContext *c, const char *addr, int port, - const struct timeval *timeout, char *source_addr) { + const struct timeval *timeout, + const char *source_addr) { return _redisContextConnectTcp(c, addr, port, timeout, source_addr); } diff --git a/net.h b/net.h index 370a1ff..5e742f5 100644 --- a/net.h +++ b/net.h @@ -43,7 +43,8 @@ int redisCheckSocketError(redisContext *c); int redisContextSetTimeout(redisContext *c, const struct timeval tv); int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout); int redisContextConnectBindTcp(redisContext *c, const char *addr, int port, - const struct timeval *timeout, char *source_addr); + const struct timeval *timeout, + const char *source_addr); int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout); int redisKeepAlive(redisContext *c, int interval); -- cgit v1.2.3