summaryrefslogtreecommitdiffstats
path: root/sys/geom/part
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
committerpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
commit729533413f4e97bb65852c22fb914805e2759b5a (patch)
treecd4dfa8859a5f57124d315ff395b524d7587e1ea /sys/geom/part
parent0d55061d05ce55d28aff0c06bad831448d172425 (diff)
downloadFreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.zip
FreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.tar.gz
sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
Diffstat (limited to 'sys/geom/part')
-rw-r--r--sys/geom/part/g_part_bsd64.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/geom/part/g_part_bsd64.c b/sys/geom/part/g_part_bsd64.c
index 7586c94..2b88fea 100644
--- a/sys/geom/part/g_part_bsd64.c
+++ b/sys/geom/part/g_part_bsd64.c
@@ -447,9 +447,9 @@ g_part_bsd64_resize(struct g_part_table *basetable,
if (baseentry == NULL) {
pp = LIST_FIRST(&basetable->gpt_gp->consumer)->provider;
table = (struct g_part_bsd64_table *)basetable;
- table->d_abase = ((pp->mediasize -
- table->d_bbase * pp->sectorsize) & ~(table->d_align - 1)) /
- pp->sectorsize;
+ table->d_abase =
+ rounddown2(pp->mediasize - table->d_bbase * pp->sectorsize,
+ table->d_align) / pp->sectorsize;
basetable->gpt_last = table->d_abase - 1;
return (0);
}
@@ -477,8 +477,8 @@ g_part_bsd64_probe(struct g_part_table *table, struct g_consumer *cp)
pp = cp->provider;
if (pp->mediasize < 2 * PALIGN_SIZE)
return (ENOSPC);
- v = (pp->sectorsize +
- offsetof(struct disklabel64, d_magic)) & ~(pp->sectorsize - 1);
+ v = rounddown2(pp->sectorsize + offsetof(struct disklabel64, d_magic),
+ pp->sectorsize);
buf = g_read_data(cp, 0, v, &error);
if (buf == NULL)
return (error);
@@ -502,8 +502,7 @@ g_part_bsd64_read(struct g_part_table *basetable, struct g_consumer *cp)
pp = cp->provider;
table = (struct g_part_bsd64_table *)basetable;
- v32 = (pp->sectorsize +
- sizeof(struct disklabel64) - 1) & ~(pp->sectorsize - 1);
+ v32 = roundup2(sizeof(struct disklabel64), pp->sectorsize);
buf = g_read_data(cp, 0, v32, &error);
if (buf == NULL)
return (error);
@@ -620,8 +619,7 @@ g_part_bsd64_write(struct g_part_table *basetable, struct g_consumer *cp)
pp = cp->provider;
table = (struct g_part_bsd64_table *)basetable;
- sz = (pp->sectorsize +
- sizeof(struct disklabel64) - 1) & ~(pp->sectorsize - 1);
+ sz = roundup2(sizeof(struct disklabel64), pp->sectorsize);
dlp = g_malloc(sz, M_WAITOK | M_ZERO);
memcpy(dlp->d_reserved0, table->d_reserved0,
OpenPOWER on IntegriCloud