[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 03/13] qemu: change if to switch in qemuBuildDeviceAddressStr




On 05/05/2015 02:03 PM, Laine Stump wrote:
> ---
>  src/qemu/qemu_command.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 620a2a0..b76bd98 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -2585,11 +2585,11 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
>  {
>      int ret = -1;
>      char *devStr = NULL;
> +    const char *contAlias = NULL;
> +    size_t i;
>  
> -    if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
> -        const char *contAlias = NULL;
> -        size_t i;
> -
> +    switch (info->type) {

s/(/((virDomainDeviceAddressType)/

> +    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
>          if (!(devStr = virDomainPCIAddressAsString(&info->addr.pci)))
>              goto cleanup;
>          for (i = 0; i < domainDef->ncontrollers; i++) {
> @@ -2664,19 +2664,23 @@ 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;
> +    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
>          virBufferAddLit(buf, ",bus=");
>          qemuUSBId(buf, info->addr.usb.bus);
>          virBufferAsprintf(buf, ".0,port=%s", info->addr.usb.port);
> -    } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
> +        break;
> +    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
>          if (info->addr.spaprvio.has_reg)
>              virBufferAsprintf(buf, ",reg=0x%llx", info->addr.spaprvio.reg);
> -    } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
> +        break;
> +    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
>          if (info->addr.ccw.assigned)
>              virBufferAsprintf(buf, ",devno=%x.%x.%04x",
>                                info->addr.ccw.cssid,
>                                info->addr.ccw.ssid,
>                                info->addr.ccw.devno);
> +        break;

and the obligatory:

    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
        break;


ACK with that,

John
>      }
>  
>      ret = 0;
> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]