From f76e133584d1ad8bad43dd1d0a15744cbe245433 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 6 Aug 2024 17:40:26 +0100 Subject: [PATCH] tests/test-api.c: Fix calloc warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14.2.1 gives: test-api.c: In function ‘testAugPreview’: test-api.c:867:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 867 | hosts_txt = calloc(sizeof(char),4096); | ^~~~ test-api.c:867:39: note: earlier argument should specify number of elements, later size of each element Signed-off-by: Richard W.M. Jones --- tests/test-api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-api.c b/tests/test-api.c index 4833dfae3..88a7f55ca 100644 --- a/tests/test-api.c +++ b/tests/test-api.c @@ -864,7 +864,7 @@ static void testAugPreview(CuTest *tc) { if (asprintf(&etc_hosts_fn,"%s/etc/hosts",root) >=0 ) { hosts_fp = fopen(etc_hosts_fn,"r"); if ( hosts_fp ) { - hosts_txt = calloc(sizeof(char),4096); + hosts_txt = calloc(4096,sizeof(char)); if ( hosts_txt ) { readsz = fread(hosts_txt,sizeof(char),4096,hosts_fp); *(hosts_txt+readsz) = '\0';