Skip to content

Commit

Permalink
Remove redundant argument in parse_cluster_slots and parse_cluster_nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Oct 3, 2024
1 parent ffc6796 commit 9dcda0b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ static int cluster_master_slave_mapping_with_name(valkeyClusterContext *cc,
/**
* Parse the "cluster slots" command reply to nodes dict.
*/
static dict *parse_cluster_slots(valkeyClusterContext *cc, valkeyReply *reply,
int flags) {
static dict *parse_cluster_slots(valkeyClusterContext *cc, valkeyReply *reply) {
int ret;
cluster_slot *slot = NULL;
dict *nodes = NULL;
Expand Down Expand Up @@ -813,7 +812,7 @@ static dict *parse_cluster_slots(valkeyClusterContext *cc, valkeyReply *reply,
}

slot = NULL;
} else if (flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) {
} else if (cc->flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) {
slave = node_get_with_slots(cc, elem_ip, elem_port,
VALKEY_ROLE_SLAVE);
if (slave == NULL) {
Expand Down Expand Up @@ -858,8 +857,7 @@ static dict *parse_cluster_slots(valkeyClusterContext *cc, valkeyReply *reply,
/**
* Parse the "cluster nodes" command reply to nodes dict.
*/
static dict *parse_cluster_nodes(valkeyClusterContext *cc, valkeyReply *reply,
int flags) {
static dict *parse_cluster_nodes(valkeyClusterContext *cc, valkeyReply *reply) {
int ret;
dict *nodes = NULL;
dict *nodes_name = NULL;
Expand Down Expand Up @@ -952,7 +950,7 @@ static dict *parse_cluster_nodes(valkeyClusterContext *cc, valkeyReply *reply,
goto oom;
}

if (flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) {
if (cc->flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) {
ret = cluster_master_slave_mapping_with_name(
cc, &nodes_name, master, master->name);
if (ret != VALKEY_OK) {
Expand Down Expand Up @@ -1004,7 +1002,7 @@ static dict *parse_cluster_nodes(valkeyClusterContext *cc, valkeyReply *reply,

}
// add slave node
else if ((flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) &&
else if ((cc->flags & VALKEYCLUSTER_FLAG_ADD_SLAVE) &&
(role_len >= 5 && memcmp(role, "slave", 5) == 0)) {
slave = node_get_with_nodes(cc, part, count_part,
VALKEY_ROLE_SLAVE);
Expand Down Expand Up @@ -1093,9 +1091,9 @@ static int clusterUpdateRouteHandleReply(valkeyClusterContext *cc,

dict *nodes;
if (cc->flags & VALKEYCLUSTER_FLAG_ROUTE_USE_SLOTS) {
nodes = parse_cluster_slots(cc, reply, cc->flags);
nodes = parse_cluster_slots(cc, reply);
} else {
nodes = parse_cluster_nodes(cc, reply, cc->flags);
nodes = parse_cluster_nodes(cc, reply);
}
freeReplyObject(reply);
return updateNodesAndSlotmap(cc, nodes);
Expand Down Expand Up @@ -2974,7 +2972,7 @@ void clusterSlotsReplyCallback(valkeyAsyncContext *ac, void *r,
}

valkeyClusterContext *cc = acc->cc;
dict *nodes = parse_cluster_slots(cc, reply, cc->flags);
dict *nodes = parse_cluster_slots(cc, reply);
if (updateNodesAndSlotmap(cc, nodes) != VALKEY_OK) {
/* Ignore failures for now */
}
Expand All @@ -2995,7 +2993,7 @@ void clusterNodesReplyCallback(valkeyAsyncContext *ac, void *r,
}

valkeyClusterContext *cc = acc->cc;
dict *nodes = parse_cluster_nodes(cc, reply, cc->flags);
dict *nodes = parse_cluster_nodes(cc, reply);
if (updateNodesAndSlotmap(cc, nodes) != VALKEY_OK) {
/* Ignore failures for now */
}
Expand Down

0 comments on commit 9dcda0b

Please sign in to comment.