diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-07 04:23:23 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-07 04:23:23 +0200 |
commit | 214cc189aad68868c0ac390dc12981747bbbb858 (patch) | |
tree | 32f0feee8c954588c154098eb539e3e05b2c9eb4 /src/crypto/zinc/selftest/run.h | |
parent | 2d9f583e5ceb3ec38b28678d935c107a339cf6cd (diff) |
crypto: use BIT(i) & bitmap instead of (bitmap >> i) & 1
Pros: clearer if you're not familiar with the shift idiom, uses kernel
macro.
Cons: doesn't work any more if the lvalue ever ceases to be a bool.
Neutral: generates the same machine code.
Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/selftest/run.h')
-rw-r--r-- | src/crypto/zinc/selftest/run.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/crypto/zinc/selftest/run.h b/src/crypto/zinc/selftest/run.h index 99079a0..74f607a 100644 --- a/src/crypto/zinc/selftest/run.h +++ b/src/crypto/zinc/selftest/run.h @@ -27,7 +27,7 @@ static inline bool selftest_run(const char *name, bool (*selftest)(void), do { for (i = 0; i < nobs_len; ++i) - *nobs[i] = (subset >> i) & 1; + *nobs[i] = BIT(i) & subset; if (selftest()) largest_subset = max(subset, largest_subset); else @@ -37,7 +37,7 @@ static inline bool selftest_run(const char *name, bool (*selftest)(void), } while (subset); for (i = 0; i < nobs_len; ++i) - *nobs[i] = (largest_subset >> i) & 1; + *nobs[i] = BIT(i) & largest_subset; if (largest_subset == set) pr_info("%s self-tests: pass\n", name); |