diff options
author | Pierre Riteau <priteau@gmail.com> | 2010-05-25 13:56:18 +0200 |
---|---|---|
committer | Pierre Riteau <priteau@gmail.com> | 2010-05-25 14:02:14 +0200 |
commit | 4693a51707fa5c29853d7df110b424df08114f38 (patch) | |
tree | 97bc1be307a46a0e72b3080855d652ab76b502f7 | |
parent | bd4ec5705906642268d93561985f216f07dc2ba7 (diff) |
Constify the API and enable -Wwrite-strings
The API is more similar to printf now.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | anet.c | 4 | ||||
-rw-r--r-- | anet.h | 2 | ||||
-rw-r--r-- | hiredis.c | 6 | ||||
-rw-r--r-- | hiredis.h | 4 | ||||
-rw-r--r-- | sds.c | 4 | ||||
-rw-r--r-- | sds.h | 4 |
7 files changed, 13 insertions, 13 deletions
@@ -8,7 +8,7 @@ ifeq ($(uname_S),SunOS) CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6 CCLINK?= -ldl -lnsl -lsocket -lm -lpthread else - CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF) + CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -Wwrite-strings $(ARCH) $(PROF) CCLINK?= -lm -pthread endif CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF) @@ -125,7 +125,7 @@ int anetResolve(char *err, char *host, char *ipbuf) #define ANET_CONNECT_NONE 0 #define ANET_CONNECT_NONBLOCK 1 -static int anetTcpGenericConnect(char *err, char *addr, int port, int flags) +static int anetTcpGenericConnect(char *err, const char *addr, int port, int flags) { int s, on = 1; struct sockaddr_in sa; @@ -167,7 +167,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, int flags) return s; } -int anetTcpConnect(char *err, char *addr, int port) +int anetTcpConnect(char *err, const char *addr, int port) { return anetTcpGenericConnect(err,addr,port,ANET_CONNECT_NONE); } @@ -35,7 +35,7 @@ #define ANET_ERR -1 #define ANET_ERR_LEN 256 -int anetTcpConnect(char *err, char *addr, int port); +int anetTcpConnect(char *err, const char *addr, int port); int anetTcpNonBlockConnect(char *err, char *addr, int port); int anetRead(int fd, char *buf, int count); int anetResolve(char *err, char *host, char *ipbuf); @@ -50,7 +50,7 @@ static void redisOOM(void) { * to the socket file descriptor. On error a redisReply object is returned * with reply->type set to REDIS_REPLY_ERROR and reply->string containing * the error message. This replyObject must be freed with redisFreeReply(). */ -redisReply *redisConnect(int *fd, char *ip, int port) { +redisReply *redisConnect(int *fd, const char *ip, int port) { char err[ANET_ERR_LEN]; *fd = anetTcpConnect(err,ip,port); @@ -233,10 +233,10 @@ static void addArgument(sds a, char ***argv, int *argc) { * Finally when type is REDIS_REPLY_INTEGER the long long integer is * stored at reply->integer. */ -redisReply *redisCommand(int fd, char *format, ...) { +redisReply *redisCommand(int fd, const char *format, ...) { va_list ap; size_t size; - char *arg, *c = format; + const char *arg, *c = format; sds cmd = sdsempty(); /* whole command buffer */ sds current = sdsempty(); /* current argument */ char **argv = NULL; @@ -47,8 +47,8 @@ typedef struct redisReply { struct redisReply **element; /* elements vector for REDIS_REPLY_ARRAY */ } redisReply; -redisReply *redisConnect(int *fd, char *ip, int port); +redisReply *redisConnect(int *fd, const char *ip, int port); void freeReplyObject(redisReply *r); -redisReply *redisCommand(int fd, char *format, ...); +redisReply *redisCommand(int fd, const char *format, ...); #endif @@ -116,7 +116,7 @@ static sds sdsMakeRoomFor(sds s, size_t addlen) { return newsh->buf; } -sds sdscatlen(sds s, void *t, size_t len) { +sds sdscatlen(sds s, const void *t, size_t len) { struct sdshdr *sh; size_t curlen = sdslen(s); @@ -130,7 +130,7 @@ sds sdscatlen(sds s, void *t, size_t len) { return s; } -sds sdscat(sds s, char *t) { +sds sdscat(sds s, const char *t) { return sdscatlen(s, t, strlen(t)); } @@ -48,8 +48,8 @@ size_t sdslen(const sds s); sds sdsdup(const sds s); void sdsfree(sds s); size_t sdsavail(sds s); -sds sdscatlen(sds s, void *t, size_t len); -sds sdscat(sds s, char *t); +sds sdscatlen(sds s, const void *t, size_t len); +sds sdscat(sds s, const char *t); sds sdscpylen(sds s, char *t, size_t len); sds sdscpy(sds s, char *t); |