All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coccinelle: adjust the confidence of fen.cocci
@ 2021-12-14 12:19 Qing Wang
  2021-12-14 13:03 ` Julia Lawall
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Qing Wang @ 2021-12-14 12:19 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Nicolas Palix, Michal Marek, cocci,
	linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

We scan by coccinelle according to the confidence value, then check for 
potential problems. But the accuracy of this cocci is very low,
the scan results are all wrong.

So, lower its confidence to low.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 scripts/coccinelle/iterators/fen.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
index b69f966..7b71207
--- a/scripts/coccinelle/iterators/fen.cocci
+++ b/scripts/coccinelle/iterators/fen.cocci
@@ -2,7 +2,7 @@
 /// These iterators only exit normally when the loop cursor is NULL, so there
 /// is no point to call of_node_put on the final value.
 ///
-// Confidence: High
+// Confidence: Low
 // Copyright: (C) 2010-2012 Nicolas Palix.
 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
-- 
2.7.4


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

* Re: [PATCH] coccinelle: adjust the confidence of fen.cocci
  2021-12-14 12:19 [PATCH] coccinelle: adjust the confidence of fen.cocci Qing Wang
@ 2021-12-14 13:03 ` Julia Lawall
       [not found] ` <AMYAywCFE0lG630WMxnU84qe.9.1639487006485.Hmail.wangqing@vivo.com.@PGFscGluZS5ERUIuMi4yMi4zOTQuMjExMjE0MTQwMjI0MC4yNjIzQGhhZHJpZW4+>
  2021-12-26 10:40 ` Julia Lawall
  2 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2021-12-14 13:03 UTC (permalink / raw)
  To: Qing Wang; +Cc: Nicolas Palix, cocci, linux-kernel



On Tue, 14 Dec 2021, Qing Wang wrote:

> From: Wang Qing <wangqing@vivo.com>
>
> We scan by coccinelle according to the confidence value, then check for
> potential problems. But the accuracy of this cocci is very low,
> the scan results are all wrong.

Can you give some examples of cases where the results are wrong?

thanks,
julia

>
> So, lower its confidence to low.
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>  scripts/coccinelle/iterators/fen.cocci | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
> index b69f966..7b71207
> --- a/scripts/coccinelle/iterators/fen.cocci
> +++ b/scripts/coccinelle/iterators/fen.cocci
> @@ -2,7 +2,7 @@
>  /// These iterators only exit normally when the loop cursor is NULL, so there
>  /// is no point to call of_node_put on the final value.
>  ///
> -// Confidence: High
> +// Confidence: Low
>  // Copyright: (C) 2010-2012 Nicolas Palix.
>  // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
>  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
> --
> 2.7.4
>
>

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

* 回复: [PATCH] coccinelle: adjust the confidence of fen.cocci
       [not found] ` <AMYAywCFE0lG630WMxnU84qe.9.1639487006485.Hmail.wangqing@vivo.com.@PGFscGluZS5ERUIuMi4yMi4zOTQuMjExMjE0MTQwMjI0MC4yNjIzQGhhZHJpZW4+>
@ 2021-12-15  2:54   ` 王擎
  2021-12-15  9:36     ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: 王擎 @ 2021-12-15  2:54 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Nicolas Palix, cocci, linux-kernel


>> From: Wang Qing <wangqing@vivo.com>
>>
>> We scan by coccinelle according to the confidence value, then check for
>> potential problems. But the accuracy of this cocci is very low,
>> the scan results are all wrong.
>
>Can you give some examples of cases where the results are wrong?
>
For example:
for_each_node_by_name(np, "global-utilities") {
	if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
		rstcr = of_iomap(np, 0) + 0xb0;
		if (!rstcr) {
			printk (KERN_ERR "Error: reset control "
					"register not mapped!\n");
		} else {
			register_restart_handler(&restart_handler);
		}
		break; // break here
	}
}

of_node_put(np);  // Is there any problem here?

And there are many others:
>>>>>>>>>>>>>>>>>  iterators/fen.cocci <<<<<<<<<<<<<<<<<<<<
drivers/edac/cell_edac.c:165:1-12: ERROR: of_node_put not needed after iterator on line 137
arch/powerpc/platforms/powermac/udbg_adb.c:204:1-12: ERROR: of_node_put not needed after iterator on line 195
arch/powerpc/platforms/cell/iommu.c:744:1-12: ERROR: of_node_put not needed after iterator on line 737
arch/powerpc/kexec/file_load_64.c:1037:1-12: ERROR: of_node_put not needed after iterator on line 1023
drivers/cpufreq/pmac64-cpufreq.c:640:1-12: ERROR: of_node_put not needed after iterator on line 501
arch/powerpc/kexec/ranges.c:271:1-12: ERROR: of_node_put not needed after iterator on line 248
arch/powerpc/platforms/chrp/setup.c:479:1-12: ERROR: of_node_put not needed after iterator on line 470
arch/powerpc/platforms/chrp/setup.c:524:1-12: ERROR: of_node_put not needed after iterator on line 521
arch/powerpc/platforms/4xx/uic.c:293:1-12: ERROR: of_node_put not needed after iterator on line 280
arch/powerpc/mm/numa.c:1317:1-12: ERROR: of_node_put not needed after iterator on line 1289
sound/ppc/pmac.c:970:2-13: ERROR: of_node_put not needed after iterator on line 951
drivers/tty/serial/cpm_uart/cpm_uart_core.c:1336:1-12: ERROR: of_node_put not needed after iterator on line 1316
arch/powerpc/sysdev/fsl_soc.c:190:1-12: ERROR: of_node_put not needed after iterator on line 177

Thanks,
Qing

>thanks,
>julia
>
>>
>> So, lower its confidence to low.
>>
>> Signed-off-by: Wang Qing <wangqing@vivo.com>
>> ---
>>  scripts/coccinelle/iterators/fen.cocci | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
>> index b69f966..7b71207
>> --- a/scripts/coccinelle/iterators/fen.cocci
>> +++ b/scripts/coccinelle/iterators/fen.cocci
>> @@ -2,7 +2,7 @@
>>  /// These iterators only exit normally when the loop cursor is NULL, so there
>>  /// is no point to call of_node_put on the final value.
>>  ///
>> -// Confidence: High
>> +// Confidence: Low
>>  // Copyright: (C) 2010-2012 Nicolas Palix.
>>  // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
>>  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
>> --
>> 2.7.4
>>
>>

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

* Re: 回复: [PATCH] coccinelle: adjust the confidence of fen.cocci
  2021-12-15  2:54   ` 回复: " 王擎
@ 2021-12-15  9:36     ` Julia Lawall
  0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2021-12-15  9:36 UTC (permalink / raw)
  To: 王擎; +Cc: Nicolas Palix, cocci, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3496 bytes --]



On Wed, 15 Dec 2021, 王擎 wrote:

>
> >> From: Wang Qing <wangqing@vivo.com>
> >>
> >> We scan by coccinelle according to the confidence value, then check for
> >> potential problems. But the accuracy of this cocci is very low,
> >> the scan results are all wrong.
> >
> >Can you give some examples of cases where the results are wrong?
> >
> For example:
> for_each_node_by_name(np, "global-utilities") {
> 	if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
> 		rstcr = of_iomap(np, 0) + 0xb0;
> 		if (!rstcr) {
> 			printk (KERN_ERR "Error: reset control "
> 					"register not mapped!\n");
> 		} else {
> 			register_restart_handler(&restart_handler);
> 		}
> 		break; // break here
> 	}
> }
>
> of_node_put(np);  // Is there any problem here?

This looks quite strange.  If the loop exits normally, then there is a put
on something on which there was no get.  Is the value NULL in tihs case,
and so the of_node_put does nothing?  I guess that then there is no
problem, but it's not clear that the code is very nice either.

But I think that the real of_node_put problems are covered by another
rule, so we can drop this one, as you suggested.

julia

>
> And there are many others:
> >>>>>>>>>>>>>>>>>  iterators/fen.cocci <<<<<<<<<<<<<<<<<<<<
> drivers/edac/cell_edac.c:165:1-12: ERROR: of_node_put not needed after iterator on line 137
> arch/powerpc/platforms/powermac/udbg_adb.c:204:1-12: ERROR: of_node_put not needed after iterator on line 195
> arch/powerpc/platforms/cell/iommu.c:744:1-12: ERROR: of_node_put not needed after iterator on line 737
> arch/powerpc/kexec/file_load_64.c:1037:1-12: ERROR: of_node_put not needed after iterator on line 1023
> drivers/cpufreq/pmac64-cpufreq.c:640:1-12: ERROR: of_node_put not needed after iterator on line 501
> arch/powerpc/kexec/ranges.c:271:1-12: ERROR: of_node_put not needed after iterator on line 248
> arch/powerpc/platforms/chrp/setup.c:479:1-12: ERROR: of_node_put not needed after iterator on line 470
> arch/powerpc/platforms/chrp/setup.c:524:1-12: ERROR: of_node_put not needed after iterator on line 521
> arch/powerpc/platforms/4xx/uic.c:293:1-12: ERROR: of_node_put not needed after iterator on line 280
> arch/powerpc/mm/numa.c:1317:1-12: ERROR: of_node_put not needed after iterator on line 1289
> sound/ppc/pmac.c:970:2-13: ERROR: of_node_put not needed after iterator on line 951
> drivers/tty/serial/cpm_uart/cpm_uart_core.c:1336:1-12: ERROR: of_node_put not needed after iterator on line 1316
> arch/powerpc/sysdev/fsl_soc.c:190:1-12: ERROR: of_node_put not needed after iterator on line 177
>
> Thanks,
> Qing
>
> >thanks,
> >julia
> >
> >>
> >> So, lower its confidence to low.
> >>
> >> Signed-off-by: Wang Qing <wangqing@vivo.com>
> >> ---
> >>  scripts/coccinelle/iterators/fen.cocci | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
> >> index b69f966..7b71207
> >> --- a/scripts/coccinelle/iterators/fen.cocci
> >> +++ b/scripts/coccinelle/iterators/fen.cocci
> >> @@ -2,7 +2,7 @@
> >>  /// These iterators only exit normally when the loop cursor is NULL, so there
> >>  /// is no point to call of_node_put on the final value.
> >>  ///
> >> -// Confidence: High
> >> +// Confidence: Low
> >>  // Copyright: (C) 2010-2012 Nicolas Palix.
> >>  // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
> >>  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
> >> --
> >> 2.7.4
> >>
> >>

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

* Re: [PATCH] coccinelle: adjust the confidence of fen.cocci
  2021-12-14 12:19 [PATCH] coccinelle: adjust the confidence of fen.cocci Qing Wang
  2021-12-14 13:03 ` Julia Lawall
       [not found] ` <AMYAywCFE0lG630WMxnU84qe.9.1639487006485.Hmail.wangqing@vivo.com.@PGFscGluZS5ERUIuMi4yMi4zOTQuMjExMjE0MTQwMjI0MC4yNjIzQGhhZHJpZW4+>
@ 2021-12-26 10:40 ` Julia Lawall
  2 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2021-12-26 10:40 UTC (permalink / raw)
  To: Qing Wang; +Cc: Nicolas Palix, cocci, linux-kernel



On Tue, 14 Dec 2021, Qing Wang wrote:

> From: Wang Qing <wangqing@vivo.com>
>
> We scan by coccinelle according to the confidence value, then check for
> potential problems. But the accuracy of this cocci is very low,
> the scan results are all wrong.
>
> So, lower its confidence to low.

I have made a patch to delete this.

julia

>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>  scripts/coccinelle/iterators/fen.cocci | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
> index b69f966..7b71207
> --- a/scripts/coccinelle/iterators/fen.cocci
> +++ b/scripts/coccinelle/iterators/fen.cocci
> @@ -2,7 +2,7 @@
>  /// These iterators only exit normally when the loop cursor is NULL, so there
>  /// is no point to call of_node_put on the final value.
>  ///
> -// Confidence: High
> +// Confidence: Low
>  // Copyright: (C) 2010-2012 Nicolas Palix.
>  // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
>  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
> --
> 2.7.4
>
>

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

end of thread, other threads:[~2021-12-26 10:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 12:19 [PATCH] coccinelle: adjust the confidence of fen.cocci Qing Wang
2021-12-14 13:03 ` Julia Lawall
     [not found] ` <AMYAywCFE0lG630WMxnU84qe.9.1639487006485.Hmail.wangqing@vivo.com.@PGFscGluZS5ERUIuMi4yMi4zOTQuMjExMjE0MTQwMjI0MC4yNjIzQGhhZHJpZW4+>
2021-12-15  2:54   ` 回复: " 王擎
2021-12-15  9:36     ` Julia Lawall
2021-12-26 10:40 ` 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.