[libvirt] [PATCH 05/18] event-test: Use functions with typecasted switch to convert enums
Ján Tomko
jtomko at redhat.com
Mon Apr 18 11:19:47 UTC 2016
On Thu, Apr 14, 2016 at 05:52:30PM +0200, Peter Krempa wrote:
> Arrays would induce crash if a new value was introduced without adding
> it here. This could happen for
> VIR_DOMAIN_EVENT_DISK_DROP_MISSING_ON_START
> ---
> examples/object-events/event-test.c | 37 ++++++++++++++++++++++++++++---------
> 1 file changed, 28 insertions(+), 9 deletions(-)
>
> +static const char *
> +diskChangeReasonToStr(int reason)
diskChangeReasonToString would looks nicer, but Str is readable enough,
thanks to all the std funcs in libc.
ACK
Jan
> +{
> + switch ((virConnectDomainEventDiskChangeReason) reason) {
> + case VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START:
> + return "disk empty due to startupPolicy";
> +
> + case VIR_DOMAIN_EVENT_DISK_DROP_MISSING_ON_START:
> + return "disk dropped due to startupPolicy";
> + }
> +
> + return "unknown";
> +}
> +
More information about the libvir-list
mailing list