Skip to contentSkip to conversation

ocfs2: Optimize bad declarations and redundant assignment

PATCH New Norton.Zhu 3 participants 3 messages Nov 16, 2015 OCFS2

lore
Share & tools
lore

Norton.Zhu

author
#0 lore raw

PATCH 1/1 ocfs2: Optimize bad declarations and redundant assignment

In ocfs2_parse_options,
a)it's better to declare variables(small size) outside of while loop; b)'option' will be set by match_int, 'option = 0;' makes no sense, if match_int failed,
it just goto bail and return.

---
 fs/ocfs2/super.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/ocfs2/super.c +2 -6
index 403c566..8a6b48f 100644
@@ -1278,6 +1278,8 @@ static int ocfs2_parse_options(struct super_block *sb,
 	int status, user_stack = 0;
 	char *p;
 	u32 tmp;
+	int token, option;
+	substring_t args[MAX_OPT_ARGS];
 
 	trace_ocfs2_parse_options(is_remount, options ? options : "(none)");
 
@@ -1296,9 +1298,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 	}
 
 	while ((p = strsep(&options, ",")) != NULL) {
-		int token, option;
-		substring_t args[MAX_OPT_ARGS];
-
 		if (!*p)
 			continue;
 
@@ -1356,7 +1355,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->atime_quantum = option;
 			break;
 		case Opt_slot:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
@@ -1365,7 +1363,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->slot = (s16)option;
 			break;
 		case Opt_commit:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
@@ -1377,7 +1374,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 			mopt->commit_interval = HZ * option;
 			break;
 		case Opt_localalloc:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
Signature · 1 line
1.8.4.3
#1 lore raw

PATCH 1/1 ocfs2: Optimize bad declarations and redundant assignment

Quoted 6 lines · Norton.Zhu

In ocfs2_parse_options,
a)it's better to declare variables(small size) outside of while loop; b)'option' will be set by match_int, 'option = 0;' makes no sense, if match_int failed,
it just goto bail and return.

Quoted 52 lines
---
 fs/ocfs2/super.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/ocfs2/super.c +2 -6
index 403c566..8a6b48f 100644
@@ -1278,6 +1278,8 @@ static int ocfs2_parse_options(struct super_block *sb,
 	int status, user_stack = 0;
 	char *p;
 	u32 tmp;
+	int token, option;
+	substring_t args[MAX_OPT_ARGS];
 
 	trace_ocfs2_parse_options(is_remount, options ? options : "(none)");
 
@@ -1296,9 +1298,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 	}
 
 	while ((p = strsep(&options, ",")) != NULL) {
-		int token, option;
-		substring_t args[MAX_OPT_ARGS];
-
 		if (!*p)
 			continue;
 
@@ -1356,7 +1355,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->atime_quantum = option;
 			break;
 		case Opt_slot:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
@@ -1365,7 +1363,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->slot = (s16)option;
 			break;
 		case Opt_commit:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
@@ -1377,7 +1374,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 			mopt->commit_interval = HZ * option;
 			break;
 		case Opt_localalloc:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
#2 lore raw

PATCH 1/1 ocfs2: Optimize bad declarations and redundant assignment

Thanks a lot.
Gang

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 3 lines · Norton.Zhu

In ocfs2_parse_options,
a)it's better to declare variables(small size) outside of while loop; b)'option' will be set by match_int, 'option = 0;' makes no sense, if

match_int failed,

Quoted 3 lines

it just goto bail and return.

Quoted 60 lines
Quoted 46 lines
---
 fs/ocfs2/super.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/ocfs2/super.c +2 -5
index 403c566..8a6b48f 100644
@@ -1278,6 +1278,8 @@ static int ocfs2_parse_options(struct super_block *sb,
 	int status, user_stack = 0;
 	char *p;
 	u32 tmp;
+	int token, option;
+	substring_t args[MAX_OPT_ARGS];
 
 	trace_ocfs2_parse_options(is_remount, options ? options : "(none)");
 
@@ -1296,9 +1298,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 	}
 
 	while ((p = strsep(&options, ",")) != NULL) {
-		int token, option;
-		substring_t args[MAX_OPT_ARGS];
-
 		if (!*p)
 			continue;
 
@@ -1356,7 +1355,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->atime_quantum = option;
 			break;
 		case Opt_slot:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;
@@ -1365,7 +1363,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 				mopt->slot = (s16)option;
 			break;
 		case Opt_commit:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;

fs/ocfs2/super.c static int ocfs2_parse_options(struct super_block *sb, · line 1379

Quoted 7 lines
fs/ocfs2/super.c +0 -1
@@ -1377,7 +1374,6 @@ static int ocfs2_parse_options(struct super_block *sb,
 			mopt->commit_interval = HZ * option;
 			break;
 		case Opt_localalloc:
-			option = 0;
 			if (match_int(&args[0], &option)) {
 				status = 0;
 				goto bail;

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel