Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2021 04:40:51 GMT
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 34dad5e91413 - stable/13 - usr.bin/netstat: use roundup2 when rounding up to power of 2.
Message-ID:  <202105160440.14G4ep47008790@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=34dad5e91413e7d533f7628d39c2b70cedf9c793

commit 34dad5e91413e7d533f7628d39c2b70cedf9c793
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2021-05-02 16:30:22 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2021-05-16 04:40:23 +0000

    usr.bin/netstat: use roundup2 when rounding up to power of 2.
    
    (cherry picked from commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8)
---
 usr.bin/netstat/common.c | 4 ++--
 usr.bin/netstat/nhops.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.bin/netstat/common.c b/usr.bin/netstat/common.c
index ac721b3e9ab0..9dbbaeee25ea 100644
--- a/usr.bin/netstat/common.c
+++ b/usr.bin/netstat/common.c
@@ -114,7 +114,7 @@ prepare_ifmap(size_t *pifmap_size)
 		ifindex = sdl->sdl_index;
 
 		if (ifindex >= ifmap_size) {
-			size = roundup(ifindex + 1, 32) *
+			size = roundup2(ifindex + 1, 32) *
 			    sizeof(struct ifmap_entry);
 			if ((ifmap = realloc(ifmap, size)) == NULL)
 				errx(2, "realloc(%d) failed", size);
@@ -122,7 +122,7 @@ prepare_ifmap(size_t *pifmap_size)
 			    size - ifmap_size *
 			    sizeof(struct ifmap_entry));
 
-			ifmap_size = roundup(ifindex + 1, 32);
+			ifmap_size = roundup2(ifindex + 1, 32);
 		}
 
 		if (*ifmap[ifindex].ifname != '\0')
diff --git a/usr.bin/netstat/nhops.c b/usr.bin/netstat/nhops.c
index 44006da7f1fe..51bed6e23c0f 100644
--- a/usr.bin/netstat/nhops.c
+++ b/usr.bin/netstat/nhops.c
@@ -213,7 +213,7 @@ nhop_map_update(struct nhop_map *map, uint32_t idx, char *gw, char *ifname)
 		else
 			new_size = map->size * 2;
 		if (new_size <= idx)
-			new_size = roundup(idx + 1, 32);
+			new_size = roundup2(idx + 1, 32);
 
 		sz = new_size * (sizeof(struct nhop_entry));
 		if ((map->ptr = realloc(map->ptr, sz)) == NULL)



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