Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Nov 2024 16:51:14 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 27c7ae36be0f - stable/14 - libcasper: Consistently use item count as the first argument to calloc
Message-ID:  <202411301651.4AUGpEYd043593@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=27c7ae36be0f2e9e06701e9cd1b8383a1b125edc

commit 27c7ae36be0f2e9e06701e9cd1b8383a1b125edc
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-07-19 17:01:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 13:55:57 +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 84b49e1d2081..8681f0baef40 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 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++) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202411301651.4AUGpEYd043593>