calloc() accepts two arguments, nmemb and size, which are multiplied together. nmemb is supposed to be the number of elements, and size the size of each element, but we're passing the size first, then the number of elements.
Because we use sizeof(), this now triggers a warning in gcc:
/home/david/Development/augustus/src/core/memory_block.c: In function ‘core_memory_block_init’:
/home/david/Development/augustus/src/core/memory_block.c:7:35: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
7 | block->memory = calloc(sizeof(char), initial_size);
| ^~~~
/home/david/Development/augustus/src/core/memory_block.c:7:35: note: earlier argument should specify number of elements, later size of each element
/home/david/Development/augustus/ext/zip/zip.c: In function ‘zip_stream_copy’:
/home/david/Development/augustus/ext/zip/zip.c:1925:24: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
1925 | *buf = calloc(sizeof(unsigned char), n);
| ^~~~~~~~
/home/david/Development/augustus/ext/zip/zip.c:1925:24: note: earlier argument should specify number of elements, later size of each element
So, while I can't see how this could actually cause an issue, let's get rid of the warning. One of the warnings is in the external zip library. I've just fixed it here, rather than updating the whole library (which seems to have diverged slightly). It seems to have been fixed there, too, though: https://github.com/kuba--/zip/pull/345
calloc()
accepts two arguments,nmemb
andsize
, which are multiplied together.nmemb
is supposed to be the number of elements, andsize
the size of each element, but we're passing the size first, then the number of elements.Because we use sizeof(), this now triggers a warning in gcc:
So, while I can't see how this could actually cause an issue, let's get rid of the warning. One of the warnings is in the external zip library. I've just fixed it here, rather than updating the whole library (which seems to have diverged slightly). It seems to have been fixed there, too, though: https://github.com/kuba--/zip/pull/345