net: fix aliasing in checksum computation
authorGeorg Sauthoff <mail@gms.tf>
Sun, 17 Oct 2021 20:37:18 +0000 (22:37 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 Oct 2021 16:15:58 +0000 (18:15 +0200)
commit24f1955d1ecd13a3c261a328c72932115732825e
tree3d99828486792e70e62d3c4a3a0fcb82c9480930
parent54fe0cf1b8682684ba8a8778669483867343798e
net: fix aliasing in checksum computation

That means a superfluous cast is removed and aliasing through a uint8_t
pointer is eliminated. NB: The C standard specifies that a unsigned char
pointer may alias while the C standard doesn't include such requirement
for uint8_t pointers.

Also simplified the loop since a modern C compiler can speed up (i.e.
auto-vectorize) it in a similar way. For example, GCC auto-vectorizes it
for Haswell using AVX registers while halving the number of instructions
in the generated code.

Fixes: 6006818cfb26 ("net: new checksum functions")
Fixes: e079655c41fb ("net: fix build with gcc 4.4.7 and strict aliasing")
Cc: stable@dpdk.org
Signed-off-by: Georg Sauthoff <mail@gms.tf>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/net/rte_ip.h