Re: [PATCH 05/18] event-test: Use functions with typecasted switch to convert enums

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

 



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";
> +}
> +

--
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]