]> xenbits.xensource.com Git - libvirt.git/commitdiff
admin: Check for flags properly
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 1 Mar 2016 14:03:04 +0000 (15:03 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 11 Mar 2016 11:58:41 +0000 (12:58 +0100)
Function virAdmConnectListServers() forgot to check for flags at all,
virAdmConnectOpen() on the other hand checked them but did no dispatch
the error.  virCheckFlags() should be used only when there should be no
other thing done after erroring out and since they are used on different
places then just public API, they cannot dispatch errors.  So let's use
virCheckFlagsGoto instead.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/libvirt-admin.c

index 54ae5ad3135eb311860cff453ab5bd25a80d09a6..645e0723e0b36e3d7a8e7d798b5ccea56fb48a2e 100644 (file)
@@ -185,7 +185,7 @@ virAdmGetDefaultURI(virConfPtr conf)
 /**
  * virAdmConnectOpen:
  * @name: uri of the daemon to connect to, NULL for default
- * @flags: unused, must be 0
+ * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Opens connection to admin interface of the daemon.
  *
@@ -204,7 +204,7 @@ virAdmConnectOpen(const char *name, unsigned int flags)
 
     VIR_DEBUG("flags=%x", flags);
     virResetLastError();
-    virCheckFlags(VIR_CONNECT_NO_ALIASES, NULL);
+    virCheckFlagsGoto(VIR_CONNECT_NO_ALIASES, error);
 
     if (!(conn = virAdmConnectNew()))
         goto error;
@@ -603,7 +603,7 @@ int virAdmServerFree(virAdmServerPtr srv)
  * @conn: daemon connection reference
  * @servers: Pointer to a list to store an array containing objects or NULL
  *           if the list is not required (number of servers only)
- * @flags: bitwise-OR of virAdmConnectListServersFlags
+ * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Collect list of all servers provided by daemon the client is connected to.
  *
@@ -624,6 +624,7 @@ virAdmConnectListServers(virAdmConnectPtr conn,
     VIR_DEBUG("conn=%p, servers=%p, flags=%x", conn, servers, flags);
 
     virResetLastError();
+    virCheckFlagsGoto(0, error);
 
     if (servers)
         *servers = NULL;