Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
4693a517
Commit
4693a517
authored
May 25, 2010
by
Pierre Riteau
Browse files
Constify the API and enable -Wwrite-strings
The API is more similar to printf now.
parent
bd4ec570
Changes
7
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
4693a517
...
...
@@ -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)
...
...
anet.c
View file @
4693a517
...
...
@@ -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
);
}
...
...
anet.h
View file @
4693a517
...
...
@@ -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
);
...
...
hiredis.c
View file @
4693a517
...
...
@@ -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
;
...
...
hiredis.h
View file @
4693a517
...
...
@@ -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
sds.c
View file @
4693a517
...
...
@@ -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
));
}
...
...
sds.h
View file @
4693a517
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment