[libvirt] [PATCH 7/7] Simplify some conditions

Ján Tomko jtomko at redhat.com
Tue Mar 6 14:01:39 UTC 2018


In qemuMigrationSrcRun, we already checked for non-NULL mig
and then dereferenced it. It's only possible for mig to be
NULL in the error section.

In remoteConnectOpen, conn->uri cannot be NULL in the second
part of the OR expression due to short-circuit evaluation.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_migration.c  | 2 +-
 src/remote/remote_driver.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index bf89e184e..e5231555d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3992,7 +3992,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
         goto error;
     }
 
-    if (mig && mig->nbd &&
+    if (mig->nbd &&
         qemuMigrationSrcCancelDriveMirror(driver, vm, true,
                                           QEMU_ASYNC_JOB_MIGRATION_OUT,
                                           dconn) < 0)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2ec69166f..9390bead6 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1310,7 +1310,7 @@ remoteConnectOpen(virConnectPtr conn,
     int ret, rflags = 0;
     const char *autostart = virGetEnvBlockSUID("LIBVIRT_AUTOSTART");
 
-    if (inside_daemon && (!conn->uri || (conn->uri && !conn->uri->server)))
+    if (inside_daemon && (!conn->uri || !conn->uri->server))
         return VIR_DRV_OPEN_DECLINED;
 
     if (!(priv = remoteAllocPrivateData()))
-- 
2.16.1




More information about the libvir-list mailing list