From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5514A00C2; Thu, 8 Dec 2022 09:06:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 425B342D40; Thu, 8 Dec 2022 09:06:04 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id C622442D29 for ; Thu, 8 Dec 2022 09:06:02 +0100 (CET) Received: from kwepemm600004.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NSRSp4mZCzJpCm for ; Thu, 8 Dec 2022 16:02:02 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 8 Dec 2022 16:05:34 +0800 From: Huisong Li To: CC: , , , , Subject: [PATCH 7/8] mem: possible data truncation and conversion error Date: Thu, 8 Dec 2022 16:05:39 +0800 Message-ID: <20221208080540.62913-8-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221208080540.62913-1-lihuisong@huawei.com> References: <20221208080540.62913-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The 'u32' and 'u64' data can not assigned to 'int' type variable. The 'u32' data need to use the 'u32' telemetry API to add, and the 'u64' data need to use the 'u64' telemetry API to add. Fixes: e6732d0d6e26 ("mem: add telemetry infos") Cc: stable@dpdk.org Signed-off-by: Huisong Li --- lib/eal/common/eal_common_memory.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index 688dc615d7..b7981507da 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -1139,7 +1139,7 @@ handle_eal_heap_info_request(const char *cmd __rte_unused, const char *params, malloc_heap_get_stats(heap, &sock_stats); rte_tel_data_start_dict(d); - rte_tel_data_add_dict_int(d, "Head id", heap_id); + rte_tel_data_add_dict_u32(d, "Head id", heap_id); rte_tel_data_add_dict_string(d, "Name", heap->name); rte_tel_data_add_dict_u64(d, "Heap_size", sock_stats.heap_totalsz_bytes); @@ -1148,8 +1148,8 @@ handle_eal_heap_info_request(const char *cmd __rte_unused, const char *params, sock_stats.heap_allocsz_bytes); rte_tel_data_add_dict_u64(d, "Greatest_free_size", sock_stats.greatest_free_size); - rte_tel_data_add_dict_u64(d, "Alloc_count", sock_stats.alloc_count); - rte_tel_data_add_dict_u64(d, "Free_count", sock_stats.free_count); + rte_tel_data_add_dict_u32(d, "Alloc_count", sock_stats.alloc_count); + rte_tel_data_add_dict_u32(d, "Free_count", sock_stats.free_count); return 0; } @@ -1201,13 +1201,13 @@ handle_eal_memzone_info_request(const char *cmd __rte_unused, mz = rte_fbarray_get(&mcfg->memzones, mz_idx); rte_tel_data_start_dict(d); - rte_tel_data_add_dict_int(d, "Zone", mz_idx); + rte_tel_data_add_dict_u32(d, "Zone", mz_idx); rte_tel_data_add_dict_string(d, "Name", mz->name); - rte_tel_data_add_dict_int(d, "Length", mz->len); + rte_tel_data_add_dict_u64(d, "Length", mz->len); snprintf(addr, ADDR_STR, "%p", mz->addr); rte_tel_data_add_dict_string(d, "Address", addr); rte_tel_data_add_dict_int(d, "Socket", mz->socket_id); - rte_tel_data_add_dict_int(d, "Flags", mz->flags); + rte_tel_data_add_dict_u32(d, "Flags", mz->flags); /* go through each page occupied by this memzone */ msl = rte_mem_virt2memseg_list(mz->addr); @@ -1222,7 +1222,7 @@ handle_eal_memzone_info_request(const char *cmd __rte_unused, ms_idx = RTE_PTR_DIFF(mz->addr, msl->base_va) / page_sz; ms = rte_fbarray_get(&msl->memseg_arr, ms_idx); - rte_tel_data_add_dict_int(d, "Hugepage_size", page_sz); + rte_tel_data_add_dict_u64(d, "Hugepage_size", page_sz); snprintf(addr, ADDR_STR, "%p", ms->addr); rte_tel_data_add_dict_string(d, "Hugepage_base", addr); -- 2.33.0