git: a56dc7e6c774 - stable/13 - libcasper: Consistently use item count as the first argument to calloc
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 30 Nov 2024 16:51:36 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a56dc7e6c774e3bfe8afa7f8d9d445ec6450f9df commit a56dc7e6c774e3bfe8afa7f8d9d445ec6450f9df Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-07-19 17:01:40 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-11-29 19:25:37 +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 (cherry picked from commit 5275d1ddb42dc70fb87925e59445059068c08271) --- 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 1e552d2dc252..a5223a0ea4a5 100644 --- a/lib/libcasper/services/cap_dns/cap_dns.c +++ b/lib/libcasper/services/cap_dns/cap_dns.c @@ -84,7 +84,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++) { @@ -98,7 +98,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 c29bc36bf64c..62eddd0a80a8 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++) {