Commit 8f4c7cc3 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

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: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11177


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent b7e49409
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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) {