All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] how to debug missing match?
@ 2014-12-21  9:53 Wolfram Sang
  2014-12-21 10:20 ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2014-12-21  9:53 UTC (permalink / raw)
  To: cocci

Hi

with linux kernel v3.18-rc1 and spatch version 1.0.0-rc22 with Python
support and with PCRE support from Debian:

~/Kernel/linux$ spatch -D report --sp-file scripts/coccinelle/api/platform_no_drv_owner.cocci arch/arm/mach-exynos/*.c

produces:

arch/arm/mach-exynos/pmu.c:994:3-8: No need to set .owner here. The core will do it.
diff = 
--- arch/arm/mach-exynos/pmu.c
+++ /tmp/cocci-output-25796-7e6ab9-pmu.c
@@ -991,7 +991,6 @@ static int exynos_pmu_probe(struct platf
 static struct platform_driver exynos_pmu_driver = {
 	.driver  = {
 		.name   = "exynos-pmu",
-		.owner	= THIS_MODULE,
 		.of_match_table = exynos_pmu_of_device_ids,
 	},
 	.probe = exynos_pmu_probe,

But:

~/Kernel/linux$ spatch -D report --sp-file scripts/coccinelle/api/platform_no_drv_owner.cocci drivers/macintosh/*.c

does not result in anything although three drivers should match IMO with
the same pattern as the pmu driver above. Both use
platform_driver_register() and both have the .owner field set.

drivers/macintosh/windfarm_pm112.c
drivers/macintosh/windfarm_pm72.c
drivers/macintosh/windfarm_rm31.c

How can I debug why the match does not occur?

Thanks,

   Wolfram

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141221/7b223621/attachment.asc>

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

* [Cocci] how to debug missing match?
  2014-12-21  9:53 [Cocci] how to debug missing match? Wolfram Sang
@ 2014-12-21 10:20 ` Wolfram Sang
  2014-12-21 10:39   ` Julia Lawall
  2014-12-21 11:15   ` Julia Lawall
  0 siblings, 2 replies; 6+ messages in thread
From: Wolfram Sang @ 2014-12-21 10:20 UTC (permalink / raw)
  To: cocci


> does not result in anything although three drivers should match IMO with
> the same pattern as the pmu driver above. Both use
> platform_driver_register() and both have the .owner field set.
> 
> drivers/macintosh/windfarm_pm112.c
> drivers/macintosh/windfarm_pm72.c
> drivers/macintosh/windfarm_rm31.c
> 
> How can I debug why the match does not occur?

So, I found "--verbose-parsing" to be helpful which gives me:

parse error 
 = File "drivers/macintosh/windfarm_pm112.c", line 685, column 4, charpos = 17702
    around = 'nr_cores', whole content = 		++nr_cores;

which basically means that it can't handle for_each_node_by_type()?

bad: 	for_each_node_by_type(cpu, "cpu")
BAD:!!!!! 		++nr_cores;

But neither "--include include/linux/of.h" nor "--recursive-includes"
does help the case for me?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141221/6a5b7940/attachment.asc>

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

* [Cocci] how to debug missing match?
  2014-12-21 10:20 ` Wolfram Sang
@ 2014-12-21 10:39   ` Julia Lawall
  2014-12-21 10:51     ` Wolfram Sang
  2014-12-21 11:15   ` Julia Lawall
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2014-12-21 10:39 UTC (permalink / raw)
  To: cocci

On Sun, 21 Dec 2014, Wolfram Sang wrote:

> 
> > does not result in anything although three drivers should match IMO with
> > the same pattern as the pmu driver above. Both use
> > platform_driver_register() and both have the .owner field set.
> > 
> > drivers/macintosh/windfarm_pm112.c
> > drivers/macintosh/windfarm_pm72.c
> > drivers/macintosh/windfarm_rm31.c
> > 
> > How can I debug why the match does not occur?
> 
> So, I found "--verbose-parsing" to be helpful which gives me:
> 
> parse error 
>  = File "drivers/macintosh/windfarm_pm112.c", line 685, column 4, charpos = 17702
>     around = 'nr_cores', whole content = 		++nr_cores;
> 
> which basically means that it can't handle for_each_node_by_type()?
> 
> bad: 	for_each_node_by_type(cpu, "cpu")
> BAD:!!!!! 		++nr_cores;
> 
> But neither "--include include/linux/of.h" nor "--recursive-includes"
> does help the case for me?

It is not surprising that adding more includes doesn't help.  But I would 
have thought that for_each_node_by_type, as it begins with for, would be 
something that it would pick up on.  I will take a look.

julia

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

* [Cocci] how to debug missing match?
  2014-12-21 10:39   ` Julia Lawall
@ 2014-12-21 10:51     ` Wolfram Sang
  2014-12-21 10:55       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2014-12-21 10:51 UTC (permalink / raw)
  To: cocci

On Sun, Dec 21, 2014 at 11:39:14AM +0100, Julia Lawall wrote:
> On Sun, 21 Dec 2014, Wolfram Sang wrote:
> 
> > 
> > > does not result in anything although three drivers should match IMO with
> > > the same pattern as the pmu driver above. Both use
> > > platform_driver_register() and both have the .owner field set.
> > > 
> > > drivers/macintosh/windfarm_pm112.c
> > > drivers/macintosh/windfarm_pm72.c
> > > drivers/macintosh/windfarm_rm31.c
> > > 
> > > How can I debug why the match does not occur?
> > 
> > So, I found "--verbose-parsing" to be helpful which gives me:
> > 
> > parse error 
> >  = File "drivers/macintosh/windfarm_pm112.c", line 685, column 4, charpos = 17702
> >     around = 'nr_cores', whole content = 		++nr_cores;
> > 
> > which basically means that it can't handle for_each_node_by_type()?
> > 
> > bad: 	for_each_node_by_type(cpu, "cpu")
> > BAD:!!!!! 		++nr_cores;
> > 
> > But neither "--include include/linux/of.h" nor "--recursive-includes"
> > does help the case for me?
> 
> It is not surprising that adding more includes doesn't help.  But I would 
> have thought that for_each_node_by_type, as it begins with for, would be 
> something that it would pick up on.  I will take a look.

How does coccinelle work with such constructs? I'd think that replacing
that #define with the actual for()-construct is much more reliable than
an assumption like "it starts with 'for' so it is probably...' :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20141221/81a1a83a/attachment.asc>

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

* [Cocci] how to debug missing match?
  2014-12-21 10:51     ` Wolfram Sang
@ 2014-12-21 10:55       ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2014-12-21 10:55 UTC (permalink / raw)
  To: cocci



On Sun, 21 Dec 2014, Wolfram Sang wrote:

> On Sun, Dec 21, 2014 at 11:39:14AM +0100, Julia Lawall wrote:
> > On Sun, 21 Dec 2014, Wolfram Sang wrote:
> > 
> > > 
> > > > does not result in anything although three drivers should match IMO with
> > > > the same pattern as the pmu driver above. Both use
> > > > platform_driver_register() and both have the .owner field set.
> > > > 
> > > > drivers/macintosh/windfarm_pm112.c
> > > > drivers/macintosh/windfarm_pm72.c
> > > > drivers/macintosh/windfarm_rm31.c
> > > > 
> > > > How can I debug why the match does not occur?
> > > 
> > > So, I found "--verbose-parsing" to be helpful which gives me:
> > > 
> > > parse error 
> > >  = File "drivers/macintosh/windfarm_pm112.c", line 685, column 4, charpos = 17702
> > >     around = 'nr_cores', whole content = 		++nr_cores;
> > > 
> > > which basically means that it can't handle for_each_node_by_type()?
> > > 
> > > bad: 	for_each_node_by_type(cpu, "cpu")
> > > BAD:!!!!! 		++nr_cores;
> > > 
> > > But neither "--include include/linux/of.h" nor "--recursive-includes"
> > > does help the case for me?
> > 
> > It is not surprising that adding more includes doesn't help.  But I would 
> > have thought that for_each_node_by_type, as it begins with for, would be 
> > something that it would pick up on.  I will take a look.
> 
> How does coccinelle work with such constructs? I'd think that replacing
> that #define with the actual for()-construct is much more reliable than
> an assumption like "it starts with 'for' so it is probably...' :)

When you replace things with other things, then you can't transform them.  
So it tries to guess.  It is possible that the guess only happens when the 
body of the loop has {}...

julia

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

* [Cocci] how to debug missing match?
  2014-12-21 10:20 ` Wolfram Sang
  2014-12-21 10:39   ` Julia Lawall
@ 2014-12-21 11:15   ` Julia Lawall
  1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2014-12-21 11:15 UTC (permalink / raw)
  To: cocci

On Sun, 21 Dec 2014, Wolfram Sang wrote:

> 
> > does not result in anything although three drivers should match IMO with
> > the same pattern as the pmu driver above. Both use
> > platform_driver_register() and both have the .owner field set.
> > 
> > drivers/macintosh/windfarm_pm112.c
> > drivers/macintosh/windfarm_pm72.c
> > drivers/macintosh/windfarm_rm31.c
> > 
> > How can I debug why the match does not occur?
> 
> So, I found "--verbose-parsing" to be helpful which gives me:
> 
> parse error 
>  = File "drivers/macintosh/windfarm_pm112.c", line 685, column 4, charpos = 17702
>     around = 'nr_cores', whole content = 		++nr_cores;
> 
> which basically means that it can't handle for_each_node_by_type()?
> 
> bad: 	for_each_node_by_type(cpu, "cpu")
> BAD:!!!!! 		++nr_cores;
> 
> But neither "--include include/linux/of.h" nor "--recursive-includes"
> does help the case for me?

Here is a patch (band-aid...).  It was made on rc23, but it should apply 
to rc22 just as well.

julia

diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml
index 2a665cd..58b7a14 100644
--- a/parsing_c/parsing_hacks.ml
+++ b/parsing_c/parsing_hacks.ml
@@ -324,6 +324,8 @@ let rec is_really_foreach xs =
     | TCPar _::Tfor _::xs -> true, xs
     | TCPar _::Tswitch _::xs -> true, xs
     | TCPar _::Treturn _::xs -> true, xs
+    | TCPar _::TInc _::xs -> true, xs
+    | TCPar _::TDec _::xs -> true, xs
 
 
     | TCPar _::xs -> false, xs

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

end of thread, other threads:[~2014-12-21 11:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-21  9:53 [Cocci] how to debug missing match? Wolfram Sang
2014-12-21 10:20 ` Wolfram Sang
2014-12-21 10:39   ` Julia Lawall
2014-12-21 10:51     ` Wolfram Sang
2014-12-21 10:55       ` Julia Lawall
2014-12-21 11:15   ` Julia Lawall

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.