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

Ján Tomko posted 7 patches 7 years, 2 months ago
Only 6 patches received!
[libvirt] [PATCH 7/7] Simplify some conditions
Posted by Ján Tomko 7 years, 2 months ago
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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/7] Simplify some conditions
Posted by Peter Krempa 7 years, 2 months ago
On Tue, Mar 06, 2018 at 15:01:39 +0100, Ján Tomko wrote:
> 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@redhat.com>
> ---

I'd commit those as 2 commits.

ACK if you split it.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list