Fix alignment errors
This fixes -Wcast-align errors when compiled with WARNS=6.
Submitted by: Ján Sučan <sucanjan@gmail.com>
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential D21217
ping6: Fix alignment errors jansucan on Aug 11 2019, 2:52 PM. Authored by Tags None Referenced Files
Subscribers
Details
Fix alignment errors This fixes -Wcast-align errors when compiled with WARNS=6. Submitted by: Ján Sučan <sucanjan@gmail.com>
Diff Detail
Event Timeline
Comment Actions I combined this revision with D21260 and ran a "make tinderbox". The build failed with GCC. cc1: warnings being treated as errors /home/asomers/freebsd/base/head/sbin/ping6/ping6.c: In function 'pr_nodeaddr': /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:2105: warning: 'ttl' may be used uninitialized in this function And here's with GCC 8: /home/asomers/freebsd/base/head/sbin/ping6/ping6.c: In function 'main': /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:963:15: warning: variable 'types' set but not used [-Wunused-but-set-variable] const char *types[1]; ^~~~~ /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:1171:4: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] memset(cm, 0, CONTROLLEN); ^~~~~~ /home/asomers/freebsd/base/head/sbin/ping6/ping6.c: In function 'capdns_setup': /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:2816:6: warning: variable 'families' set but not used [-Wunused-but-set-variable] int families[1]; ^~~~~~~~ /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:2815:14: warning: variable 'types' set but not used [-Wunused-but-set-variable] const char *types[2]; ^~~~~ At top level: /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:69:19: warning: 'copyright' defined but not used [-Wunused-const-variable=] static const char copyright[] = ^~~~~~~~~ In file included from /home/asomers/freebsd/base/head/sys/net/if.h:47, from /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:111: /home/asomers/freebsd/base/head/sbin/ping6/ping6.c: In function 'main': /home/asomers/freebsd/base/head/sys/sys/time.h:380:35: error: 'intvl.tv_nsec' may be used uninitialized in this function [-Werror=maybe-uninitialized] (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ ^ /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:298:24: note: 'intvl.tv_nsec' was declared here struct timespec last, intvl; ^~~~~ In file included from /home/asomers/freebsd/base/head/sys/net/if.h:47, from /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:111: /home/asomers/freebsd/base/head/sys/sys/time.h:379:33: error: 'intvl.tv_sec' may be used uninitialized in this function [-Werror=maybe-uninitialized] (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ ^ /home/asomers/freebsd/base/head/sbin/ping6/ping6.c:298:24: note: 'intvl.tv_sec' was declared here struct timespec last, intvl; ^~~~~ cc1: all warnings being treated as errors --- ping6.o --- *** [ping6.o] Error code 1 The easiest way to reproduce the full failure with GCC8 (easy, but not fast), is to install the riscv64-xtoolchain-gcc package and then do env CROSS_TOOLCHAIN=riscv64-gcc TARGET=riscv TARGET_ARCH=riscv64 make -jwhatever buildworld. |