]> xenbits.xensource.com Git - libvirt.git/commitdiff
Drop some useless comparisons and checks
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 27 Feb 2019 14:03:10 +0000 (15:03 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Mar 2019 08:22:47 +0000 (09:22 +0100)
In these cases the check that is removed has been done a few
lines above already (as can even be seen in the context). Drop
them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
examples/dommigrate/dommigrate.c
src/conf/nwfilter_conf.c
src/qemu/qemu_command.c
src/qemu/qemu_hotplug.c
src/util/virresctrl.c
tools/virsh-snapshot.c

index 1b6072d1380639e5b14b2d50de4bba2ca379acec..60cfb3fb8328d75ce76f9b3af6c64aac96d60787 100644 (file)
@@ -79,8 +79,7 @@ main(int argc, char *argv[])
  cleanup:
     if (dom != NULL)
         virDomainFree(dom);
-    if (conn != NULL)
-        virConnectClose(conn);
+    virConnectClose(conn);
 
  out:
     return ret;
index 7cad3ccc57d080271f96cd769fa4bda790f1b3fa..15290f7f80ed30670633d63fb5ddee7ec0951814 100644 (file)
@@ -2659,10 +2659,8 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
             ret->chainPriority = chain_priority;
         } else {
             /* assign default priority if none can be found via lookup */
-            if (!name_prefix ||
-                 intMapGetByString(chain_priorities, name_prefix, 0,
-                                   &ret->chainPriority) < 0) {
-                /* assign default chain priority */
+            if (intMapGetByString(chain_priorities, name_prefix,
+                                  0, &ret->chainPriority) < 0) {
                 ret->chainPriority = (NWFILTER_MAX_FILTER_PRIORITY +
                                       NWFILTER_MIN_FILTER_PRIORITY) / 2;
             }
index 853b0932b0f0e6c292236f4f712418f802157004..3a2ec7f26cbe748e479e2521a1a71818dfdd7527 100644 (file)
@@ -4340,8 +4340,7 @@ qemuBuildNVRAMCommandLine(virCommandPtr cmd,
         optstr = qemuBuildNVRAMDevStr(def->nvram);
         if (!optstr)
             return -1;
-        if (optstr)
-            virCommandAddArg(cmd, optstr);
+        virCommandAddArg(cmd, optstr);
         VIR_FREE(optstr);
     } else {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
index 00dbff6b2a736464f62e7decd563127081db00ac..19b7e6e8ea3798ad5bafae3bc177ea017511e005 100644 (file)
@@ -3521,17 +3521,15 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
         goto cleanup;
     }
 
-    if (oldbridge) {
-        ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname);
-        virDomainAuditNet(vm, olddev, NULL, "detach", ret == 0);
-        if (ret < 0) {
-            /* warn but continue - possibly the old network
-             * had been destroyed and reconstructed, leaving the
-             * tap device orphaned.
-             */
-            VIR_WARN("Unable to detach device %s from bridge %s",
-                     olddev->ifname, oldbridge);
-        }
+    ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname);
+    virDomainAuditNet(vm, olddev, NULL, "detach", ret == 0);
+    if (ret < 0) {
+        /* warn but continue - possibly the old network
+         * had been destroyed and reconstructed, leaving the
+         * tap device orphaned.
+         */
+        VIR_WARN("Unable to detach device %s from bridge %s",
+                 olddev->ifname, oldbridge);
     }
 
     ret = virNetDevBridgeAddPort(newbridge, olddev->ifname);
index 97891b2f8f727de9f896fe8b2aaba96e1abefa96..0857d4e882be420c35cc48fa9b5261454cc222fc 100644 (file)
@@ -2120,7 +2120,7 @@ virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl,
     if (!mem_bw_alloc)
         return 0;
 
-    if (mem_bw_alloc && !mem_bw_info) {
+    if (!mem_bw_info) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("RDT Memory Bandwidth allocation unsupported"));
         return -1;
index e38ebb1f286ebd5ce4402e6699f7d390f5e46b4e..025321c58e0aa499c48059f27ba076082aea94bc 100644 (file)
@@ -1208,9 +1208,8 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
     /* Now that we have a count, collect the list.  */
     if (from && !priv->useSnapshotOld) {
         if (tree) {
-            if (count)
-                count = virDomainSnapshotListChildrenNames(from, names + 1,
-                                                           count - 1, flags);
+            count = virDomainSnapshotListChildrenNames(from, names + 1,
+                                                       count - 1, flags);
             if (count >= 0) {
                 count++;
                 names[0] = vshStrdup(ctl, fromname);