diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-21 19:57:40 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-21 19:57:40 +0000 |
commit | 729533413f4e97bb65852c22fb914805e2759b5a (patch) | |
tree | cd4dfa8859a5f57124d315ff395b524d7587e1ea /sys/geom | |
parent | 0d55061d05ce55d28aff0c06bad831448d172425 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/geom/bde/g_bde_crypt.c | 2 | ||||
-rw-r--r-- | sys/geom/part/g_part_bsd64.c | 16 |
2 files changed, 8 insertions, 10 deletions
diff --git a/sys/geom/bde/g_bde_crypt.c b/sys/geom/bde/g_bde_crypt.c index c59b85a..5761e69 100644 --- a/sys/geom/bde/g_bde_crypt.c +++ b/sys/geom/bde/g_bde_crypt.c @@ -311,7 +311,7 @@ g_bde_map_sector(struct g_bde_work *wp) /* Compensate for lock sectors */ for (u = 0; u < G_BDE_MAXKEYS; u++) { /* Find the start of this lock sector */ - ko = kp->lsector[u] & ~((uint64_t)kp->sectorsize - 1); + ko = rounddown2(kp->lsector[u], (uint64_t)kp->sectorsize); if (wp->kso >= ko) wp->kso += kp->sectorsize; 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, |