Skip to contentSkip to conversation

coccinelle: ifnullfree: add vfree(), kvfree*() functions

PATCH Julia Lawall 1 participant 1 message Sep 2, 2020 1 message not in the archive Kernel janitors

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 34 lines · Markus Elfring

…

Quoted 6 lines

+++ b/scripts/coccinelle/free/ifnullfree.cocci

(quoted diff) +1 -0
@@ -20,8 +20,14 @@ expression E;
 - if (E != NULL)
 (
   kfree(E);
+|

Review expression E; · line 33

Quoted 10 lines
(quoted diff) +5 -0
+  kvfree(E);
 |
   kfree_sensitive(E);
+|
+  kvfree_sensitive(E, ...);
+|
+  vfree(E);
 |
   debugfs_remove(E);
 |

Would you ever get into the development mood to move the source code search specification “(E);” out of the SmPL disjunction (as it happened for the rule “r”)?

Quoted 10 lines
(quoted diff) +3 -2
@@ -42,9 +48,10 @@ position p;
 @@
 
 * if (E != NULL)
-*	\(kfree@p\|kfree_sensitive@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|
+*	\(kfree@p\|kvfree@p\|kfree_sensitive@p\|kvfree_sensitive@p\|vfree@p\|
+*         debugfs_remove@p\|debugfs_remove_recursive@p\|
 *         usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\|
-*         dma_pool_destroy@p\)(E);
+*         dma_pool_destroy@p\)(E, ...);

…

Quoted 4 lines

How do you think about to attach the position variable to the opening parenthesis instead of each function name?

+* dma_pool_destroy\)(@p E, ...);

While it probably impacts few people, this is a really bad idea for org mode, because org mode colors the thing that the position variable is attached to. Having the ( colored would not be very visible.

But even for report mode, this is probably not a good idea for the rare case where the function name and the argument list are on different lines.

julia

Quoted 7 lines

Would the number of function call parameters influence such SmPL code any more?

Regards,
Markus