lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Jun 2014 09:24:01 -0700
From:	Joe Perches <joe@...ches.com>
To:	Ivo Sieben <meltedpianoman@...il.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andy Whitcroft <apw@...onical.com>
Subject: Re: [PATCH] [checkpatch.pl] ctx_statement_block #if/#else/#endif fix

On Tue, 2014-06-10 at 08:19 +0200, Ivo Sieben wrote:
> Andy, Joe,
> 
> What do you think about my patchset below?

Andy wrote that originally and I think he should respond.

> Regards,
> Ivo Sieben
> 
> 2014-05-15 16:43 GMT+02:00 Ivo Sieben <meltedpianoman@...il.com>:
> > When picking up a complete statement block #if/#else/#endif prepocesor
> > boundaries are taken into account by pushing current level & type on a stack.
> > But on an #else the level was read from stack again (without actually popping it
> > from stack) causing the statement block to end too early on the next ';'.
> > Fixed this.
> >
> > For example the following code:
> >
> >         if (!test()) {
> >  #ifdef NEVER
> >                 foo();
> >                 bar();
> >  #else
> >                 bar();
> >                 foo();
> >  #endif
> >         }
> >
> > Results in statement block:
> >
> >  STATEMENT<+    if (!test()) {
> >  +#ifdef NEVER
> >  +              foo();
> >  +              bar();
> >  +#else
> >  +              bar();>
> >  CONDITION<+    if (!test())>
> >
> > While you would expect:
> >
> >  STATEMENT<+    if (!test()) {
> >  +#ifdef NEVER
> >  +              foo();
> >  +              bar();
> >  +#else
> >  +              bar();
> >  +              foo();
> >  +#endif
> >  +       }>
> >  CONDITION<+     if (!test())>
> >
> > Signed-off-by: Ivo Sieben <meltedpianoman@...il.com>
> > ---
> >
> > Request for comments:
> > I think I fixed a problem here that I encountered while I was working on another
> > changeset in which I check the statement block after a condition.
> > Somehow the statement block did not contain everything I expected.
> >
> >  scripts/checkpatch.pl |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 34eb216..e7bca89 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -878,7 +878,7 @@ sub ctx_statement_block {
> >                 if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) {
> >                         push(@stack, [ $type, $level ]);
> >                 } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) {
> > -                       ($type, $level) = @{$stack[$#stack - 1]};
> > +                       # no changes to stack: type & level remain the same
> >                 } elsif ($remainder =~ /^#\s*endif\b/) {
> >                         ($type, $level) = @{pop(@stack)};
> >                 }
> > @@ -1050,7 +1050,7 @@ sub ctx_block_get {
> >                 if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
> >                         push(@stack, $level);
> >                 } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
> > -                       $level = $stack[$#stack - 1];
> > +                       # no changes to stack: type & level remain the same
> >                 } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
> >                         $level = pop(@stack);
> >                 }
> > --
> > 1.7.9.5
> >



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ