New script to find RTE_DIM should be used. Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- devtools/cocci/rte-dim.cocci | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 devtools/cocci/rte-dim.cocci
diff --git a/devtools/cocci/rte-dim.cocci b/devtools/cocci/rte-dim.cocci new file mode 100644 index 0000000000..e7fcadec98 --- /dev/null +++ b/devtools/cocci/rte-dim.cocci @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Use RTE_DIM macro instead of dividing sizeof array with sizeof an elmemnt +// +// Based of Linux kernela array_size.cocci +// +@@ +type T; +T[] E; +@@ +( +| +- (sizeof(E)/sizeof(E[...])) ++ RTE_DIM(E) +| +- (sizeof(E)/sizeof(*E)) ++ RTE_DIM(E) +| +- (sizeof(E)/sizeof(T)) ++ RTE_DIM(E) +| +- RTE_DIM((E)) ++ RTE_DIM(E) +) -- 2.43.0