summaryrefslogtreecommitdiff
path: root/kern/bitmap.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2016-12-09 01:41:06 +0100
committerRichard Braun <rbraun@sceen.net>2016-12-09 01:41:06 +0100
commit39c13b3b84b34e0938220126c8f147d2b0b6ac89 (patch)
tree92accef33f04f49a01765e00ec026b092ae0c8ca /kern/bitmap.c
parent84c92cd2be8bc4aea6c14a186f79c2277f0fd4aa (diff)
Force brackets around one-line conditional statements
This change was done using astyle, with a few manual editing here and there.
Diffstat (limited to 'kern/bitmap.c')
-rw-r--r--kern/bitmap.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/kern/bitmap.c b/kern/bitmap.c
index af19805f..b3117dfb 100644
--- a/kern/bitmap.c
+++ b/kern/bitmap.c
@@ -31,8 +31,9 @@ bitmap_cmp(const unsigned long *a, const unsigned long *b, int nr_bits)
if (n != 0) {
rv = memcmp(a, b, n * sizeof(unsigned long));
- if (rv != 0)
+ if (rv != 0) {
return rv;
+ }
nr_bits -= n * LONG_BIT;
}
@@ -46,19 +47,21 @@ bitmap_cmp(const unsigned long *a, const unsigned long *b, int nr_bits)
last_b &= mask;
}
- if (last_a == last_b)
+ if (last_a == last_b) {
return 0;
- else if (last_a < last_b)
+ } else if (last_a < last_b) {
return -1;
- else
+ } else {
return 1;
+ }
}
static inline unsigned long
bitmap_find_next_compute_complement(unsigned long word, int nr_bits)
{
- if (nr_bits < LONG_BIT)
+ if (nr_bits < LONG_BIT) {
word |= (((unsigned long)-1) << nr_bits);
+ }
return ~word;
}
@@ -80,27 +83,32 @@ bitmap_find_next_bit(const unsigned long *bm, int nr_bits, int bit,
word = *bm;
- if (complement)
+ if (complement) {
word = bitmap_find_next_compute_complement(word, nr_bits);
+ }
- if (bit < LONG_BIT)
+ if (bit < LONG_BIT) {
word &= ~(bitmap_mask(bit) - 1);
+ }
for (;;) {
bit = __builtin_ffsl(word);
- if (bit != 0)
+ if (bit != 0) {
return ((bm - start) * LONG_BIT) + bit - 1;
+ }
bm++;
- if (bm >= end)
+ if (bm >= end) {
return -1;
+ }
nr_bits -= LONG_BIT;
word = *bm;
- if (complement)
+ if (complement) {
word = bitmap_find_next_compute_complement(word, nr_bits);
+ }
}
}