From 4cfef26251dc9056a2864e497ee19930e9513f01 Mon Sep 17 00:00:00 2001 From: ArtSin Date: Mon, 4 Nov 2024 11:17:56 +0400 Subject: [PATCH] Fix argument types of formatting functions `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 --- deps/lua/src/lua_cjson.c | 2 +- src/cluster_legacy.c | 8 ++++---- src/valkey-cli.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deps/lua/src/lua_cjson.c b/deps/lua/src/lua_cjson.c index b86d73e97c..fac9c1a345 100644 --- a/deps/lua/src/lua_cjson.c +++ b/deps/lua/src/lua_cjson.c @@ -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) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 43d56b9a09..9fc8773b9e 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -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; diff --git a/src/valkey-cli.c b/src/valkey-cli.c index b4a7fcaf91..9f055b729b 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -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; }