Skip to contentSkip to conversation

Staging: lustre: lmv_obd: Remove redundant if-statement.

PATCH In review Sandhya Bankar 1 participant 2 messages Sep 18, 2016 – Sep 19, 2016 1 message not in the archive Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: lustre: lmv_obd: Remove redundant if-statement.

Remove redundant if-statement.

---
Changes in v2:
* Correcting the file permission issue.

 drivers/staging/lustre/lustre/lmv/lmv_obd.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -4
index 5783359..0713e55 100644
@@ -949,10 +949,8 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
 
 	rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group,
 				   &kcd, sizeof(kcd));
-	if (rc) {
-		if (filp)
-			fput(filp);
-	}
+	if (rc && filp)
+		fput(filp);
 
 	return rc;
 }
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Thanks Andreas ! I will send a patch with your suggestion.

Quoted 40 lines · Andreas

Review

Quoted 11 lines · Sandhya Bankar

Remove redundant if-statement.

---
Changes in v2:
* Correcting the file permission issue.
drivers/staging/lustre/lustre/lmv/lmv_obd.c | 6 ++----

1 files changed, 2 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/lustre/lustre/lmv/lmv_obd.c

drivers/staging/lustre/lustre/lmv/lmv_obd.c static int lmv_hsm_ct_register(struct lmv_obd *lmv,

Quoted 4 lines

index 5783359..0713e55 100644

drivers/staging/lustre/lustre/lmv/lmv_obd.c +0 -0
@@ -949,10 +949,8 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv,

unsigned int cmd, int len,

drivers/staging/lustre/lustre/lmv/lmv_obd.c static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, · line 953

Quoted 9 lines
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -4
      rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group,
                                 &kcd, sizeof(kcd));
-     if (rc) {
-             if (filp)
-                     fput(filp);
-     }
+     if (rc && filp)
+             fput(filp);

In fact, the check for filp != NULL is also redundant. A few lines earlier:

        /* at least one registration done, with no failure */
        filp = fget(lk->lk_wfd);
        if (!filp)
                return -EBADF;

so it cannot be NULL at this point, and the check should just be removed.

Cheers, Andreas