]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_command: Change logic in qemuVirCommandGet{FDSet,GetDevSet}
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 19 Oct 2019 11:19:32 +0000 (13:19 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 23 Oct 2019 12:56:57 +0000 (14:56 +0200)
These two functions have pattern that's preventing us from
simpler virAsprintf() -> g_strdup_printf() transition. Modify
their logic a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c

index f24013f9ebf13e899fef4a0460c0772eaa78e205..0160507737ddd3e59175fb792aebb8e128b88ed3 100644 (file)
@@ -256,13 +256,13 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
     char *result = NULL;
     int idx = virCommandPassFDGetFDIndex(cmd, fd);
 
-    if (idx >= 0) {
-        ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd));
-    } else {
+    if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("file descriptor %d has not been transferred"), fd);
+        return NULL;
     }
 
+    ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd));
     return result;
 }
 
@@ -283,12 +283,13 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
     char *result = NULL;
     int idx = virCommandPassFDGetFDIndex(cmd, fd);
 
-    if (idx >= 0) {
-        ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx));
-    } else {
+    if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("file descriptor %d has not been transferred"), fd);
+        return NULL;
     }
+
+    ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx));
     return result;
 }