avf: fix gcc compiling warning on Arm 59/30459/4
authorJieqiang Wang <jieqiang.wang@arm.com>
Tue, 15 Dec 2020 13:20:15 +0000 (13:20 +0000)
committerDamjan Marion <dmarion@me.com>
Sat, 19 Dec 2020 09:59:25 +0000 (09:59 +0000)
commit3daf1f5d3a5918564ae2acdd748b24acaef5bce0
tree84b497fe557a5e9e165f1b281648dcec669d0fb5
parentee6b0e2904ee5123198ffe26a7de3019e16332b2
avf: fix gcc compiling warning on Arm

Initializing struct avf_ip6_psh by {0} using gcc with O2 optimize option
will trigger the -Werror=maybe-uninitialized compiling warning on Arm
because gcc compiler will think some members of the struct avf_ip6_psh
may not be initialized, which probably is a false positive in this case.
The compiling error log is shown as below. Avoid this compiling warning
by explicitly declaring the IPv6 src and dst ip in avf_ip6_psh as
ip6_address_t.

ccache /usr/lib/ccache/gcc-10 -DHAVE_FCNTL64 -DHAVE_GETCPU -DHAVE_MEMFD_CREATE -I/home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src -I. -Iinclude -I/home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/plugins -Iplugins -Iplugins/avf -Wno-address-of-packed-member -g -fPIC -Werror -Wall -march=armv8-a+crc  -O2 -fstack-protector -DFORTIFY_SOURCE=2 -fno-common  -fPIC   -DCLIB_MARCH_VARIANT=cortexa72 -march=armv8-a+crc+crypto -mtune=cortex-a72 -DCLIB_N_PREFETCHES=6 -MD -MT plugins/avf/CMakeFiles/avf_plugin_cortexa72.dir/output.c.o -MF plugins/avf/CMakeFiles/avf_plugin_cortexa72.dir/output.c.o.d -o plugins/avf/CMakeFiles/avf_plugin_cortexa72.dir/output.c.o   -c /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/plugins/avf/output.c
In file included from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/vector_funcs.h:41,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/vector.h:196,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/string.h:48,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/mem.h:49,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/vec.h:42,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/format.h:44,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/elf.h:41,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/elf_clib.h:41,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vlib/vlib.h:44,
                 from /home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/plugins/avf/output.c:18:
/home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/plugins/avf/output.c: In function ‘avf_device_class_tx_fn_cortexa72’:
/home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/vppinfra/byte_order.h:59:10: error: ‘*((void *)&psh+32)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   59 |   return __builtin_bswap16 (x);
      |          ^~~~~~~~~~~~~~~~~~~~~
/home/snowball/tasks/test_vpp_build/test-patch-9/vpp/src/plugins/avf/output.c:115:23: note: ‘*((void *)&psh+32)’ was declared here
  115 |    struct avf_ip6_psh psh = { 0 };
      |                       ^~~

Type: fix

Change-Id: I2684b101b07823dfacc4a56cc29d152828d0cf37
Signed-off-by: Jieqiang Wang <jieqiang.wang@arm.com>
src/plugins/avf/output.c