[libvirt] [PATCH v2 08/42] nwfilter: handle missing switch enum cases

John Ferlan jferlan at redhat.com
Mon Feb 19 20:30:39 UTC 2018



On 02/15/2018 11:43 AM, Daniel P. Berrangé wrote:
> Ensure all enum cases are listed in switch statements, or cast away
> enum type in places where we don't wish to cover all cases.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  src/nwfilter/nwfilter_ebiptables_driver.c | 16 +++++++++++-----
>  src/nwfilter/nwfilter_learnipaddr.c       |  6 +++++-
>  2 files changed, 16 insertions(+), 6 deletions(-)
> 

[...]

> diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
> index 5b95f0e613..9ca0639576 100644
> --- a/src/nwfilter/nwfilter_learnipaddr.c
> +++ b/src/nwfilter/nwfilter_learnipaddr.c
> @@ -430,7 +430,7 @@ learnIPAddressThread(void *arg)
>          }
>          virBufferAddLit(&buf, "src port 67 and dst port 68");
>          break;
> -    default:
> +    case DETECT_STATIC:
>          if (techdriver->applyBasicRules(req->ifname,
>                                          &req->macaddr) < 0) {
>              req->status = EINVAL;
> @@ -438,6 +438,10 @@ learnIPAddressThread(void *arg)
>          }
>          virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff:ff",
>                            macaddr);
> +        break;
> +    default:
> +        req->status = EINVAL;
> +        goto done;

Could add a VIR_DEBUG() in this just to "track" the reason it was EINVAL
since there's so many ways it could be EINVAL, not that important...

>      }
>  
>      if (virBufferError(&buf)) {
> 

Reviewed-by: John Ferlan <jferlan at redhat.com>

John




More information about the libvir-list mailing list