Re: [PATCH] Staging: lustre: lustre: lmv: Compress return logic into one line.

2017-01-08 Thread Dilger, Andreas
On Jan 4, 2017, at 22:14, Gustavo A. R. Silva  
wrote:
> 
> Simplify return logic to avoid unnecessary variable assignments.
> These issues were detected using Coccinelle and the following semantic patch:
> 
> @@
> local idexpression ret;
> expression e;
> @@
> 
> -ret =
> +return
> e;
> -return ret;
> 
> Signed-off-by: Gustavo A. R. Silva 

Reviewed-by: Andreas Dilger 

> ---
> drivers/staging/lustre/lustre/lmv/lmv_obd.c | 58 -
> 1 file changed, 16 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
> b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index f124f6c..76a0306 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -771,7 +771,6 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
> unsigned int cmd, int len,
>struct lustre_kernelcomm *lk,
>void __user *uarg)
> {
> - int rc = 0;
>   __u32 i;
> 
>   /* unregister request (call from llapi_hsm_copytool_fini) */
> @@ -791,9 +790,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
> unsigned int cmd, int len,
>* Unreached coordinators will get EPIPE on next requests
>* and will unregister automatically.
>*/
> - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
> -
> - return rc;
> + return libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
> }
> 
> static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
> @@ -1425,8 +1422,7 @@ static int lmv_getstatus(struct obd_export *exp,
>   if (rc)
>   return rc;
> 
> - rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid);
> - return rc;
> + return md_getstatus(lmv->tgts[0]->ltd_exp, fid);
> }
> 
> static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
> @@ -1447,10 +1443,8 @@ static int lmv_getxattr(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_getxattr(tgt->ltd_exp, fid, valid, name, input,
> + return md_getxattr(tgt->ltd_exp, fid, valid, name, input,
>input_size, output_size, flags, request);
> -
> - return rc;
> }
> 
> static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
> @@ -1472,11 +1466,9 @@ static int lmv_setxattr(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_setxattr(tgt->ltd_exp, fid, valid, name, input,
> + return md_setxattr(tgt->ltd_exp, fid, valid, name, input,
>input_size, output_size, flags, suppgid,
>request);
> -
> - return rc;
> }
> 
> static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
> @@ -1500,9 +1492,7 @@ static int lmv_getattr(struct obd_export *exp, struct 
> md_op_data *op_data,
>   return 0;
>   }
> 
> - rc = md_getattr(tgt->ltd_exp, op_data, request);
> -
> - return rc;
> + return md_getattr(tgt->ltd_exp, op_data, request);
> }
> 
> static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid)
> @@ -1549,8 +1539,7 @@ static int lmv_close(struct obd_export *exp, struct 
> md_op_data *op_data,
>   return PTR_ERR(tgt);
> 
>   CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(_data->op_fid1));
> - rc = md_close(tgt->ltd_exp, op_data, mod, request);
> - return rc;
> + return md_close(tgt->ltd_exp, op_data, mod, request);
> }
> 
> /**
> @@ -1743,10 +1732,8 @@ lmv_enqueue(struct obd_export *exp, struct 
> ldlm_enqueue_info *einfo,
>   CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n",
>  LL_IT2STR(it), PFID(_data->op_fid1), tgt->ltd_idx);
> 
> - rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
> + return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
>   extra_lock_flags);
> -
> - return rc;
> }
> 
> static int
> @@ -1894,9 +1881,7 @@ static int lmv_link(struct obd_export *exp, struct 
> md_op_data *op_data,
>   if (rc != 0)
>   return rc;
> 
> - rc = md_link(tgt->ltd_exp, op_data, request);
> -
> - return rc;
> + return md_link(tgt->ltd_exp, op_data, request);
> }
> 
> static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
> @@ -2109,8 +2094,7 @@ static int lmv_sync(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_sync(tgt->ltd_exp, fid, request);
> - return rc;
> + return md_sync(tgt->ltd_exp, fid, request);
> }
> 
> /**
> @@ -2428,17 +2412,14 @@ static int lmv_read_page(struct obd_export *exp, 
> struct md_op_data *op_data,
>   return rc;
> 
>   if (unlikely(lsm)) {
> - rc = 

[PATCH] Staging: lustre: lustre: lmv: Compress return logic into one line.

2017-01-04 Thread Gustavo A. R. Silva
Simplify return logic to avoid unnecessary variable assignments.
These issues were detected using Coccinelle and the following semantic patch:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
 e;
-return ret;

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c | 58 -
 1 file changed, 16 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index f124f6c..76a0306 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -771,7 +771,6 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
unsigned int cmd, int len,
 struct lustre_kernelcomm *lk,
 void __user *uarg)
 {
-   int rc = 0;
__u32 i;
 
/* unregister request (call from llapi_hsm_copytool_fini) */
@@ -791,9 +790,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
unsigned int cmd, int len,
 * Unreached coordinators will get EPIPE on next requests
 * and will unregister automatically.
 */
-   rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
-
-   return rc;
+   return libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
 }
 
 static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
@@ -1425,8 +1422,7 @@ static int lmv_getstatus(struct obd_export *exp,
if (rc)
return rc;
 
-   rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid);
-   return rc;
+   return md_getstatus(lmv->tgts[0]->ltd_exp, fid);
 }
 
 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
@@ -1447,10 +1443,8 @@ static int lmv_getxattr(struct obd_export *exp, const 
struct lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
 
-   rc = md_getxattr(tgt->ltd_exp, fid, valid, name, input,
+   return md_getxattr(tgt->ltd_exp, fid, valid, name, input,
 input_size, output_size, flags, request);
-
-   return rc;
 }
 
 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
@@ -1472,11 +1466,9 @@ static int lmv_setxattr(struct obd_export *exp, const 
struct lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
 
-   rc = md_setxattr(tgt->ltd_exp, fid, valid, name, input,
+   return md_setxattr(tgt->ltd_exp, fid, valid, name, input,
 input_size, output_size, flags, suppgid,
 request);
-
-   return rc;
 }
 
 static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
@@ -1500,9 +1492,7 @@ static int lmv_getattr(struct obd_export *exp, struct 
md_op_data *op_data,
return 0;
}
 
-   rc = md_getattr(tgt->ltd_exp, op_data, request);
-
-   return rc;
+   return md_getattr(tgt->ltd_exp, op_data, request);
 }
 
 static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid)
@@ -1549,8 +1539,7 @@ static int lmv_close(struct obd_export *exp, struct 
md_op_data *op_data,
return PTR_ERR(tgt);
 
CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(_data->op_fid1));
-   rc = md_close(tgt->ltd_exp, op_data, mod, request);
-   return rc;
+   return md_close(tgt->ltd_exp, op_data, mod, request);
 }
 
 /**
@@ -1743,10 +1732,8 @@ lmv_enqueue(struct obd_export *exp, struct 
ldlm_enqueue_info *einfo,
CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n",
   LL_IT2STR(it), PFID(_data->op_fid1), tgt->ltd_idx);
 
-   rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
+   return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
extra_lock_flags);
-
-   return rc;
 }
 
 static int
@@ -1894,9 +1881,7 @@ static int lmv_link(struct obd_export *exp, struct 
md_op_data *op_data,
if (rc != 0)
return rc;
 
-   rc = md_link(tgt->ltd_exp, op_data, request);
-
-   return rc;
+   return md_link(tgt->ltd_exp, op_data, request);
 }
 
 static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
@@ -2109,8 +2094,7 @@ static int lmv_sync(struct obd_export *exp, const struct 
lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
 
-   rc = md_sync(tgt->ltd_exp, fid, request);
-   return rc;
+   return md_sync(tgt->ltd_exp, fid, request);
 }
 
 /**
@@ -2428,17 +2412,14 @@ static int lmv_read_page(struct obd_export *exp, struct 
md_op_data *op_data,
return rc;
 
if (unlikely(lsm)) {
-   rc = lmv_read_striped_page(exp, op_data, cb_op, offset, ppage);
-   return rc;
+   return lmv_read_striped_page(exp, op_data, cb_op, offset, 
ppage);
}
 
tgt = lmv_find_target(lmv, _data->op_fid1);
if (IS_ERR(tgt))
return