[libvirt] [PATCH] Fix build with GCC 8 new warnings

Andrea Bolognani abologna at redhat.com
Tue Feb 13 13:16:53 UTC 2018


On Tue, 2018-02-13 at 12:21 +0000, Daniel P. Berrangé wrote:
> @@ -175,9 +175,9 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
>      case QEMU_ASYNC_JOB_NONE:
>      case QEMU_ASYNC_JOB_LAST:
>          ATTRIBUTE_FALLTHROUGH;
> +    default:
> +        return "none";
>      }
> -
> -    return "none";
>  }

Can't we just replace ATTRIBUTE_FALLTHROUGH with a break? Or even
just duplicate the return statement, without adding the default
label, if that doesn't help? Same for the next hunk.

> @@ -532,6 +532,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
>              case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2: /* xen only */
>              case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
>              case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
> +            default:
>                  return 0;
>              }

Adding the default label here and in the following hunks will
forfeit the advantage of having the compiler catch for us cases
where we introduced a new model but didn't update all the code
that needs to deal with it accordingly. IMHO that should only be
considered as a very last resort if we can't possibly otherwise
restructure the code in a way that makes the compiler happy.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list