Permalink
Browse files

Mark the timeout parameter as const in various functions

The struct timeval argument in redisConnectWithTimeout(),
redisConnectUnixWithTimeout(), redisSetTimeout(),
redisContextSetTimeout(), redisContextConnectTcp()
and redisContextConnectUnix() is never modified and can
therefore be marked as const.

Signed-off-by: Noah Williamsson <noah.williamsson@gmail.com>
  • Loading branch information...
1 parent c532edc commit fbf1bb648e2e71a354ff4a1c0db07be2b3673a8a @noahwilliamsson noahwilliamsson committed with pietern May 30, 2012
Showing with 12 additions and 12 deletions.
  1. +3 −3 hiredis.c
  2. +3 −3 hiredis.h
  3. +3 −3 net.c
  4. +3 −3 net.h
View
@@ -1025,7 +1025,7 @@ redisContext *redisConnect(const char *ip, int port) {
return c;
}
-redisContext *redisConnectWithTimeout(const char *ip, int port, struct timeval tv) {
+redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv) {
redisContext *c;
c = redisContextInit();
@@ -1061,7 +1061,7 @@ redisContext *redisConnectUnix(const char *path) {
return c;
}
-redisContext *redisConnectUnixWithTimeout(const char *path, struct timeval tv) {
+redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv) {
redisContext *c;
c = redisContextInit();
@@ -1086,7 +1086,7 @@ redisContext *redisConnectUnixNonBlock(const char *path) {
}
/* Set read/write timeout on a blocking socket. */
-int redisSetTimeout(redisContext *c, struct timeval tv) {
+int redisSetTimeout(redisContext *c, const struct timeval tv) {
if (c->flags & REDIS_BLOCK)
return redisContextSetTimeout(c,tv);
return REDIS_ERR;
View
@@ -173,12 +173,12 @@ typedef struct redisContext {
} redisContext;
redisContext *redisConnect(const char *ip, int port);
-redisContext *redisConnectWithTimeout(const char *ip, int port, struct timeval tv);
+redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv);
redisContext *redisConnectNonBlock(const char *ip, int port);
redisContext *redisConnectUnix(const char *path);
-redisContext *redisConnectUnixWithTimeout(const char *path, struct timeval tv);
+redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv);
redisContext *redisConnectUnixNonBlock(const char *path);
-int redisSetTimeout(redisContext *c, struct timeval tv);
+int redisSetTimeout(redisContext *c, const struct timeval tv);
int redisEnableKeepAlive(redisContext *c);
void redisFree(redisContext *c);
int redisBufferRead(redisContext *c);
View
6 net.c
@@ -232,7 +232,7 @@ int redisCheckSocketError(redisContext *c, int fd) {
return REDIS_OK;
}
-int redisContextSetTimeout(redisContext *c, struct timeval tv) {
+int redisContextSetTimeout(redisContext *c, const struct timeval tv) {
if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv)) == -1) {
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)");
return REDIS_ERR;
@@ -244,7 +244,7 @@ int redisContextSetTimeout(redisContext *c, struct timeval tv) {
return REDIS_OK;
}
-int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout) {
+int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout) {
int s, rv;
char _port[6]; /* strlen("65535"); */
struct addrinfo hints, *servinfo, *p;
@@ -300,7 +300,7 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
return rv; // Need to return REDIS_OK if alright
}
-int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout) {
+int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout) {
int s;
int blocking = (c->flags & REDIS_BLOCK);
struct sockaddr_un sa;
View
6 net.h
@@ -40,9 +40,9 @@
#endif
int redisCheckSocketError(redisContext *c, int fd);
-int redisContextSetTimeout(redisContext *c, struct timeval tv);
-int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout);
-int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout);
+int redisContextSetTimeout(redisContext *c, const struct timeval tv);
+int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout);
+int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout);
int redisKeepAlive(redisContext *c, int interval);
#endif

0 comments on commit fbf1bb6

Please sign in to comment.