Skip to contentSkip to conversation

staging: lustre: lustre: lclient: Removed the else statement

PATCH In review Anjali Menon 3 participants 3 messages Sep 17, 2015 – Sep 19, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lustre: lclient: Removed the else statement

Removed the else statement along with some unwanted brackets to fix the following coding style warning detected by checkpatch.

WARNING: else is not generally useful after a break or return

---
 drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/lclient/lcommon_cl.c +7 -9
index ab6cb41..23092fc 100644
@@ -836,7 +836,7 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
 					*exceed = 1;
 			}
 			return result;
-		} else {
+		}
 			/*
 			 * region is within kms and, hence, within real file
 			 * size (A). We need to increase i_size to cover the
@@ -847,14 +847,12 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
 			 * which will always be >= the kms value here.
 			 * b=11081
 			 */
-			if (cl_isize_read(inode) < kms) {
-				cl_isize_write_nolock(inode, kms);
-				CDEBUG(D_VFSTRACE,
-				       DFID" updating i_size %llu\n",
-				       PFID(lu_object_fid(&obj->co_lu)),
-				       (__u64)cl_isize_read(inode));
-
-			}
+		if (cl_isize_read(inode) < kms) {
+			cl_isize_write_nolock(inode, kms);
+			CDEBUG(D_VFSTRACE,
+				DFID" updating i_size %llu\n",
+				PFID(lu_object_fid(&obj->co_lu)),
+				(__u64)cl_isize_read(inode));
 		}
 	}
 	ccc_object_size_unlock(obj);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 35 lines · Anjali Menon

Removed the else statement along with some unwanted brackets to fix the following coding style warning detected by checkpatch.

WARNING: else is not generally useful after a break or return

---
  drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 16 +++++++---------
  1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/lclient/lcommon_cl.c +1 -8
index ab6cb41..23092fc 100644
@@ -836,7 +836,7 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
  					*exceed = 1;
  			}
  			return result;
-		} else {
+		}
  			/*
  			 * region is within kms and, hence, within real file
  			 * size (A). We need to increase i_size to cover the
@@ -847,14 +847,12 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
  			 * which will always be >= the kms value here.
  			 * b=11081
  			 */
-			if (cl_isize_read(inode) < kms) {
-				cl_isize_write_nolock(inode, kms);
-				CDEBUG(D_VFSTRACE,
-				       DFID" updating i_size %llu\n",
-				       PFID(lu_object_fid(&obj->co_lu)),
-				       (__u64)cl_isize_read(inode));
-

drivers/staging/lustre/lustre/lclient/lcommon_cl.c int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, · line 858

Quoted 10 lines
drivers/staging/lustre/lustre/lclient/lcommon_cl.c +6 -1
-			}
+		if (cl_isize_read(inode) < kms) {
+			cl_isize_write_nolock(inode, kms);
+			CDEBUG(D_VFSTRACE,
+				DFID" updating i_size %llu\n",
+				PFID(lu_object_fid(&obj->co_lu)),
+				(__u64)cl_isize_read(inode));
  		}
  	}
  	ccc_object_size_unlock(obj);

I think the "else" bracket is needed for when the statement "pos > kms" is not true, but it might work since there's only two choices tested. The checkpatch.pl error can bring notices like that, what's important is the context of the code. It might be there to increase readability since it is kind of an obvious situation.
That's just my analysis.

-JA

maintainer
#2 lore raw
In reply to Anjali Menon
Quoted 16 lines · Anjali Menon

Removed the else statement along with some unwanted brackets to fix the following coding style warning detected by checkpatch.

WARNING: else is not generally useful after a break or return

---
 drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/lclient/lcommon_cl.c +0 -0
index ab6cb41..23092fc 100644

drivers/staging/lustre/lustre/lclient/lcommon_cl.c int ccc_prep_size(const struct lu_env *env, struct cl_object *obj, · line 842

Quoted 8 lines
drivers/staging/lustre/lustre/lclient/lcommon_cl.c +1 -1
@@ -836,7 +836,7 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
 					*exceed = 1;
 			}
 			return result;
-		} else {
+		}
 			/*
 			 * region is within kms and, hence, within real file
 			 * size (A). We need to increase i_size to cover the

This change isn't correct, look at how the code now looks :(