kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree
@ 2015-10-17 17:23 Julia Lawall
  2015-10-18  9:55 ` SF Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2015-10-17 17:23 UTC (permalink / raw)
  To: cocci

Adjust tests to compare against NULL, to match cases that explicitly make
that comparison.

Remove removal and re-addition of freeing functions.

Add position variable on usb_free_urb in the non-patch case.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 scripts/coccinelle/free/ifnullfree.cocci |   18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/scripts/coccinelle/free/ifnullfree.cocci b/scripts/coccinelle/free/ifnullfree.cocci
index a42d70b..d4a072d 100644
--- a/scripts/coccinelle/free/ifnullfree.cocci
+++ b/scripts/coccinelle/free/ifnullfree.cocci
@@ -16,19 +16,15 @@ virtual context
 @r2 depends on patch@
 expression E;
 @@
-- if (E)
+- if (E != NULL)
 (
--	kfree(E);
-+ kfree(E);
+  kfree(E);
 |
--	debugfs_remove(E);
-+ debugfs_remove(E);
+  debugfs_remove(E);
 |
--	debugfs_remove_recursive(E);
-+ debugfs_remove_recursive(E);
+  debugfs_remove_recursive(E);
 |
--	usb_free_urb(E);
-+ usb_free_urb(E);
+  usb_free_urb(E);
 )
 
 @r depends on context || report || org @
@@ -36,8 +32,8 @@ expression E;
 position p;
 @@
 
-* if (E)
-*	\(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E);
+* if (E != NULL)
+*	\(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb@p\)(E);
 
 @script:python depends on org@
 p << r.p;


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

* Re: [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree
  2015-10-17 17:23 [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree Julia Lawall
@ 2015-10-18  9:55 ` SF Markus Elfring
  2015-10-26 21:32   ` Michal Marek
  0 siblings, 1 reply; 4+ messages in thread
From: SF Markus Elfring @ 2015-10-18  9:55 UTC (permalink / raw)
  To: cocci

> Remove removal and re-addition of freeing functions.

I find such a wording confusing for a commit message.


> Add position variable on usb_free_urb in the non-patch case.

Is it interesting that this fix corresponds to a bug report from 2014-08-09?
https://lkml.org/lkml/2014/8/9/33
https://systeme.lip6.fr/pipermail/cocci/2014-August/001038.html


>  @r depends on context || report || org @
> @@ -36,8 +32,8 @@ expression E;
>  position p;
>  @@
>  
> -* if (E)
> -*	\(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E);
> +* if (E != NULL)
> +*	\(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb@p\)(E);

How do you think about to extend the shown function name pattern
also with suffixes like the following (besides "destroy")?
* put
* release
* unref
* unregister

Regards,
Markus

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

* Re: [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree
  2015-10-18  9:55 ` SF Markus Elfring
@ 2015-10-26 21:32   ` Michal Marek
  2015-10-26 21:36     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Marek @ 2015-10-26 21:32 UTC (permalink / raw)
  To: cocci

Dne 18.10.2015 v 11:55 SF Markus Elfring napsal(a):
>> Remove removal and re-addition of freeing functions.
> 
> I find such a wording confusing for a commit message.

It is also a bit confusing to use the same subject for two patches in a
series. How about

[PATCH 1/2] coccinelle: ifnullfree: Adjust tests to compare against NULL
[PATCH 2/2] coccinelle: ifnullfree: handle various destroy functions

?

Michal

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

* Re: [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree
  2015-10-26 21:32   ` Michal Marek
@ 2015-10-26 21:36     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2015-10-26 21:36 UTC (permalink / raw)
  To: cocci

On Mon, 26 Oct 2015, Michal Marek wrote:

> Dne 18.10.2015 v 11:55 SF Markus Elfring napsal(a):
> >> Remove removal and re-addition of freeing functions.
> > 
> > I find such a wording confusing for a commit message.
> 
> It is also a bit confusing to use the same subject for two patches in a
> series. How about
> 
> [PATCH 1/2] coccinelle: ifnullfree: Adjust tests to compare against NULL
> [PATCH 2/2] coccinelle: ifnullfree: handle various destroy functions

Sorry.  I'll send them again.

julia

> 
> ?
> 
> Michal
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2015-10-26 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-17 17:23 [PATCH 1/2] coccinelle: ifnullfree: improve and extend ifnullfree Julia Lawall
2015-10-18  9:55 ` SF Markus Elfring
2015-10-26 21:32   ` Michal Marek
2015-10-26 21:36     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).