summaryrefslogtreecommitdiff
path: root/contrib/coccinelle/array.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/coccinelle/array.cocci')
-rw-r--r--contrib/coccinelle/array.cocci27
1 files changed, 22 insertions, 5 deletions
diff --git a/contrib/coccinelle/array.cocci b/contrib/coccinelle/array.cocci
index 4ba98b7eaf..01586821dc 100644
--- a/contrib/coccinelle/array.cocci
+++ b/contrib/coccinelle/array.cocci
@@ -4,7 +4,7 @@ T *dst;
T *src;
expression n;
@@
-- memcpy(dst, src, n * sizeof(*dst));
+- memcpy(dst, src, (n) * sizeof(*dst));
+ COPY_ARRAY(dst, src, n);
@@
@@ -13,7 +13,7 @@ T *dst;
T *src;
expression n;
@@
-- memcpy(dst, src, n * sizeof(*src));
+- memcpy(dst, src, (n) * sizeof(*src));
+ COPY_ARRAY(dst, src, n);
@@
@@ -22,15 +22,32 @@ T *dst;
T *src;
expression n;
@@
-- memcpy(dst, src, n * sizeof(T));
+- memcpy(dst, src, (n) * sizeof(T));
+ COPY_ARRAY(dst, src, n);
@@
type T;
+T *dst;
+T *src;
+expression n;
+@@
+(
+- memmove(dst, src, (n) * sizeof(*dst));
++ MOVE_ARRAY(dst, src, n);
+|
+- memmove(dst, src, (n) * sizeof(*src));
++ MOVE_ARRAY(dst, src, n);
+|
+- memmove(dst, src, (n) * sizeof(T));
++ MOVE_ARRAY(dst, src, n);
+)
+
+@@
+type T;
T *ptr;
expression n;
@@
-- ptr = xmalloc(n * sizeof(*ptr));
+- ptr = xmalloc((n) * sizeof(*ptr));
+ ALLOC_ARRAY(ptr, n);
@@
@@ -38,5 +55,5 @@ type T;
T *ptr;
expression n;
@@
-- ptr = xmalloc(n * sizeof(T));
+- ptr = xmalloc((n) * sizeof(T));
+ ALLOC_ARRAY(ptr, n);