From 0a4fd16a1c58754ac4f85cabe6a0161c9ad5f108 Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Thu, 20 Jan 2022 08:34:35 +0000 Subject: [PATCH] spdk_top: fix warning on build During make operation warning -Walloc-size-larger-than is seen. The cause is the type of threads_count variable, which can store value up to MAX_SIZE threshold. The value of the variable is then divided by 8 and multiplied by 32, what exceeds the MAX_SIZE limit. To fix the problem I changed value of threads_count to uint16_t. Its maximum value is closer to that of hard coded limit of threads RPC_MAX_THREADS than size_t. Change-Id: I7c76db21c328166c074d564d9c1d6d29ae8a07da Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11177 Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- app/spdk_top/spdk_top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index c2bdec997..785d26b0d 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -499,7 +499,7 @@ rpc_decode_cores_lw_threads(const struct spdk_json_val *val, void *out) /* The number of thread entries received from RPC can be calculated using * above define value (each JSON line = key + value, hence '* 2' ) and JSON * 'val' value (-2 is to subtract VAL_OBJECT_BEGIN/END). */ - size_t threads_count = (spdk_json_val_len(val) - 2) / RPC_THREAD_ENTRY_SIZE; + uint16_t threads_count = (spdk_json_val_len(val) - 2) / RPC_THREAD_ENTRY_SIZE; threads->thread = calloc(threads_count, sizeof(struct rpc_core_thread_info)); if (!out) {