From c4c510be1eb485658dfb7fe0ef77ed233eda86a3 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 18 Apr 2016 17:30:33 +0000 Subject: [PATCH] Reuse our roundup2() macro instead of reinventing the wheel. Obtained from: DragonflyBSD --- usr.sbin/btxld/btxld.c | 4 +--- usr.sbin/usbdump/usbdump.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/usr.sbin/btxld/btxld.c b/usr.sbin/btxld/btxld.c index 7984c4cd31d..c2f4b5b126f 100644 --- a/usr.sbin/btxld/btxld.c +++ b/usr.sbin/btxld/btxld.c @@ -68,8 +68,6 @@ static const char rcsid[] = #define IMPURE 1 /* Writable text */ #define MAXU32 0xffffffff /* Maximum unsigned 32-bit quantity */ -#define align(x, y) (((x) + (y) - 1) & ~((y) - 1)) - struct hdr { uint32_t fmt; /* Format */ uint32_t flags; /* Bit flags */ @@ -425,7 +423,7 @@ puthdr(int fd, struct hdr *hdr) eh.p[1].p_offset = htole32(le32toh(eh.p[0].p_offset) + le32toh(eh.p[0].p_filesz)); eh.p[1].p_vaddr = eh.p[1].p_paddr = - htole32(align(le32toh(eh.p[0].p_paddr) + le32toh(eh.p[0].p_memsz), + htole32(roundup2(le32toh(eh.p[0].p_paddr) + le32toh(eh.p[0].p_memsz), 4096)); eh.p[1].p_filesz = eh.p[1].p_memsz = htole32(hdr->data); eh.sh[2].sh_addr = eh.p[0].p_vaddr; diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c index 99307a48805..0b8b3913efe 100644 --- a/usr.sbin/usbdump/usbdump.c +++ b/usr.sbin/usbdump/usbdump.c @@ -95,8 +95,6 @@ struct usbcap_filehdr { uint8_t reserved[26]; } __packed; -#define HEADER_ALIGN(x,a) (((x) + (a) - 1) & ~((a) - 1)) - struct header_32 { /* capture timestamp */ uint32_t ts_sec; @@ -622,7 +620,7 @@ print_packets(uint8_t *data, const int datalen) temp.hdrlen = hdr32->hdrlen; temp.align = hdr32->align; - next = ptr + HEADER_ALIGN(temp.hdrlen + temp.caplen, temp.align); + next = ptr + roundup2(temp.hdrlen + temp.caplen, temp.align); if (next <= ptr) err(EXIT_FAILURE, "Invalid length");