From 191a5fe45842d868f48640df63c9745dc2b2ff0d Mon Sep 17 00:00:00 2001 From: Li Zhijian Date: Tue, 12 Nov 2024 17:05:19 +0800 Subject: [PATCH] libibnetdisc: Correct argument order in calloc call to fix warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a compiler warning related to the use of calloc. ``` libibnetdisc/ibnetdisc_cache.c:560:36: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 560 | calloc(sizeof(*node->ports), node->numports + 1))) { | ^ libibnetdisc/ibnetdisc_cache.c:560:36: note: earlier argument should specify number of elements, later size of each element ``` The warning was due to transposed arguments in the calloc call, where the number of elements and the size of each element were specified in the wrong order. The correct order for calloc's arguments is: void *calloc(size_t nmemb, size_t size) Signed-off-by: Li Zhijian --- libibnetdisc/ibnetdisc_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libibnetdisc/ibnetdisc_cache.c b/libibnetdisc/ibnetdisc_cache.c index 605582fca..10de714e6 100644 --- a/libibnetdisc/ibnetdisc_cache.c +++ b/libibnetdisc/ibnetdisc_cache.c @@ -557,7 +557,7 @@ static int _rebuild_nodes(ibnd_fabric_cache_t * fabric_cache) /* Rebuild node ports array */ if (!(node->ports = - calloc(sizeof(*node->ports), node->numports + 1))) { + calloc(node->numports + 1, sizeof(*node->ports)))) { IBND_DEBUG("OOM: node->ports\n"); return -1; }