diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2014-04-09 22:30:04 -0700 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2014-04-09 22:30:04 -0700 |
commit | a9c21e4d48ecde49901e46e78ae87897fc182d52 (patch) | |
tree | 0d69ff8886c1a44549e2e12b7fcd1a802e9398a2 | |
parent | fa8bcca1dcf8fd87f3b3ce2853d1fe32526a0afa (diff) |
Fix const correctness
-rw-r--r-- | async.c | 2 | ||||
-rw-r--r-- | async.h | 2 | ||||
-rw-r--r-- | hiredis.c | 8 | ||||
-rw-r--r-- | hiredis.h | 4 | ||||
-rw-r--r-- | net.c | 5 | ||||
-rw-r--r-- | net.h | 3 |
6 files changed, 13 insertions, 11 deletions
@@ -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); @@ -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); @@ -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; } @@ -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. */ @@ -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); } @@ -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); |