summaryrefslogtreecommitdiff
path: root/src/redis-cli.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-12-19 23:52:23 +0800
committerGitHub <noreply@github.com>2021-12-19 17:52:23 +0200
commit0fb1aa0645fd1e31d12c8d57d4326ded0aa4d555 (patch)
treea997d5739941b6036dc21fa57d489c273148669a /src/redis-cli.c
parent6add1b7217458dab90b2458e4bac3fa9a2c15e1b (diff)
downloadredis-0fb1aa0645fd1e31d12c8d57d4326ded0aa4d555.tar.gz
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.
Diffstat (limited to 'src/redis-cli.c')
-rw-r--r--src/redis-cli.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index 950e591f1..c826a93f0 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -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++;