Skip to content

Commit

Permalink
tests: clear -Wcalloc-transposed-args warnings
Browse files Browse the repository at this point in the history
* order of arguments was swapped; not consistent with calloc signature
* therefore producing -Wcalloc-transposed-args during compilation.

Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
Link: https://man7.org/linux/man-pages/man3/calloc.3p.html
Signed-off-by: Ariel Otilibili <[email protected]>
  • Loading branch information
ariel-anieli committed Dec 14, 2024
1 parent 30467f8 commit d9bb576
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/helpers/c/prng.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct prng {

struct prng *prng_new(unsigned long long seed)
{
struct prng *rv = calloc(sizeof(*rv), 1);
struct prng *rv = calloc(1, sizeof(*rv));
assert(rv);

rv->state = seed;
Expand Down
4 changes: 2 additions & 2 deletions tests/isisd/test_isis_lspdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void test_lsp_build_list_nonzero_ht(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00
};

struct isis_area *area = calloc(sizeof(*area), 1);
struct isis_area *area = calloc(1, sizeof(*area));

area->lsp_mtu = 1500;

Expand Down Expand Up @@ -75,7 +75,7 @@ static void test_lsp_build_list_nonzero_ht(void)
int main(int argc, char **argv)
{
struct isis *isis = NULL;
isis = calloc(sizeof(*isis), 1);
isis = calloc(1, sizeof(*isis));
test_lsp_build_list_nonzero_ht();
return 0;
}
8 changes: 4 additions & 4 deletions tests/lib/test_nexthop_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static struct nexthop_chain *nexthop_chain_new(void)
{
struct nexthop_chain *rv;

rv = calloc(sizeof(*rv), 1);
rv = calloc(1, sizeof(*rv));
assert(rv);
return rv;
}
Expand All @@ -71,7 +71,7 @@ static void nexthop_chain_add_top(struct nexthop_chain *nc)
{
struct nexthop *nh;

nh = calloc(sizeof(*nh), 1);
nh = calloc(1, sizeof(*nh));
assert(nh);

if (nc->head.nexthop) {
Expand Down Expand Up @@ -109,7 +109,7 @@ static void nexthop_chain_add_recursive(struct nexthop_chain *nc)
{
struct nexthop *nh;

nh = calloc(sizeof(*nh), 1);
nh = calloc(1, sizeof(*nh));
assert(nh);

assert(nc->current_top);
Expand All @@ -128,7 +128,7 @@ static void nexthop_chain_add_recursive_level(struct nexthop_chain *nc)
{
struct nexthop *nh;

nh = calloc(sizeof(*nh), 1);
nh = calloc(1, sizeof(*nh));
assert(nh);

assert(nc->current_top);
Expand Down

0 comments on commit d9bb576

Please sign in to comment.