Skip to contentSkip to conversation

staging: lustre: llite: Remove else after goto

PATCH New Luis de Bethencourt 1 participant 3 messages Dec 6, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 staging: lustre: llite: Remove else after goto

If an "if" branch is terminated by a "goto", there's no need to have an "else" statement and an indented block of code.

Remove the "else" statement to simplify the code flow.

---

Hi,

The following patches remove unneeded 'else' after a 'goto' or 'return'. They are meant to just make the code more readable and aren't functional changes.

Thanks,
Luis

 drivers/staging/lustre/lustre/llite/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/llite/dir.c +2 -2
index 5b2e47c246f3..f5b67a4923e3 100644
@@ -1339,9 +1339,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 					       cmd == LL_IOC_MDC_GETINFO)) {
 				rc = 0;
 				goto skip_lmm;
-			} else {
-				goto out_req;
 			}
+
+			goto out_req;
 		}
 
 		if (cmd == IOC_MDC_GETFILESTRIPE ||
Signature · 1 line
2.15.1
#1 lore raw

PATCH 2/3 staging: lustre: llite: Remove redundant else keyword

There is no need to use 'else' if in main branch 'goto' is present.

---
 drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/llite_lib.c +3 -1
index 8666f1e81ade..e84719662edf 100644
@@ -236,7 +236,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
 				   "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n",
 				   md);
 		goto out;
-	} else if (err) {
+	}
+
+	if (err) {
 		CERROR("cannot connect to %s: rc = %d\n", md, err);
 		goto out;
 	}
Signature · 1 line
2.15.1
#2 lore raw

PATCH 3/3 staging: lustre: llite: Remove redundant else keyword

In reply to Luis de Bethencourt

There is no need to use 'else' if in main branch 'return' is present.

---
 drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/vvp_io.c +1 -1
index bfae98e82d6f..e7a4778e02e4 100644
@@ -699,7 +699,7 @@ static int vvp_io_read_start(const struct lu_env *env,
 	result = vvp_prep_size(env, obj, io, pos, tot, &exceed);
 	if (result != 0)
 		return result;
-	else if (exceed != 0)
+	if (exceed != 0)
 		goto out;
 
 	LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu,
Signature · 1 line
2.15.1