Prefer using simple structure assignment instead of memcpy. Using a structure assignment preserves type information and compiler checks types already.
Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- devtools/cocci/struct-assign.cocci | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 devtools/cocci/struct-assign.cocci diff --git a/devtools/cocci/struct-assign.cocci b/devtools/cocci/struct-assign.cocci new file mode 100644 index 0000000000..052ebf3340 --- /dev/null +++ b/devtools/cocci/struct-assign.cocci @@ -0,0 +1,15 @@ +// +// prefer structure assignment over memcpy +// +@@ +type T; +T *SRCP; +T *DSTP; +@@ +( +- rte_memcpy(DSTP, SRCP, sizeof(T)) ++ *DSTP = *SRCP +| +- memcpy(DSTP, SRCP, sizeof(T)) ++ *DSTP = *SRCP +) -- 2.47.2