Staging: lustre: lmv: Remove unneeded do-while(0)
PATCH 1/1 Staging: lustre: lmv: Remove unneeded do-while(0)
do {} while (0) wrapper in a single statement macro is unneeded. Also its ok to keep empty #define here to avoid "statement with no effect" warning.
--- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/lmv/lmv_obd.c +1 -1
@@ -2147,7 +2147,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs)LASSERTF (nlupgs ==0 ,"left = %d" , nlupgs); }#else -#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs) do {} while (0) +#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs)#endif /* PAGE_CACHE_SIZE > LU_PAGE_SIZE */ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 1 line · Bhumika Goyal
do {} while (0) wrapper in a single statement macro is unneeded.
Are you sure? You can easly break code by changing this.
Quoted 13 lines
Also its ok to keep empty #define here to avoid "statement with no effect" warning.
Signed-off-by Bhumika Goyal <[email protected]>--- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/lmv/lmv_obd.c +0
-0
drivers/staging/lustre/lustre/lmv/lmv_obd.c static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) · line 2150
Quoted 5 lines
drivers/staging/lustre/lustre/lmv/lmv_obd.c +1
-1@@ -2147,7 +2147,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) LASSERTF(nlupgs == 0, "left = %d", nlupgs); }#else -#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs) do {} while (0) +#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs)
That's scary, please leave it alone, unless you audited all users of this call? Hint, think about if this call was used as the result of an if() statement?
thanks,
greg k-h
Quoted 28 lines · Greg KH
Quoted 1 line · Bhumika Goyal
do {} while (0) wrapper in a single statement macro is unneeded.
Are you sure? You can easly break code by changing this.
Quoted 13 lines
Also its ok to keep empty #define here to avoid "statement with no effect" warning.
Signed-off-by Bhumika Goyal <[email protected]>--- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/lmv/lmv_obd.c +0
-0drivers/staging/lustre/lustre/lmv/lmv_obd.c static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) · line 2150
Quoted 5 lines
drivers/staging/lustre/lustre/lmv/lmv_obd.c +1
-1@@ -2147,7 +2147,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) LASSERTF(nlupgs == 0, "left = %d", nlupgs); }#else -#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs) do {} while (0) +#define lmv_adjust_dirpages (pages, ncfspgs, nlupgs)That's scary, please leave it alone, unless you audited all users of this call? Hint, think about if this call was used as the result of an
if()statement?
Quoted 3 lines
thanks,
greg k-h
I found out is that if (PAGE_CACHE_SIZE > LU_PAGE_SIZE) then functionlmv_adjust_dirpages is defined with void retun type and it does something. Otherwise it is defined as macro and does nothing. Also lmv_adjust_dirpages is called only once in entire kernel and its retun value is not stored anywhere which implies that the call is made to function lmv_adjust_dirpages and not the macro. So I guess the macro can be dropped as it is of no use.
Thanks
Bhumika