[libvirt] [PATCH] virsh-volume: Unify strigification of volume type
Eric Blake
eblake at redhat.com
Tue Nov 12 16:13:08 UTC 2013
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
-------------- 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/20131112/8a7b6cd3/attachment-0001.sig>
More information about the libvir-list
mailing list