Skip to content

Commit

Permalink
tests/test-api.c: Fix calloc warning
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rwmjones committed Aug 14, 2024
1 parent 80ed4c7 commit 87bbea4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 87bbea4

Please sign in to comment.