net/tap: fix build with GCC 11
Reproduced with '--buildtype=debugoptimized' config,
compiler version: gcc (GCC) 12.0.0
20210509 (experimental)
There are multiple build errors, like:
In file included from ../drivers/net/tap/tap_flow.c:13:
In function ‘rte_jhash_2hashes’,
inlined from ‘rte_jhash’ at ../lib/hash/rte_jhash.h:284:2,
inlined from ‘tap_flow_set_handle’ at
../drivers/net/tap/tap_flow.c:1306:12,
inlined from ‘rss_enable’ at ../drivers/net/tap/tap_flow.c:1909:3,
inlined from ‘priv_flow_process’ at
../drivers/net/tap/tap_flow.c:1228:11:
../lib/hash/rte_jhash.h:238:9:
warning: ‘flow’ may be used uninitialized [-Wmaybe-uninitialized]
238 | __rte_jhash_2hashes(key, length, pc, pb, 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/tap/tap_flow.c: In function ‘priv_flow_process’:
../lib/hash/rte_jhash.h:81:1: note: by argument 1 of type ‘const void *’
to ‘__rte_jhash_2hashes.constprop’ declared here
81 | __rte_jhash_2hashes(const void *key, uint32_t length, uint32_t *pc,
| ^~~~~~~~~~~~~~~~~~~
../drivers/net/tap/tap_flow.c:1028:1: note: ‘flow’ declared here
1028 | priv_flow_process(struct pmd_internals *pmd,
| ^~~~~~~~~~~~~~~~~
Fix strict aliasing rule by using union.
Bugzilla ID: 690
Fixes:
de96fe68ae95 ("net/tap: add basic flow API patterns and actions")
Cc: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>