[libvirt] [PATCH 3/6] conf: Make switch statements more strict

Laine Stump laine at laine.org
Wed Feb 22 14:40:33 UTC 2017


On 02/21/2017 02:57 PM, Andrea Bolognani wrote:
> When switching over the values in the virDomainControllerModelPCI
> enumeration, make sure the proper cast is in place so that the
> compiler can warn us when the coverage is not exaustive.
>
> For the same reason, remove the 'default' case from one of the
> existing switch statements.
> ---
>   src/conf/domain_addr.c |  4 ++--
>   src/conf/domain_conf.c | 12 +++++++++++-
>   2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
> index 519cc6b..933c2fe 100644
> --- a/src/conf/domain_addr.c
> +++ b/src/conf/domain_addr.c
> @@ -344,9 +344,9 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
>           bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
>           break;
>   
> -    default:
> +    case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
>           virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("Invalid PCI controller model %d"), model);
> +                       _("PCI controller model was not set correctly"));

You're going to need to precede the string with "%s", to avoid a 
syntax-check failure.


ACK with that fixed.




More information about the libvir-list mailing list