[PATCH v2 01/71] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy

Mattias Rönnblom hofors at lysator.liu.se
Sat Mar 2 12:19:13 CET 2024


On 2024-03-01 18:14, Stephen Hemminger wrote:
> Rte_memcpy should not be used for the simple case of copying
> a fix size structure because it is slower and will hide problems
> from code analysis tools. Coverity, fortify and other analyzers
> special case memcpy().
> 
> Gcc (and Clang) are smart enough to inline copies which
> will be faster.
> 

Are you suggesting rte_memcpy() calls aren't inlined?

> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
>   devtools/cocci/rte_memcpy.cocci | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>   create mode 100644 devtools/cocci/rte_memcpy.cocci
> 
> diff --git a/devtools/cocci/rte_memcpy.cocci b/devtools/cocci/rte_memcpy.cocci
> new file mode 100644
> index 000000000000..fa1038fc066d
> --- /dev/null
> +++ b/devtools/cocci/rte_memcpy.cocci
> @@ -0,0 +1,11 @@
> +//
> +// rte_memcpy should not be used for simple fixed size structure
> +// because compiler's are smart enough to inline these.
> +//

What do you do in code where it's not known if the size will be constant 
or not?

> +@@
> +expression src, dst; constant size;
> +@@
> +(
> +- rte_memcpy(dst, src, size)
> ++ memcpy(dst, src, size)
> +)


More information about the dev mailing list