From owner-svn-src-all@freebsd.org Mon Apr 18 17:30:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F42BB13F52; Mon, 18 Apr 2016 17:30:35 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DABA01AE9; Mon, 18 Apr 2016 17:30:34 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3IHUYhM044137; Mon, 18 Apr 2016 17:30:34 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3IHUXJc044135; Mon, 18 Apr 2016 17:30:33 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604181730.u3IHUXJc044135@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 18 Apr 2016 17:30:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298216 - in head/usr.sbin: btxld usbdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2016 17:30:35 -0000 Author: pfg Date: Mon Apr 18 17:30:33 2016 New Revision: 298216 URL: https://svnweb.freebsd.org/changeset/base/298216 Log: Reuse our roundup2() macro instead of reinventing the wheel. Obtained from: DragonflyBSD Modified: head/usr.sbin/btxld/btxld.c head/usr.sbin/usbdump/usbdump.c Modified: head/usr.sbin/btxld/btxld.c ============================================================================== --- head/usr.sbin/btxld/btxld.c Mon Apr 18 16:25:37 2016 (r298215) +++ head/usr.sbin/btxld/btxld.c Mon Apr 18 17:30:33 2016 (r298216) @@ -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; Modified: head/usr.sbin/usbdump/usbdump.c ============================================================================== --- head/usr.sbin/usbdump/usbdump.c Mon Apr 18 16:25:37 2016 (r298215) +++ head/usr.sbin/usbdump/usbdump.c Mon Apr 18 17:30:33 2016 (r298216) @@ -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 d 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");