git: f6b6d216cafb - main - usr.bin/netstat: use roundup2 when rounding up to power of 2.
Xin LI
delphij at FreeBSD.org
Sun May 2 16:33:29 UTC 2021
The branch main has been updated by delphij:
URL: https://cgit.FreeBSD.org/src/commit/?id=f6b6d216cafb154a85313a2d1bd34b18b9bfbba8
commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8
Author: Xin LI <delphij at FreeBSD.org>
AuthorDate: 2021-05-02 16:30:22 +0000
Commit: Xin LI <delphij at FreeBSD.org>
CommitDate: 2021-05-02 16:30:22 +0000
usr.bin/netstat: use roundup2 when rounding up to power of 2.
MFC after: 2 weeks
---
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)
More information about the dev-commits-src-main
mailing list