[ipxe-devel] Unable to pass through GCC 7 build for Werror=implicit-fallthrough

Liang Yan lyan at suse.com
Tue Mar 28 21:39:53 UTC 2017


Hi, All

When we building our qemu with GCC 7, we hit this error:

[  528s] drivers/net/igbvf/igbvf_vf.c: In function 'igbvf_promisc_set_vf':
[  528s] drivers/net/igbvf/igbvf_vf.c:359:10: error: this statement may fall through [-Werror=implicit-fallthrough=]
[  528s]    msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
[  528s] drivers/net/igbvf/igbvf_vf.c:360:2: note: here
[  528s]   case e1000_promisc_unicast:
[  528s]   ^~~~
[  528s]   [BUILD] bin/phantom.o
[  528s]   [BUILD] bin/rtl8180_grf5101.o
[  528s] cc1: all warnings being treated as errors
[  528s] make[1]: *** [Makefile.housekeeping:856: bin/igbvf_vf.o] Error 1
[  528s] make[1]: *** Waiting for unfinished jobs....
[  528s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/qemu-2.7.0/roms/ipxe/src'
[  528s] make: *** [Makefile:133: build-pxe-roms] Error 2

(https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:Gcc7/qemu/standard/x86_64)


Source code(v1.0.0):
	switch (type) {
	case e1000_promisc_multicast:
		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
		break;
	case e1000_promisc_enabled:
		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
	case e1000_promisc_unicast:
		msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
	case e1000_promisc_disabled:
		break;
	default:
		return -E1000_ERR_MAC_INIT;
	}



That is because GCC7 enables -Wimplicit-fallthrough now.

According to https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wimplicit-fallthrough

    -Wimplicit-fallthrough is the same as -Wimplicit-fallthrough=3 and -Wno-implicit-fallthrough is the same as -Wimplicit-fallthrough=0.

Looks there are two options to fix it:
 
1. add /* fall through*/ comment in source code, which follows level 3 rule.

2. add -Wno-implicit-fallthrough in Makefile cflags


Could anyone give me some opinions about which fix should be better or is there other options to handle it? 
Thanks.


Also found a pending patch followed option 2 above,
https://www.mail-archive.com/ipxe-devel@lists.ipxe.org/msg05329.html



Best,
Liang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20170328/f8373d8b/attachment.htm>


More information about the ipxe-devel mailing list