On Tue, Apr 06, 2021 at 16:31:35 +0100, Daniel Berrange wrote: > The compiler can more easily optimize a switch, and more importantly can > also warn when new address types are added which are not handled. > > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com> > --- > src/qemu/qemu_command.c | 37 +++++++++++++++++++++++++++++++------ > 1 file changed, 31 insertions(+), 6 deletions(-) > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index d3fcca699a..bf60289786 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -351,7 +351,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, > bool contIsPHB = false; > int contTargetIndex = 0; > > - if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { > + switch ((virDomainDeviceAddressType)info->type) { > + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: { > size_t i; > > if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci))) > @@ -419,7 +420,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, > virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot); > if (info->addr.pci.function != 0) > virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); > - } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { > + } break;
break on a separate line please. Reviewed-by: Peter Krempa <pkre...@redhat.com>