Skip to content

Commit

Permalink
Fix argument types of formatting functions
Browse files Browse the repository at this point in the history
`lua_cjson.c`: `json->ptr` and `json->data` are `const char *`, so the argument is usually 64-bit, but `%d` was used.

`cluster_legacy.c`: `slot_info_pairs` has `uint16_t` values, but they were cast to `unsigned long` and `%i` was used.

`valkey-cli.c`: `node->replicas_count` is `int`, not `unsigned long`.

Signed-off-by: Sinkevich Artem <[email protected]>
  • Loading branch information
ArtSin committed Nov 4, 2024
1 parent a102852 commit 4cfef26
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deps/lua/src/lua_cjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ static void json_decode_descend(lua_State *l, json_parse_t *json, int slots)

strbuf_free(json->tmp);
luaL_error(l, "Found too many nested data structures (%d) at character %d",
json->current_depth, json->ptr - json->data);
json->current_depth, (int)(json->ptr - json->data));
}

static void json_parse_object_context(lua_State *l, json_parse_t *json)
Expand Down
8 changes: 4 additions & 4 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5544,12 +5544,12 @@ sds representClusterNodeFlags(sds ci, uint16_t flags) {
* else each slot is added separately. */
sds representSlotInfo(sds ci, uint16_t *slot_info_pairs, int slot_info_pairs_count) {
for (int i = 0; i < slot_info_pairs_count; i += 2) {
unsigned long start = slot_info_pairs[i];
unsigned long end = slot_info_pairs[i + 1];
unsigned int start = slot_info_pairs[i];
unsigned int end = slot_info_pairs[i + 1];
if (start == end) {
ci = sdscatfmt(ci, " %i", start);
ci = sdscatfmt(ci, " %u", start);
} else {
ci = sdscatfmt(ci, " %i-%i", start, end);
ci = sdscatfmt(ci, " %u-%u", start, end);
}
}
return ci;
Expand Down
2 changes: 1 addition & 1 deletion src/valkey-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -4395,7 +4395,7 @@ static sds clusterManagerNodeInfo(clusterManagerNode *node, int indent) {
if (node->replicate != NULL)
info = sdscatfmt(info, "\n%s replicates %S", spaces, node->replicate);
else if (node->replicas_count)
info = sdscatfmt(info, "\n%s %U additional replica(s)", spaces, node->replicas_count);
info = sdscatfmt(info, "\n%s %i additional replica(s)", spaces, node->replicas_count);
sdsfree(spaces);
return info;
}
Expand Down

0 comments on commit 4cfef26

Please sign in to comment.