linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing.
@ 2018-10-17  0:09 Leonardo Brás
  2018-10-17  3:06 ` [Lkcamp] " Helen Koike
  0 siblings, 1 reply; 4+ messages in thread
From: Leonardo Brás @ 2018-10-17  0:09 UTC (permalink / raw)
  To: lkcamp
  Cc: Matthew Wilcox, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, x86, Masahiro Yamada,
	Michal Marek, linux-kernel, linux-kbuild

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

Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
---
 scripts/asn1_compiler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index c146020fc783..08bb6e5fd6ad 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -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)))
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Lkcamp] [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing.
  2018-10-17  0:09 [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing Leonardo Brás
@ 2018-10-17  3:06 ` Helen Koike
  2018-10-18  2:03   ` Leonardo Bras
  0 siblings, 1 reply; 4+ messages in thread
From: Helen Koike @ 2018-10-17  3:06 UTC (permalink / raw)
  To: Leonardo Brás, lkcamp
  Cc: x86, linux-kbuild, Matthew Wilcox, linux-kernel, Masahiro Yamada,
	Ingo Molnar, Borislav Petkov, Andy Lutomirski, H. Peter Anvin,
	Michal Marek, Thomas Gleixner

Hi Leonardo,

On 10/16/18 9:09 PM, Leonardo Brás wrote:
>     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.

> 
> Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
> ---
>  scripts/asn1_compiler.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
> index c146020fc783..08bb6e5fd6ad 100644
> --- a/scripts/asn1_compiler.c
> +++ b/scripts/asn1_compiler.c
> @@ -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 */

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

>  
> -			/* Handle numbers */
> -			if (isdigit(*p)) {
>  				/* Find the end of the number */
>  				q = p + 1;
>  				while (q < nl && (isdigit(*q)))
> 

Regards
Helen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Lkcamp] [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing.
  2018-10-17  3:06 ` [Lkcamp] " Helen Koike
@ 2018-10-18  2:03   ` Leonardo Bras
  2018-10-19  2:44     ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Leonardo Bras @ 2018-10-18  2:03 UTC (permalink / raw)
  To: helen
  Cc: lkcamp, x86, linux-kbuild, Matthew Wilcox, linux-kernel,
	Masahiro Yamada, Ingo Molnar, Borislav Petkov, Andy Lutomirski,
	H. Peter Anvin, Michal Marek, Thomas Gleixner

Hello Helen,

On Wed, Oct 17, 2018 at 12:06 AM Helen Koike <helen@koikeco.de> wrote:
>
> Hi Leonardo,
>
> On 10/16/18 9:09 PM, Leonardo Brás wrote:
> >     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.

>
> >
> > Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
> > ---
> >  scripts/asn1_compiler.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
> > index c146020fc783..08bb6e5fd6ad 100644
> > --- a/scripts/asn1_compiler.c
> > +++ b/scripts/asn1_compiler.c
> > @@ -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 */
>
> 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.

>
> >
> > -                     /* 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Lkcamp] [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing.
  2018-10-18  2:03   ` Leonardo Bras
@ 2018-10-19  2:44     ` Masahiro Yamada
  0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-10-19  2:44 UTC (permalink / raw)
  To: Leonardo Brás
  Cc: helen, lkcamp, X86 ML, Linux Kbuild mailing list, Matthew Wilcox,
	Linux Kernel Mailing List, Ingo Molnar, Borislav Petkov,
	Andy Lutomirski, H. Peter Anvin, Michal Marek, Thomas Gleixner

On Thu, Oct 18, 2018 at 11:04 AM Leonardo Bras <leobras.c@gmail.com> wrote:
>
> Hello Helen,
>
> On Wed, Oct 17, 2018 at 12:06 AM Helen Koike <helen@koikeco.de> wrote:
> >
> > Hi Leonardo,
> >
> > On 10/16/18 9:09 PM, Leonardo Brás wrote:
> > >     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.
>
> >
> > >
> > > Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
> > > ---
> > >  scripts/asn1_compiler.c | 7 +++----
> > >  1 file changed, 3 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
> > > index c146020fc783..08bb6e5fd6ad 100644
> > > --- a/scripts/asn1_compiler.c
> > > +++ b/scripts/asn1_compiler.c
> > > @@ -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 */
> >
> > 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.


I drop v1 from my tree.

Please send v2.


> >
> > >
> > > -                     /* 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



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-19  2:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17  0:09 [PATCH 3/4] kbuild: Removes unnecessary shadowed local variable and optimize testing Leonardo Brás
2018-10-17  3:06 ` [Lkcamp] " Helen Koike
2018-10-18  2:03   ` Leonardo Bras
2018-10-19  2:44     ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).