staging: lustre: fix macro definitions warnings
PATCH 1/1 staging: lustre: fix macro definitions warnings
This patch fixes the checkpatch.pl warnings related to macro definitions.
1. macros with complex values should be enclosed in parentheses.
2. macros with multiple lines should be enclosed in do-while block.
--- drivers/staging/lustre/lustre/include/lu_object.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/include/lu_object.h +9 -7
@@ -1151,8 +1151,10 @@ struct lu_context_key { struct __##mod##__dummy_fini {; } /* semicolon catcher */#define LU_KEY_INIT_FINI (mod, type) \ +do { \ LU_KEY_INIT(mod, type); \ - LU_KEY_FINI(mod, type) + LU_KEY_FINI(mod, type); \ +} while (0)#define LU_CONTEXT_KEY_DEFINE (mod, tags) \ struct lu_context_key mod##_thread_key = { \
@@ -1161,10 +1163,8 @@ struct lu_context_key { .lct_fini = mod##_key_fini \ } -#define LU_CONTEXT_KEY_INIT (key) \ -do { \ - (key)->lct_owner = THIS_MODULE; \ -} while (0) +#define LU_CONTEXT_KEY_INIT (key) ((key)->lct_owner = THIS_MODULE) +int lu_context_key_register (struct lu_context_key *key);void lu_context_key_degister (struct lu_context_key *key);
@@ -1223,10 +1223,12 @@ void lu_context_key_revive(struct lu_context_key *key); struct __##mod##_dummy_type_stop {; }#define LU_TYPE_INIT_FINI (mod, ...) \ +do { \ LU_TYPE_INIT(mod, __VA_ARGS__); \ LU_TYPE_FINI(mod, __VA_ARGS__); \ LU_TYPE_START(mod, __VA_ARGS__); \ - LU_TYPE_STOP(mod, __VA_ARGS__) + LU_TYPE_STOP(mod, __VA_ARGS__); \ +} while (0)int lu_context_init (struct lu_context *ctx,__u32 tags);void lu_context_fini (struct lu_context *ctx);
@@ -1304,7 +1306,7 @@ struct lu_buf { };#define DLUBUF "(%p %zu)" -#define PLUBUF (buf) (buf)->lb_buf, (buf)->lb_len +#define PLUBUF (buf) ((buf)->lb_buf, (buf)->lb_len)/** * One-time initializers, called at obdclass module initialization, not * exported.
Signature · 1 line
2.7.4
drivers/staging/lustre/lustre/include/lu_object.h struct lu_buf { · line 1309
Quoted 6 lines
drivers/staging/lustre/lustre/include/lu_object.h +1
-1@@ -1304,7 +1306,7 @@ struct lu_buf { };#define DLUBUF "(%p %zu)" -#define PLUBUF (buf) (buf)->lb_buf, (buf)->lb_len +#define PLUBUF (buf) ((buf)->lb_buf, (buf)->lb_len)
This does not look right. () makes something into a single expression. While there is a , operator that builds a single expression, it seems much more likely that this is intended to be a pair of adjacent arguments.
To be absolutely sure, one should check the usage sites, but as far as I can tell this macro has no uses. So you could just drop it instead. You would need to be sure that the files that include this file still compile. Dropping this macro should be done in a different patch than the other changes, because the issue is not the same at all.
julia
Quoted 12 lines · Julia Lawall
drivers/staging/lustre/lustre/include/lu_object.h struct lu_buf { · line 1309
Quoted 7 lines
drivers/staging/lustre/lustre/include/lu_object.h +1
-1@@ -1304,7 +1306,7 @@ struct lu_buf { };#define DLUBUF "(%p %zu)" -#define PLUBUF (buf) (buf)->lb_buf, (buf)->lb_len +#define PLUBUF (buf) ((buf)->lb_buf, (buf)->lb_len)This does not look right. () makes something into a single expression. While there is a , operator that builds a single expression, it seems much more likely that this is intended to be a pair of adjacent arguments.
Quoted 5 lines
To be absolutely sure, one should check the usage sites, but as far as I can tell this macro has no uses. So you could just drop it instead. You would need to be sure that the files that include this file still compile. Dropping this macro should be done in a different patch than the other changes, because the issue is not the same at all.
Julia is right - the "DLUBUF" is a printf format with two values, and "PLUBUF" generates the two arguments from the passed "buf" argument.
That said, I don't see any users of this macro pair, and found only one possible place where it could even be used, which is in the server code, so both PLUBUF and DLUBUF should just be removed. Thanks.
Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation