[libvirt] [PATCH 2/4] conf: Use correct type for device type enum in virDomainDeviceDefFree

Eric Blake eblake at redhat.com
Mon Jan 28 22:29:16 UTC 2013


On 01/11/2013 10:00 AM, Peter Krempa wrote:
> With this change it's easy to spot a forgotten free if a new device
> class is added.
> ---
>  src/conf/domain_conf.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

ACK; and this can go in pre-release.

> -    switch (def->type) {
> +    switch ((virDomainDeviceType) def->type) {
>      case VIR_DOMAIN_DEVICE_DISK:
>          virDomainDiskDefFree(def->data.disk);
>          break;
> @@ -1562,6 +1562,13 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
>      case VIR_DOMAIN_DEVICE_REDIRDEV:
>          virDomainRedirdevDefFree(def->data.redirdev);
>          break;
> +    case VIR_DOMAIN_DEVICE_NONE:
> +    case VIR_DOMAIN_DEVICE_FS:
> +    case VIR_DOMAIN_DEVICE_SMARTCARD:
> +    case VIR_DOMAIN_DEVICE_CHR:
> +    case VIR_DOMAIN_DEVICE_MEMBALLOON:
> +    case VIR_DOMAIN_DEVICE_LAST:
> +        break;
>      }

In general, this style is useful on ANY switch statement over a set of
enums, for letting the compiler help us know when the enumeration grew.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130128/9e001370/attachment-0001.sig>


More information about the libvir-list mailing list