Skip to content

Commit

Permalink
libcasper: Consistently use item count as the first argument to calloc
Browse files Browse the repository at this point in the history
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46005
  • Loading branch information
bsdjhb committed Jul 19, 2024
1 parent 680f40f commit 5275d1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/libcasper/services/cap_dns/cap_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_length = (int)nvlist_get_number(nvl, "length");

nitems = (unsigned int)nvlist_get_number(nvl, "naliases");
hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
hp->h_aliases = calloc(nitems + 1, sizeof(hp->h_aliases[0]));
if (hp->h_aliases == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
Expand All @@ -99,7 +99,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_aliases[ii] = NULL;

nitems = (unsigned int)nvlist_get_number(nvl, "naddrs");
hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
hp->h_addr_list = calloc(nitems + 1, sizeof(hp->h_addr_list[0]));
if (hp->h_addr_list == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
Expand Down
4 changes: 2 additions & 2 deletions lib/libcasper/services/cap_net/cap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_length = (int)nvlist_get_number(nvl, "length");

nitems = (unsigned int)nvlist_get_number(nvl, "naliases");
hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
hp->h_aliases = calloc(nitems + 1, sizeof(hp->h_aliases[0]));
if (hp->h_aliases == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
Expand All @@ -119,7 +119,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_aliases[ii] = NULL;

nitems = (unsigned int)nvlist_get_number(nvl, "naddrs");
hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
hp->h_addr_list = calloc(nitems + 1, sizeof(hp->h_addr_list[0]));
if (hp->h_addr_list == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
Expand Down

0 comments on commit 5275d1d

Please sign in to comment.