diff options
author | Xin LI <delphij@FreeBSD.org> | 2021-05-02 16:30:22 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2021-05-02 16:30:22 +0000 |
commit | f6b6d216cafb154a85313a2d1bd34b18b9bfbba8 (patch) | |
tree | ef7e8b0d44a9d98ef8561c4f1671a9d142086cc4 | |
parent | 9769f6f808210ddc304bc9e3c55121e6ce4d9075 (diff) | |
download | src-f6b6d216cafb154a85313a2d1bd34b18b9bfbba8.tar.gz src-f6b6d216cafb154a85313a2d1bd34b18b9bfbba8.zip |
usr.bin/netstat: use roundup2 when rounding up to power of 2.
MFC after: 2 weeks
-rw-r--r-- | usr.bin/netstat/common.c | 4 | ||||
-rw-r--r-- | 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) |