This started off as a simple fix to deal with gcc8. After shearing a few
hundred yaks, it is a now a 42 patch series :-)
The crux of the issue is/was that gcc8 reports various problems wrt
fallthrough for some switch statements. These were indeed bugs in
libvirt which the first patch fixes. What this highlighted, however,
was that relying on only listing valid enum constant names in switch
case statements is unsafe. Nothing at all prevents you from assigning
an invalid integer value to a variable that is treated as an enum.
Thus to be safe we should have a default: for every switch. Adding
this causes us to loose the warnings about missing enum constants
though, so we must turn on -Wswitch-enum. To turn that on though,
we need to fix up various switch() statements that missed enum
values but had a default. After going to all that trouble it then
adds the default: to all remaining switches.
In doing this I found a reasonable number of bugs, where we would
call virXXXXXToString() methods with a _LAST constant - this is
not right as the _LAST constant can't be converted to a string as
it is a sentinal value only. So these were all fixed along the
way. At the same time various switches were improved such that
the value being switched on was cast to an enum type, to let the
compiler report missing enum cases.
A big cleanup but the code should be more robust against future
mistakes like the one fixed in patch 01.
There's a lot of patches here, but they're mostly independant of
each other so we can push them incrementally as they're reviewed,
so don't feel a need to review everything in one go !
Daniel P. Berrangé (42):
conf: add enum constants for default controller models
util: handle missing switch enum cases
conf: handle missing switch enum cases
esx: handle missing switch enum cases
hyperv: handle missing switch enum cases
libxl: handle missing switch enum cases
lxc: handle missing switch enum cases
nwfilter: handle missing switch enum cases
qemu: handle missing switch enum cases
rpc: handle missing switch enum cases
security: handle missing switch enum cases
xen: handle missing switch enum cases
tools: handle missing switch enum cases
m4: enforce that all enum cases are listed in switch statements
m4: disable gcc8 -Wcast-function-type warnings from -Wextra
util: add default: case to all switch statements
conf: add default: case to all switch statements
cpu: add default: case to all switch statements
secret: add default: case to all switch statements
xen: add default: case to all switch statements
locking: add default: case to all switch statements
test: add default: case to all switch statements
remote: add default: case to all switch statements
openvz: add default: case to all switch statements
security: add default: case to all switch statements
rpc: add default: case to all switch statements
vbox: add default: case to all switch statements
libxl: add default: case to all switch statements
qemu: add default: case to all switch statements
lxc: add default: case to all switch statements
uml: add default: case to all switch statements
bhyve: add default: case to all switch statements
network: add default: case to all switch statements
interface: add default: case to all switch statements
storage: add default: case to all switch statements
nodedev: add default: case to all switch statements
nwfilter: add default: case to all switch statements
daemon: add default: case to all switch statements
tests: add default: case to all switch statements
tools: add default: case to all switch statements
examples: add default: case to all switch statements
m4: enable the -Wswitch-default warning flag
daemon/libvirtd.c | 4 +-
daemon/remote.c | 4 +
examples/object-events/event-test.c | 24 ++
m4/virt-compile-warnings.m4 | 11 +-
po/POTFILES.in | 1 +
src/bhyve/bhyve_command.c | 12 +-
src/conf/device_conf.c | 4 +-
src/conf/domain_addr.c | 15 +-
src/conf/domain_audit.c | 5 +
src/conf/domain_conf.c | 514 ++++++++++++++++++++++++------
src/conf/domain_conf.h | 4 +
src/conf/domain_event.c | 1 +
src/conf/interface_conf.c | 21 +-
src/conf/netdev_bandwidth_conf.h | 4 +-
src/conf/network_conf.c | 8 +-
src/conf/network_event.c | 1 +
src/conf/node_device_conf.c | 27 +-
src/conf/node_device_event.c | 1 +
src/conf/nwfilter_conf.c | 33 +-
src/conf/nwfilter_params.c | 14 +
src/conf/secret_event.c | 1 +
src/conf/storage_event.c | 1 +
src/conf/virnodedeviceobj.c | 1 +
src/conf/virstorageobj.c | 1 +
src/cpu/cpu.c | 6 +-
src/cpu/cpu_ppc64.c | 16 +-
src/cpu/cpu_x86.c | 13 +-
src/esx/esx_driver.c | 1 +
src/esx/esx_vi.c | 11 +-
src/esx/esx_vi_types.c | 9 +-
src/hyperv/hyperv_driver.c | 18 +-
src/interface/interface_backend_udev.c | 12 +-
src/libvirt.c | 3 +
src/libvirt_private.syms | 6 +
src/libxl/libxl_conf.c | 57 +++-
src/libxl/libxl_domain.c | 23 +-
src/libxl/libxl_driver.c | 16 +-
src/libxl/libxl_logger.c | 2 +
src/locking/lock_driver_sanlock.c | 6 +-
src/locking/lock_manager.c | 2 +
src/locking/sanlock_helper.c | 5 +-
src/lxc/lxc_container.c | 7 +-
src/lxc/lxc_controller.c | 11 +-
src/lxc/lxc_driver.c | 42 ++-
src/lxc/lxc_process.c | 10 +-
src/network/bridge_driver.c | 46 ++-
src/network/leaseshelper.c | 11 +-
src/node_device/node_device_udev.c | 7 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 18 +-
src/nwfilter/nwfilter_gentech_driver.c | 23 +-
src/nwfilter/nwfilter_learnipaddr.c | 19 +-
src/openvz/openvz_driver.c | 3 +
src/qemu/qemu_alias.c | 3 +
src/qemu/qemu_block.c | 22 +-
src/qemu/qemu_blockjob.c | 1 +
src/qemu/qemu_capabilities.c | 23 +-
src/qemu/qemu_cgroup.c | 9 +-
src/qemu/qemu_command.c | 440 ++++++++++++++++++++-----
src/qemu/qemu_domain.c | 228 ++++++++++---
src/qemu/qemu_domain_address.c | 68 +++-
src/qemu/qemu_driver.c | 136 ++++++--
src/qemu/qemu_hostdev.c | 5 +-
src/qemu/qemu_hotplug.c | 94 +++++-
src/qemu/qemu_interface.c | 12 +-
src/qemu/qemu_migration.c | 35 +-
src/qemu/qemu_migration_cookie.c | 6 +-
src/qemu/qemu_monitor.c | 13 +-
src/qemu/qemu_monitor_json.c | 67 +++-
src/qemu/qemu_monitor_text.c | 3 +
src/qemu/qemu_parse_command.c | 12 +-
src/qemu/qemu_process.c | 110 ++++++-
src/remote/remote_driver.c | 19 +-
src/rpc/virnetclient.c | 2 +
src/rpc/virnetclientprogram.c | 1 +
src/rpc/virnetlibsshsession.c | 4 +
src/rpc/virnetservermdns.c | 5 +-
src/rpc/virnetserverprogram.c | 4 +
src/rpc/virnetsshsession.c | 8 +
src/secret/secret_util.c | 11 +-
src/security/security_apparmor.c | 12 +-
src/security/security_dac.c | 59 +++-
src/security/security_driver.c | 1 +
src/security/security_selinux.c | 69 +++-
src/storage/storage_backend_gluster.c | 12 +-
src/storage/storage_backend_rbd.c | 6 +-
src/storage/storage_driver.c | 1 +
src/storage/storage_util.c | 18 +-
src/test/test_driver.c | 2 +
src/uml/uml_conf.c | 5 +-
src/util/vircgroup.c | 1 +
src/util/virconf.c | 13 +-
src/util/vircrypto.c | 2 +
src/util/virerror.c | 6 +-
src/util/virfdstream.c | 4 +
src/util/virfirewall.c | 8 +-
src/util/virhook.c | 12 +-
src/util/virhostdev.c | 8 +-
src/util/virhostmem.c | 5 +
src/util/virjson.c | 5 +
src/util/virlog.c | 17 +-
src/util/virnetdev.c | 1 +
src/util/virnetdevmacvlan.c | 3 +
src/util/virnetdevvportprofile.c | 54 +++-
src/util/virnuma.c | 5 +-
src/util/virprocess.c | 1 +
src/util/virqemu.c | 5 +
src/util/virsexpr.c | 2 +
src/util/virsocketaddr.c | 13 +-
src/util/virstoragefile.c | 15 +-
src/vbox/vbox_common.c | 42 ++-
src/vmx/vmx.c | 27 +-
src/xen/xen_driver.c | 17 +-
src/xenconfig/xen_common.c | 23 +-
src/xenconfig/xen_sxpr.c | 47 ++-
src/xenconfig/xen_xl.c | 28 +-
tests/cputest.c | 31 +-
tests/domaincapstest.c | 1 +
tests/qemuhotplugtest.c | 4 +
tests/storagevolxml2argvtest.c | 2 +
tests/virusbtest.c | 6 +
tools/virsh-domain-monitor.c | 4 +
tools/virsh-domain.c | 14 +-
tools/virsh-nodedev.c | 1 +
tools/virsh-pool.c | 1 +
tools/virsh.c | 1 +
tools/virt-admin.c | 1 +
tools/virt-host-validate-qemu.c | 3 +-
tools/vsh.c | 5 +
128 files changed, 2567 insertions(+), 512 deletions(-)
--
2.14.3