summaryrefslogtreecommitdiff
path: root/src/redis-cli.c
diff options
context:
space:
mode:
authorViktor Söderqvist <viktor.soderqvist@est.tech>2021-08-22 12:57:18 +0200
committerGitHub <noreply@github.com>2021-08-22 13:57:18 +0300
commit74590f8345c148024a9d55471409e772d9c8fa90 (patch)
tree6f2370d5e43cd376931d58fa083d09271fea3c16 /src/redis-cli.c
parent0835f596b8d6ab3d41a76cf468877273a6afa961 (diff)
downloadredis-74590f8345c148024a9d55471409e772d9c8fa90.tar.gz
redis-cli: Assert > 0 before dividing, to silence warning by tool (#9396)
Also make sure function can't return NULL by another assert.
Diffstat (limited to 'src/redis-cli.c')
-rw-r--r--src/redis-cli.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index a85f14f73..682ca437c 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -4679,6 +4679,7 @@ static clusterManagerNode *clusterManagerNodeMasterRandom() {
master_count++;
}
+ assert(master_count > 0);
srand(time(NULL));
idx = rand() % master_count;
listRewind(cluster_manager.nodes, &li);
@@ -4690,7 +4691,7 @@ static clusterManagerNode *clusterManagerNodeMasterRandom() {
}
}
/* Can not be reached */
- return NULL;
+ assert(0);
}
static int clusterManagerFixSlotsCoverage(char *all_slots) {