From owner-svn-src-head@freebsd.org Tue Apr 26 14:52:00 2016 Return-Path: Delivered-To: svn-src-head@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 76727B1C916; Tue, 26 Apr 2016 14:52:00 +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 2E5901E25; Tue, 26 Apr 2016 14:52:00 +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 u3QEpx7N032474; Tue, 26 Apr 2016 14:51:59 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3QEpxCp032471; Tue, 26 Apr 2016 14:51:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604261451.u3QEpxCp032471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 26 Apr 2016 14:51:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298645 - in head/sys/boot: common powerpc/ps3 sparc64/boot1 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2016 14:52:00 -0000 Author: pfg Date: Tue Apr 26 14:51:58 2016 New Revision: 298645 URL: https://svnweb.freebsd.org/changeset/base/298645 Log: sys/boot: make use of the howmany() macro when available. We have a howmany() macro in the header that is convenient to re-use as it makes things easier to read. Modified: head/sys/boot/common/part.c head/sys/boot/powerpc/ps3/main.c head/sys/boot/sparc64/boot1/boot1.c Modified: head/sys/boot/common/part.c ============================================================================== --- head/sys/boot/common/part.c Tue Apr 26 14:48:58 2016 (r298644) +++ head/sys/boot/common/part.c Tue Apr 26 14:51:58 2016 (r298645) @@ -257,8 +257,9 @@ ptable_gptread(struct ptable *table, voi table->sectorsize); if (phdr != NULL) { /* Read the primary GPT table. */ - size = MIN(MAXTBLSZ, (phdr->hdr_entries * phdr->hdr_entsz + - table->sectorsize - 1) / table->sectorsize); + size = MIN(MAXTBLSZ, + howmany(phdr->hdr_entries * phdr->hdr_entsz, + table->sectorsize)); if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 && gpt_checktbl(phdr, tbl, size * table->sectorsize, table->sectors - 1) == 0) { @@ -290,9 +291,9 @@ ptable_gptread(struct ptable *table, voi hdr.hdr_entsz != phdr->hdr_entsz || hdr.hdr_crc_table != phdr->hdr_crc_table) { /* Read the backup GPT table. */ - size = MIN(MAXTBLSZ, (phdr->hdr_entries * - phdr->hdr_entsz + table->sectorsize - 1) / - table->sectorsize); + size = MIN(MAXTBLSZ, + howmany(phdr->hdr_entries * phdr->hdr_entsz, + table->sectorsize)); if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 && gpt_checktbl(phdr, tbl, size * table->sectorsize, table->sectors - 1) == 0) { Modified: head/sys/boot/powerpc/ps3/main.c ============================================================================== --- head/sys/boot/powerpc/ps3/main.c Tue Apr 26 14:48:58 2016 (r298644) +++ head/sys/boot/powerpc/ps3/main.c Tue Apr 26 14:51:58 2016 (r298645) @@ -174,7 +174,7 @@ delay(int usecs) uint64_t tb,ttb; tb = mftb(); - ttb = tb + (usecs * 1000 + ns_per_tick - 1) / ns_per_tick; + ttb = tb + howmany(usecs * 1000, ns_per_tick); while (tb < ttb) tb = mftb(); } Modified: head/sys/boot/sparc64/boot1/boot1.c ============================================================================== --- head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:48:58 2016 (r298644) +++ head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:51:58 2016 (r298645) @@ -390,7 +390,7 @@ zbread(char *buf, off_t off, size_t byte p = buf; soff = VDEV_BOOT_OFFSET + off; - lb = (soff + bytes + DEV_BSIZE - 1) / DEV_BSIZE; + lb = howmany(soff + bytes, DEV_BSIZE); poff = soff; while (poff < soff + bytes) { nb = lb - poff / DEV_BSIZE;