summaryrefslogtreecommitdiffstats
path: root/sys/boot/common
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-26 14:51:58 +0000
committerpfg <pfg@FreeBSD.org>2016-04-26 14:51:58 +0000
commit8f98488963488a3a64220dd06361d0286c15cdb4 (patch)
tree07ce8a4419c47fd4788bda5302443efe21db7ed0 /sys/boot/common
parente6e57ebfe2dc9626d2884712e576c9299ea2a6c1 (diff)
downloadFreeBSD-src-8f98488963488a3a64220dd06361d0286c15cdb4.zip
FreeBSD-src-8f98488963488a3a64220dd06361d0286c15cdb4.tar.gz
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.
Diffstat (limited to 'sys/boot/common')
-rw-r--r--sys/boot/common/part.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c
index 7761de3..33da7bc 100644
--- a/sys/boot/common/part.c
+++ b/sys/boot/common/part.c
@@ -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) {
OpenPOWER on IntegriCloud