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]
Message-ID: <CA+MoWDr0JT0T-0ZUDsqceuXKbjW_mavS9t6HGkFR4dz2XUygWg@mail.gmail.com>
Date:	Sat, 8 Dec 2012 16:13:47 -0200
From:	Peter Senna Tschudin <peter.senna@...il.com>
To:	Joe Perches <joe@...ches.com>
Cc:	mmarek@...e.cz, Julia Lawall <Julia.Lawall@...6.fr>,
	Gilles Muller <Gilles.Muller@...6.fr>,
	Nicolas Palix <nicolas.palix@...g.fr>, cocci@...teme.lip6.fr,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scripts/coccinelle/misc/semicolon.cocci: Add unneeded
 semicolon test

On Sat, Dec 8, 2012 at 3:45 PM, Joe Perches <joe@...ches.com> wrote:
> On Sat, 2012-12-08 at 15:34 -0200, Peter Senna Tschudin wrote:
>> This semantic patch looks for semicolons that can be removed without
>> changing the semantics of the code. The confidence is moderate
>> because there are some false positives on cases like:
>>
>> b/drivers/mmc/host/cb710-mmc.c:589
>>                 break;
>>         case MMC_POWER_UP:
>>         default:
>> -               /* ignore */;
>>         }
> []
>> diff --git a/scripts/coccinelle/misc/semicolon.cocci b/scripts/coccinelle/misc/semicolon.cocci
> []
>> +@r1@
>> +statement S;
>> +position p1;
>> +position p != {r_default.p, r_case.p};
>> +identifier label;
>> +@@
>> +(
>> +label:;
>> +|
>> +S@p1;@p
>> +)
>> +
>
> I believe this also fails on this case:
>
>         void some_func(...)
>         {
>                 ...
>                 if (foo)
>                         goto exit;
>                 ...
>
>         exit:
>                 ;
>         }
>
> where gcc needs a semicolon after a label before a function exit.

No it does not fail. This issue is switch/case specific. See how I've tested:

$ cat /tmp/test.c
void some_func(void){
        int *foo;
        if (foo)
        goto exit;

exit:
;
}

void few_func (void){
        int a;
        switch (a){
                case 1:
                        a=1;
                        break;
                case 2:
                default:
                        ;
        }
}

void main (void)
{
        int a;
        some_func();
        few_func();
}


$ spatch -D patch scripts/coccinelle/misc/semicolon.cocci /tmp/test.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: /tmp/test.c
diff =
--- /tmp/test.c
+++ /tmp/cocci-output-2570-defed8-test.c
@@ -15,7 +15,6 @@ void few_func (void){
  break;
  case 2:
  default:
- ;
  }
 }



>



--
Peter
--
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