Fix some nonsense came from LGTM (#9962)
1. Local variable 's' hides a parameter of the same name. ``` int anetTcpAccept(char *err, int s, char *ip, size_t ip_len, int *port) { if ((fd = anetGenericAccept(err,s,(struct sockaddr*)&sa,&salen)) == ANET_ERR){} } ``` Change the parameter name from `s` to `serversock`, also unified with the header file definition. 2. Comparison is always false because i <= 48. ``` for (i = 0; i < DICT_STATS_VECTLEN-1; i++) { // i < 49 (i == DICT_STATS_VECTLEN-1)?">= ":"", // i == 49 } ``` `i == DICT_STATS_VECTLEN-1` always result false, it is a dead code. 3. Empty block without comment. `else if (!strcasecmp(opt,"ch")) {}`, add a comment to avoid warnings. 4. Bit field fill of type int should have explicitly unsigned integral, explicitly signed integral, or enumeration type. Modify `int fill: QL_FILL_BITS;` to `unsigned int fill: QL_FILL_BITS;` 5. The result of this call to reconnectingRedisCommand is not checked for null, but 80% of calls to reconnectingRedisCommand check for null. Just a cleanup job like others.
This commit is contained in:
parent
6add1b7217
commit
0fb1aa0645
|
@ -529,11 +529,11 @@ static int anetGenericAccept(char *err, int s, struct sockaddr *sa, socklen_t *l
|
|||
|
||||
/* Accept a connection and also make sure the socket is non-blocking, and CLOEXEC.
|
||||
* returns the new socket FD, or -1 on error. */
|
||||
int anetTcpAccept(char *err, int s, char *ip, size_t ip_len, int *port) {
|
||||
int anetTcpAccept(char *err, int serversock, char *ip, size_t ip_len, int *port) {
|
||||
int fd;
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t salen = sizeof(sa);
|
||||
if ((fd = anetGenericAccept(err,s,(struct sockaddr*)&sa,&salen)) == ANET_ERR)
|
||||
if ((fd = anetGenericAccept(err,serversock,(struct sockaddr*)&sa,&salen)) == ANET_ERR)
|
||||
return ANET_ERR;
|
||||
|
||||
if (sa.ss_family == AF_INET) {
|
||||
|
|
|
@ -1154,8 +1154,7 @@ size_t _dictGetStatsHt(char *buf, size_t bufsize, dict *d, int htidx) {
|
|||
if (clvector[i] == 0) continue;
|
||||
if (l >= bufsize) break;
|
||||
l += snprintf(buf+l,bufsize-l,
|
||||
" %s%ld: %ld (%.02f%%)\n",
|
||||
(i == DICT_STATS_VECTLEN-1)?">= ":"",
|
||||
" %ld: %ld (%.02f%%)\n",
|
||||
i, clvector[i], ((float)clvector[i]/DICTHT_SIZE(d->ht_size_exp[htidx]))*100);
|
||||
}
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ void geoaddCommand(client *c) {
|
|||
char *opt = c->argv[longidx]->ptr;
|
||||
if (!strcasecmp(opt,"nx")) nx = 1;
|
||||
else if (!strcasecmp(opt,"xx")) xx = 1;
|
||||
else if (!strcasecmp(opt,"ch")) {}
|
||||
else if (!strcasecmp(opt,"ch")) { /* Handle in zaddCommand. */ }
|
||||
else break;
|
||||
longidx++;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ typedef struct quicklist {
|
|||
quicklistNode *tail;
|
||||
unsigned long count; /* total count of all entries in all listpacks */
|
||||
unsigned long len; /* number of quicklistNodes */
|
||||
int fill : QL_FILL_BITS; /* fill factor for individual nodes */
|
||||
unsigned int fill : QL_FILL_BITS; /* fill factor for individual nodes */
|
||||
unsigned int compress : QL_COMP_BITS; /* depth of end nodes not to compress;0=off */
|
||||
unsigned int bookmark_count: QL_BM_BITS;
|
||||
quicklistBookmark bookmarks[];
|
||||
|
|
|
@ -7904,8 +7904,11 @@ static void statMode(void) {
|
|||
int j;
|
||||
|
||||
reply = reconnectingRedisCommand(context,"INFO");
|
||||
if (reply->type == REDIS_REPLY_ERROR) {
|
||||
printf("ERROR: %s\n", reply->str);
|
||||
if (reply == NULL) {
|
||||
fprintf(stderr, "\nI/O error\n");
|
||||
exit(1);
|
||||
} else if (reply->type == REDIS_REPLY_ERROR) {
|
||||
fprintf(stderr, "ERROR: %s\n", reply->str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -8071,7 +8074,7 @@ static void LRUTestMode(void) {
|
|||
if (redisGetReply(context, (void**)&reply) == REDIS_OK) {
|
||||
switch(reply->type) {
|
||||
case REDIS_REPLY_ERROR:
|
||||
printf("%s\n", reply->str);
|
||||
fprintf(stderr, "%s\n", reply->str);
|
||||
break;
|
||||
case REDIS_REPLY_NIL:
|
||||
misses++;
|
||||
|
|
Loading…
Reference in New Issue