[RFC,2/4] devtools/cocci: add script to find unnecessary malloc type

Message ID 20240425182738.4771-3-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series malloc type argument cleanup (part 1) |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger April 25, 2024, 6:23 p.m. UTC
  The malloc type argument is unused and should be NULL.
This script finds and fixes those places.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/malloc-type.cocci | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 devtools/cocci/malloc-type.cocci
  

Patch

diff --git a/devtools/cocci/malloc-type.cocci b/devtools/cocci/malloc-type.cocci
new file mode 100644
index 0000000000..d1101927e0
--- /dev/null
+++ b/devtools/cocci/malloc-type.cocci
@@ -0,0 +1,27 @@ 
+//
+// The allocation name field in malloc routines was never
+// implemented and should be NULL
+//
+@@
+expression T != NULL;
+expression num, socket, size, align;
+@@
+(
+- rte_malloc(T, size, align)
++ rte_malloc(NULL, size, align)
+|
+- rte_zmalloc(T, size, align)
++ rte_zmalloc(NULL,  size, align)
+|
+- rte_calloc(T, num, size, align)
++ rte_calloc(NULL, num, size, align)
+|
+- rte_malloc_socket(T, size, align, socket)
++ rte_malloc_socket(NULL, size, align, socket)
+|
+- rte_zmalloc_socket(T, size, align, socket)
++ rte_zmalloc_socket(NULL, size, align, socket)
+|
+- rte_calloc_socket(T, num, size, align, socket)
++ rte_calloc_socket(NULL, num, size, align, socket)
+)