Re: [PATCH] virsh-volume: Unify strigification of volume type

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

 



On 11/12/2013 08:16 AM, Peter Krempa wrote:
> There were two separate places with that were stringifying type of a
> volume. One of the places was out of sync with types implemented
> upstream.
> 
> To avoid such problems in the future, this patch adds a common function
> to convert the type to string and reuses it across the two said places.
> ---
>  tools/virsh-volume.c | 59 ++++++++++++++++++++++++----------------------------
>  1 file changed, 27 insertions(+), 32 deletions(-)

ACK with one nit:

> +static const char *
> +vshVolumeTypeToString(int type)
> +{
> +    switch (type) {

Please make this "switch ((virStorageVolType) type)"

> +    case VIR_STORAGE_VOL_FILE:
> +        return N_("file");
> +
> +    case VIR_STORAGE_VOL_BLOCK:
> +        return N_("block");
> +
> +    case VIR_STORAGE_VOL_DIR:
> +        return N_("dir");
> +
> +    case VIR_STORAGE_VOL_NETWORK:
> +        return N_("network");
> +
> +    default:
> +        return N_("unknown");
> +    }

drop the default: case, and instead use:

    VIR_STORAGE_VOL_LAST:
        break;
    }
    return N_("unknown");

which will then let the compiler enforce us to expand the list if we
ever add another type.

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]