Skip to contentSkip to conversation

kbuild: Removes unnecessary shadowed local variable and optimize testing.

PATCH Superseded Leonardo Brás 3 participants 4 messages Oct 17, 2018 – Oct 19, 2018 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 kbuild: Removes unnecessary shadowed local variable and optimize testing.

Removes an unnecessary shadowed local variable (start). Optimize test of isdigit:
- If isalpha returns true, isdigit will return false, so no need to test.

---
 scripts/asn1_compiler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
scripts/asn1_compiler.c +3 -4
index c146020fc783..08bb6e5fd6ad 100644
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end)
 
 			/* Handle string tokens */
 			if (isalpha(*p)) {
-				const char **dir, *start = p;
+				const char **dir;
 
 				/* Can be a directive, type name or element
 				 * name.  Find the end of the name.
@@ -454,10 +454,9 @@ static void tokenise(char *buffer, char *end)
 
 				tokens[tix++].token_type = TOKEN_TYPE_NAME;
 				continue;
-			}
+			} else if (isdigit(*p)) {
+				/* Handle numbers */
 
-			/* Handle numbers */
-			if (isdigit(*p)) {
 				/* Find the end of the number */
 				q = p + 1;
 				while (q < nl && (isdigit(*q)))
Signature · 1 line
2.19.1
#1 lore raw

Hi Leonardo,

Quoted 3 lines · Leonardo Brás

Removes an unnecessary shadowed local variable (start). Optimize test of isdigit:
- If isalpha returns true, isdigit will return false, so no need to test.

This patch does two different things, it should be in two separated patches.

Quoted 20 lines
---
 scripts/asn1_compiler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
scripts/asn1_compiler.c +1 -1
index c146020fc783..08bb6e5fd6ad 100644
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end)
 
 			/* Handle string tokens */
 			if (isalpha(*p)) {
-				const char **dir, *start = p;
+				const char **dir;
 
 				/* Can be a directive, type name or element
 				 * name.  Find the end of the name.

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end) · line 458

Quoted 6 lines
scripts/asn1_compiler.c +2 -1
@@ -454,10 +454,9 @@ static void tokenise(char *buffer, char *end)
 
 				tokens[tix++].token_type = TOKEN_TYPE_NAME;
 				continue;
-			}
+			} else if (isdigit(*p)) {
+				/* Handle numbers */

Actually you can't do that, p is being altered in the first if statement.

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end)

Quoted 7 lines
scripts/asn1_compiler.c +0 -2
-			/* Handle numbers */
-			if (isdigit(*p)) {
 				/* Find the end of the number */
 				q = p + 1;
 				while (q < nl && (isdigit(*q)))
 

Regards
Helen

#2 lore raw

Hello Helen,

Quoted 9 lines · Helen Koike

Hi Leonardo,

Quoted 3 lines · Leonardo Brás

Removes an unnecessary shadowed local variable (start). Optimize test of isdigit:
- If isalpha returns true, isdigit will return false, so no need to test.

This patch does two different things, it should be in two separated patches.

Sure, no problem.

Quoted 22 lines
Quoted 22 lines
---
 scripts/asn1_compiler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
scripts/asn1_compiler.c +1 -1
index c146020fc783..08bb6e5fd6ad 100644
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end)
 
                      /* Handle string tokens */
                      if (isalpha(*p)) {
-                             const char **dir, *start = p;
+                             const char **dir;
 
                              /* Can be a directive, type name or element
                               * name.  Find the end of the name.
@@ -454,10 +454,9 @@ static void tokenise(char *buffer, char *end)
 
Quoted 7 lines

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end) · line 458

Quoted 5 lines
scripts/asn1_compiler.c +2 -1
                              tokens[tix++].token_type = TOKEN_TYPE_NAME;
                              continue;
-                     }
+                     } else if (isdigit(*p)) {
+                             /* Handle numbers */

Actually you can't do that, p is being altered in the first if statement.

Yeah, you are right. I will remove this logic for v2.

Quoted 11 lines

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end)

Quoted 8 lines
scripts/asn1_compiler.c +0 -2
-                     /* Handle numbers */
-                     if (isdigit(*p)) {
                              /* Find the end of the number */
                              q = p + 1;
                              while (q < nl && (isdigit(*q)))
 

Regards
Helen

Thanks!

Leonardo Brás

#3 lore raw
Quoted 45 lines · Leonardo Bras

Hello Helen,

Quoted 9 lines · Helen Koike

Hi Leonardo,

Quoted 3 lines · Leonardo Brás

Removes an unnecessary shadowed local variable (start). Optimize test of isdigit:
- If isalpha returns true, isdigit will return false, so no need to test.

This patch does two different things, it should be in two separated patches.

Sure, no problem.

Quoted 22 lines
Quoted 22 lines
---
 scripts/asn1_compiler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
scripts/asn1_compiler.c +1 -1
index c146020fc783..08bb6e5fd6ad 100644
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end)
 
                      /* Handle string tokens */
                      if (isalpha(*p)) {
-                             const char **dir, *start = p;
+                             const char **dir;
 
                              /* Can be a directive, type name or element
                               * name.  Find the end of the name.
@@ -454,10 +454,9 @@ static void tokenise(char *buffer, char *end)
 
Quoted 7 lines

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end) · line 458

Quoted 5 lines
scripts/asn1_compiler.c +2 -1
                              tokens[tix++].token_type = TOKEN_TYPE_NAME;
                              continue;
-                     }
+                     } else if (isdigit(*p)) {
+                             /* Handle numbers */

Actually you can't do that, p is being altered in the first if statement.

Quoted 1 line

Yeah, you are right. I will remove this logic for v2.

I drop v1 from my tree.

Please send v2.

Quoted 15 lines
Quoted 11 lines

scripts/asn1_compiler.c static void tokenise(char *buffer, char *end)

Quoted 8 lines
scripts/asn1_compiler.c +0 -2
-                     /* Handle numbers */
-                     if (isdigit(*p)) {
                              /* Find the end of the number */
                              q = p + 1;
                              while (q < nl && (isdigit(*q)))
 

Regards
Helen

Thanks!

Leonardo Brás

Signature · 2 lines
Best Regards
Masahiro Yamada