]> xenbits.xensource.com Git - libvirt.git/commit
Add ATTRIBUTE_FALLTHROUGH for switch cases without break
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 22 Feb 2017 17:37:09 +0000 (17:37 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 23 Feb 2017 10:11:16 +0000 (10:11 +0000)
commit5d84f5961b8e28e802f600bb2d2c6903e219092e
treefa7dca5f1308336b97b1177e65e58d23564d82be
parentfb52faf8fa4b7d981a7d76b2751c7bad4747d51c
Add ATTRIBUTE_FALLTHROUGH for switch cases without break

In GCC 7 there is a new warning triggered when a switch
case has a conditional statement (eg if ... else...) and
some of the code paths fallthrough to the next switch
statement. e.g.

conf/domain_conf.c: In function 'virDomainChrEquals':
conf/domain_conf.c:14926:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (src->targetTypeAttr != tgt->targetTypeAttr)
            ^
conf/domain_conf.c:14928:5: note: here
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
     ^~~~
conf/domain_conf.c: In function 'virDomainChrDefFormat':
conf/domain_conf.c:22143:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (def->targetTypeAttr) {
            ^
conf/domain_conf.c:22151:5: note: here
     default:
     ^~~~~~~

GCC introduced a __attribute__((fallthrough)) to let you
indicate that this is intentionale behaviour rather than
a bug.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/conf/domain_conf.c
src/conf/network_conf.c
src/internal.h
src/lxc/lxc_container.c
src/network/bridge_driver.c
tools/virsh-edit.c