[libvirt] [PATCH v2 02/14] util: handle missing switch enum cases

John Ferlan jferlan at redhat.com
Tue Feb 20 18:44:31 UTC 2018



On 02/20/2018 12:08 PM, Daniel P. Berrangé wrote:
> Ensure all enum cases are listed in switch statements.
> 
> Reviewed-by: John Ferlan <jferlan at redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  src/util/virconf.c               | 11 ++++++++++-
>  src/util/virfirewall.c           |  6 ++++--
>  src/util/virlog.c                |  9 ++++++++-
>  src/util/virnetdevvportprofile.c | 10 +++++++++-
>  4 files changed, 31 insertions(+), 5 deletions(-)
> 

[...]

> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index 4f66cc5e5c..6c6d7e8ded 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -1206,10 +1206,17 @@ virLogGetOutputs(void)
>                                    virLogDestinationTypeToString(dest),
>                                    virLogOutputs[i]->name);
>                  break;
> -            default:
> +            case VIR_LOG_TO_STDERR:
> +            case VIR_LOG_TO_JOURNALD:
>                  virBufferAsprintf(&outputbuf, "%d:%s",
>                                    virLogOutputs[i]->priority,
>                                    virLogDestinationTypeToString(dest));
> +                break;
> +            case VIR_LOG_TO_OUTPUT_LAST:
> +            default:
> +                virReportEnumRangeError(virLogDestination, dest);

Didn't see this before, but because this is a for loop, you'll need to
add a virBufferFreeAndReset(&outputbuf); before returning.


Existing R-b still applies

John

> +                virLogUnlock();
> +                return NULL;
>          }
>      }
>      virLogUnlock();




More information about the libvir-list mailing list