git: 5275d1ddb42d - main - libcasper: Consistently use item count as the first argument to calloc
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Jul 2024 17:07:41 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=5275d1ddb42dc70fb87925e59445059068c08271
commit 5275d1ddb42dc70fb87925e59445059068c08271
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-07-19 17:01:40 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-07-19 17:05:58 +0000
libcasper: Consistently use item count as the first argument to calloc
Reported by: GCC 14 -Wcalloc-transposed-args
Reviewed by: rlibby, emaste
Differential Revision: https://reviews.freebsd.org/D46005
---
lib/libcasper/services/cap_dns/cap_dns.c | 4 ++--
lib/libcasper/services/cap_net/cap_net.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/libcasper/services/cap_dns/cap_dns.c b/lib/libcasper/services/cap_dns/cap_dns.c
index 8548715a6978..32cbf973ad45 100644
--- a/lib/libcasper/services/cap_dns/cap_dns.c
+++ b/lib/libcasper/services/cap_dns/cap_dns.c
@@ -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++) {
@@ -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++) {
diff --git a/lib/libcasper/services/cap_net/cap_net.c b/lib/libcasper/services/cap_net/cap_net.c
index a8f039f81843..40d18319ae28 100644
--- a/lib/libcasper/services/cap_net/cap_net.c
+++ b/lib/libcasper/services/cap_net/cap_net.c
@@ -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++) {
@@ -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++) {