[lustre-devel] [PATCH 18/45] lnet: libcfs: use BIT() macro where appropriate
James Simmons
jsimmons at infradead.org
Mon May 25 15:07:55 PDT 2020
From: Mr NeilBrown <neilb at suse.de>
When accessing a bit in a bitmap/mask/flags-word it can be more
readable to use BIT(num) rather than "1 << num".
This patch makes that change to various places in libcfs.
WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 5bb99e46bc904 ("LU-6142 libcfs: use BIT() macro where appropriate")
Signed-off-by: Mr NeilBrown <neilb at suse.de>
Reviewed-on: https://review.whamcloud.com/38374
Reviewed-by: Olaf Faaland-LLNL <faaland1 at llnl.gov>
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
net/lnet/libcfs/debug.c | 2 +-
net/lnet/libcfs/libcfs_string.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/lnet/libcfs/debug.c b/net/lnet/libcfs/debug.c
index c0ec184..41a0a5e 100644
--- a/net/lnet/libcfs/debug.c
+++ b/net/lnet/libcfs/debug.c
@@ -273,7 +273,7 @@ static const char *libcfs_debug_dbg2str(int debug)
len = 1;
} else { /* space-separated tokens */
for (i = 0; i < 32; i++) {
- if (!(mask & (1 << i)))
+ if ((mask & BIT(i)) == 0)
continue;
token = fn(i);
diff --git a/net/lnet/libcfs/libcfs_string.c b/net/lnet/libcfs/libcfs_string.c
index cefe6fee..b042de5 100644
--- a/net/lnet/libcfs/libcfs_string.c
+++ b/net/lnet/libcfs/libcfs_string.c
@@ -88,9 +88,9 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
if (debugstr && strlen(debugstr) == len &&
!strncasecmp(str, debugstr, len)) {
if (op == '-')
- newmask &= ~(1 << i);
+ newmask &= ~BIT(i);
else
- newmask |= (1 << i);
+ newmask |= BIT(i);
found = 1;
break;
}
--
1.8.3.1
More information about the lustre-devel
mailing list