Rename two 'buf' vars to 'ip' for better clarity
Clearly ip[32] is wrong, but it's less clear that buf[32] was wrong without further reading.
This commit is contained in:
parent
c38884ceac
commit
7e63dd23f3
@ -456,19 +456,19 @@ void sentinelIsRunning(void) {
|
|||||||
* EINVAL: Invalid port number.
|
* EINVAL: Invalid port number.
|
||||||
*/
|
*/
|
||||||
sentinelAddr *createSentinelAddr(char *hostname, int port) {
|
sentinelAddr *createSentinelAddr(char *hostname, int port) {
|
||||||
char buf[REDIS_IP_STR_LEN];
|
char ip[REDIS_IP_STR_LEN];
|
||||||
sentinelAddr *sa;
|
sentinelAddr *sa;
|
||||||
|
|
||||||
if (port <= 0 || port > 65535) {
|
if (port <= 0 || port > 65535) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (anetResolve(NULL,hostname,buf,sizeof(buf)) == ANET_ERR) {
|
if (anetResolve(NULL,hostname,ip,sizeof(ip)) == ANET_ERR) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sa = zmalloc(sizeof(*sa));
|
sa = zmalloc(sizeof(*sa));
|
||||||
sa->ip = sdsnew(buf);
|
sa->ip = sdsnew(ip);
|
||||||
sa->port = port;
|
sa->port = port;
|
||||||
return sa;
|
return sa;
|
||||||
}
|
}
|
||||||
@ -2690,7 +2690,7 @@ void sentinelCommand(redisClient *c) {
|
|||||||
/* SENTINEL MONITOR <name> <ip> <port> <quorum> */
|
/* SENTINEL MONITOR <name> <ip> <port> <quorum> */
|
||||||
sentinelRedisInstance *ri;
|
sentinelRedisInstance *ri;
|
||||||
long quorum, port;
|
long quorum, port;
|
||||||
char buf[REDIS_IP_STR_LEN];
|
char ip[REDIS_IP_STR_LEN];
|
||||||
|
|
||||||
if (c->argc != 6) goto numargserr;
|
if (c->argc != 6) goto numargserr;
|
||||||
if (getLongFromObjectOrReply(c,c->argv[5],&quorum,"Invalid quorum")
|
if (getLongFromObjectOrReply(c,c->argv[5],&quorum,"Invalid quorum")
|
||||||
@ -2700,7 +2700,7 @@ void sentinelCommand(redisClient *c) {
|
|||||||
/* Make sure the IP field is actually a valid IP before passing it
|
/* Make sure the IP field is actually a valid IP before passing it
|
||||||
* to createSentinelRedisInstance(), otherwise we may trigger a
|
* to createSentinelRedisInstance(), otherwise we may trigger a
|
||||||
* DNS lookup at runtime. */
|
* DNS lookup at runtime. */
|
||||||
if (anetResolveIP(NULL,c->argv[3]->ptr,buf,sizeof(buf)) == ANET_ERR) {
|
if (anetResolveIP(NULL,c->argv[3]->ptr,ip,sizeof(ip)) == ANET_ERR) {
|
||||||
addReplyError(c,"Invalid IP address specified");
|
addReplyError(c,"Invalid IP address specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user