sys/boot: make use of the howmany() macro when available.

We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
This commit is contained in:
Pedro F. Giffuni 2016-04-26 14:51:58 +00:00
parent 96edd3f3ee
commit 768f89e078
3 changed files with 8 additions and 7 deletions

View File

@ -257,8 +257,9 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread)
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, void *dev, diskread_t dread)
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) {

View File

@ -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();
}

View File

@ -390,7 +390,7 @@ zbread(char *buf, off_t off, size_t bytes)
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;