[libvirt] [PATCH 04/14] rpc: Add typedef for the anonymous enum used for authentication methods

Marc Hartmayer posted 14 patches 7 years, 5 months ago
There is a newer version of this series
[libvirt] [PATCH 04/14] rpc: Add typedef for the anonymous enum used for authentication methods
Posted by Marc Hartmayer 7 years, 5 months ago
Add typedef for the anonymous enum used for the authentication methods
and remove the default case. This allows the usage of the type in a
switch statement and taking advantage of the compilers feature to
detect uncovered cases.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
---
 daemon/remote.c               | 4 +---
 src/rpc/virnetserverservice.h | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index f769bb762d5b..6f78f17178f7 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3274,7 +3274,7 @@ remoteDispatchAuthList(virNetServerPtr server,
     if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0)
         goto cleanup;
 
-    switch (auth) {
+    switch ((virNetServerServiceAuthMethods) auth) {
     case VIR_NET_SERVER_SERVICE_AUTH_NONE:
         ret->types.types_val[0] = REMOTE_AUTH_NONE;
         break;
@@ -3284,8 +3284,6 @@ remoteDispatchAuthList(virNetServerPtr server,
     case VIR_NET_SERVER_SERVICE_AUTH_SASL:
         ret->types.types_val[0] = REMOTE_AUTH_SASL;
         break;
-    default:
-        ret->types.types_val[0] = REMOTE_AUTH_NONE;
     }
 
     rv = 0;
diff --git a/src/rpc/virnetserverservice.h b/src/rpc/virnetserverservice.h
index 9afa0b13dbc6..5d8c583db2e2 100644
--- a/src/rpc/virnetserverservice.h
+++ b/src/rpc/virnetserverservice.h
@@ -27,11 +27,11 @@
 # include "virnetserverprogram.h"
 # include "virobject.h"
 
-enum {
+typedef enum {
     VIR_NET_SERVER_SERVICE_AUTH_NONE = 0,
     VIR_NET_SERVER_SERVICE_AUTH_SASL,
     VIR_NET_SERVER_SERVICE_AUTH_POLKIT,
-};
+} virNetServerServiceAuthMethods;
 
 typedef int (*virNetServerServiceDispatchFunc)(virNetServerServicePtr svc,
                                                virNetSocketPtr sock,
-- 
2.13.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/14] rpc: Add typedef for the anonymous enum used for authentication methods
Posted by John Ferlan 7 years, 5 months ago

On 12/12/2017 06:36 AM, Marc Hartmayer wrote:
> Add typedef for the anonymous enum used for the authentication methods
> and remove the default case. This allows the usage of the type in a
> switch statement and taking advantage of the compilers feature to
> detect uncovered cases.
> 
> Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
> Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
> ---
>  daemon/remote.c               | 4 +---
>  src/rpc/virnetserverservice.h | 4 ++--
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 

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

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list