From bbf0736c4e472c5488fae6990de51417bc8a2e42 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 11 Dec 2014 18:28:26 +0100 Subject: [PATCH] sdsformatip() removed. Specialized single-use function. Not the best match for sds.c btw. Also genClientPeerId() is no longer static: we need symbols. --- src/networking.c | 2 +- src/sds.c | 9 --------- src/sds.h | 1 - src/sentinel.c | 4 +++- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/networking.c b/src/networking.c index 71233ce2..e4890588 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1230,7 +1230,7 @@ void getClientsMaxBuffers(unsigned long *longest_output_list, * On failure the function still populates 'peerid' with the "?:0" string * in case you want to relax error checking or need to display something * anyway (see anetPeerToString implementation for more info). */ -static void genClientPeerId(redisClient *client, char *peerid, +void genClientPeerId(redisClient *client, char *peerid, size_t peerid_len) { if (client->flags & REDIS_UNIX_SOCKET) { /* Unix socket client. */ diff --git a/src/sds.c b/src/sds.c index fa71896e..1df1043e 100644 --- a/src/sds.c +++ b/src/sds.c @@ -962,15 +962,6 @@ sds sdsjoin(char **argv, int argc, char *sep) { return join; } -sds sdsformatip(char *ip, int port) { - if (port >= 0) - return sdscatfmt(sdsempty(), - strchr(ip,':') ? "[%s]:%i" : "%s:%i", ip, port); - else - return sdscatfmt(sdsempty(), - strchr(ip,':') ? "[%s]" : "%s", ip); -} - #ifdef SDS_TEST_MAIN #include #include "testhelp.h" diff --git a/src/sds.h b/src/sds.h index f1f84c81..37aaf7a2 100644 --- a/src/sds.h +++ b/src/sds.h @@ -91,7 +91,6 @@ sds sdscatrepr(sds s, const char *p, size_t len); sds *sdssplitargs(const char *line, int *argc); sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen); sds sdsjoin(char **argv, int argc, char *sep); -sds sdsformatip(char *ip, int port); /* Low level functions exposed to the user API */ sds sdsMakeRoomFor(sds s, size_t addlen); diff --git a/src/sentinel.c b/src/sentinel.c index 89b80e0a..f252442a 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1031,9 +1031,11 @@ sentinelRedisInstance *sentinelRedisInstanceLookupSlave( { sds key; sentinelRedisInstance *slave; + char buf[REDIS_PEER_ID_LEN]; redisAssert(ri->flags & SRI_MASTER); - key = sdsformatip(ip, port); + anetFormatAddr(buf,sizeof(buf),ip,port); + key = sdsnew(buf); slave = dictFetchValue(ri->slaves,key); sdsfree(key); return slave;