* [Cocci] [bug-cocci] deadcode detection
@ 2017-05-13 12:40 Akihiro Sagawa
2017-05-13 18:46 ` Michael Stefaniuc
0 siblings, 1 reply; 2+ messages in thread
From: Akihiro Sagawa @ 2017-05-13 12:40 UTC (permalink / raw)
To: cocci
Hello, julia and folks,
I found the following source code (deadcode.c) isn't updated by semantic
patch (deadcode.cooci) with spatch version 1.0.4.
[deadcode.c]
int deadcode(const char* c)
{
do {
if (c) {
foo(*c);
break;
}
break;
} while (0);
}
[deadcode.cocci]
@@
expression E;
@@
-foo(E)
+bar(E)
With `--debug` option, spatch shows `FLOW: deadcode detected: File
"./deadcode.c", line 3`. But, I think there is no deadcode. There is
just a redundant `break` at the end of the loop. In my opinion, although
it's a bit strange, `break` keyword is harmless like the last `break`
keyword in the last label block in a `switch` statement, e.g.
switch (*c) {
case 'x': x++; break;
case 'y': y++; break;
default:
warn("Invalid input: %c\n", *c);
break; // <-- this is harmless, not a deadcode
}
Practical issue is seen in Wine 2.7's dlls/shlwapi/url.c from line 707
to 874. I tried to replace isalnum() to isalnumW(), a WCHAR version of
isalnum(),@line 812. However, spatch missed it without warnings. You
can see https://source.winehq.org/source/dlls/shlwapi/url.c?v=wine-2.7#0707
for the source code.
I'll be happy if spatch finds out the above case and makes a patch for it.
Deadcode.{c,cocci} are available in the Github pull requests.
Thanks in advance,
Akihiro Sagawa
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cocci] [bug-cocci] deadcode detection
2017-05-13 12:40 [Cocci] [bug-cocci] deadcode detection Akihiro Sagawa
@ 2017-05-13 18:46 ` Michael Stefaniuc
0 siblings, 0 replies; 2+ messages in thread
From: Michael Stefaniuc @ 2017-05-13 18:46 UTC (permalink / raw)
To: cocci
On 05/13/2017 02:40 PM, Akihiro Sagawa wrote:
> Hello, julia and folks,
> I found the following source code (deadcode.c) isn't updated by semantic
> patch (deadcode.cooci) with spatch version 1.0.4.
This fails also with coccinelle-1.0.6-111-g8996213 which is the latest
one from git.
bye
michael
>
> [deadcode.c]
> int deadcode(const char* c)
> {
> do {
> if (c) {
> foo(*c);
> break;
> }
> break;
> } while (0);
> }
>
> [deadcode.cocci]
> @@
> expression E;
> @@
> -foo(E)
> +bar(E)
>
> With `--debug` option, spatch shows `FLOW: deadcode detected: File
> "./deadcode.c", line 3`. But, I think there is no deadcode. There is
> just a redundant `break` at the end of the loop. In my opinion, although
> it's a bit strange, `break` keyword is harmless like the last `break`
> keyword in the last label block in a `switch` statement, e.g.
>
> switch (*c) {
> case 'x': x++; break;
> case 'y': y++; break;
> default:
> warn("Invalid input: %c\n", *c);
> break; // <-- this is harmless, not a deadcode
> }
>
> Practical issue is seen in Wine 2.7's dlls/shlwapi/url.c from line 707
> to 874. I tried to replace isalnum() to isalnumW(), a WCHAR version of
> isalnum(), at line 812. However, spatch missed it without warnings. You
> can see https://source.winehq.org/source/dlls/shlwapi/url.c?v=wine-2.7#0707
> for the source code.
>
> I'll be happy if spatch finds out the above case and makes a patch for it.
> Deadcode.{c,cocci} are available in the Github pull requests.
>
> Thanks in advance,
> Akihiro Sagawa
>
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-13 18:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-13 12:40 [Cocci] [bug-cocci] deadcode detection Akihiro Sagawa
2017-05-13 18:46 ` Michael Stefaniuc
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.