[PATCH 2/4] Remove redundant two-state integers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/conf/network_conf.c           |  5 ++---
 src/conf/storage_conf.c           |  5 ++---
 src/nwfilter/nwfilter_dhcpsnoop.c |  8 +-------
 src/qemu/qemu_process.c           |  9 +++------
 src/util/virnetdev.c              | 19 +++++++++----------
 5 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 8cddcc2..2b4845c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -4198,7 +4198,6 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr doms,
                          bool check_active)
 {
     int ret = -1;
-    int dupVM = 0;
     virNetworkObjPtr vm = NULL;
 
     /* See if a VM with matching UUID already exists */
@@ -4224,7 +4223,7 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr doms,
             }
         }
 
-        dupVM = 1;
+        ret = 1;
     } else {
         /* UUID does not match, but if a name matches, refuse it */
         vm = virNetworkFindByName(doms, def->name);
@@ -4236,9 +4235,9 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr doms,
                            def->name, uuidstr);
             goto cleanup;
         }
+        ret = 0;
     }
 
-    ret = dupVM;
 cleanup:
     if (vm)
         virNetworkObjUnlock(vm);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index c381023..c599b80 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1904,7 +1904,6 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
                              unsigned int check_active)
 {
     int ret = -1;
-    int dupPool = 0;
     virStoragePoolObjPtr pool = NULL;
 
     /* See if a Pool with matching UUID already exists */
@@ -1930,7 +1929,7 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
             }
         }
 
-        dupPool = 1;
+        ret = 1;
     } else {
         /* UUID does not match, but if a name matches, refuse it */
         pool = virStoragePoolObjFindByName(pools, def->name);
@@ -1942,9 +1941,9 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
                            def->name, uuidstr);
             goto cleanup;
         }
+        ret = 0;
     }
 
-    ret = dupPool;
 cleanup:
     if (pool)
         virStoragePoolObjUnlock(pool);
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 451c783..4d32f1a 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -913,7 +913,6 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
                            uint8_t *pmtype, uint32_t *pleasetime)
 {
     int oind, olen;
-    int oend;
     uint32_t nwint;
 
     olen = len - sizeof(*pd);
@@ -927,8 +926,6 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
 
     oind += sizeof(dhcp_magic);
 
-    oend = 0;
-
     *pmtype = 0;
     *pleasetime = 0;
 
@@ -953,14 +950,11 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
             oind++;
             continue;
         case DHCPO_END:
-            oend = 1;
-            break;
+            return 0;
         default:
             if (olen - oind < 2)
                 goto malformed;
         }
-        if (oend)
-            break;
         oind += pd->d_opts[oind + 1] + 2;
     }
     return 0;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 191c9c2..b297f81 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2615,7 +2615,6 @@ static int
 qemuProcessFiltersInstantiate(virConnectPtr conn,
                               virDomainDefPtr def)
 {
-    int err = 0;
     int i;
 
     if (!conn)
@@ -2624,14 +2623,12 @@ qemuProcessFiltersInstantiate(virConnectPtr conn,
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDefPtr net = def->nets[i];
         if ((net->filter) && (net->ifname)) {
-           if (virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) {
-                err = 1;
-                break;
-            }
+            if (virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0)
+                return 1;
         }
     }
 
-    return err;
+    return 0;
 }
 
 static int
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index cee4001..1a22126 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1564,7 +1564,6 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
     struct ifla_vf_vlan *vf_vlan;
     struct nlattr *tb_vf_info = {NULL, };
     struct nlattr *tb_vf[IFLA_VF_MAX+1];
-    int found = 0;
     int rem;
 
     if (!tb[IFLA_VFINFO_LIST]) {
@@ -1588,7 +1587,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             vf_mac = RTA_DATA(tb_vf[IFLA_VF_MAC]);
             if (vf_mac && vf_mac->vf == vf)  {
                 virMacAddrSetRaw(mac, vf_mac->mac);
-                found = 1;
+                rc = 0;
             }
         }
 
@@ -1596,17 +1595,17 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             vf_vlan = RTA_DATA(tb_vf[IFLA_VF_VLAN]);
             if (vf_vlan && vf_vlan->vf == vf)  {
                 *vlanid = vf_vlan->vlan;
-                found = 1;
+                rc = 0;
             }
         }
-        if (found) {
-            rc = 0;
-            goto cleanup;
-        }
+
+        if (rc == 0)
+            break;
     }
-    virReportError(VIR_ERR_INTERNAL_ERROR,
-                   _("couldn't find IFLA_VF_INFO for VF %d "
-                     "in netlink response"), vf);
+    if (rc < 0)
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("couldn't find IFLA_VF_INFO for VF %d "
+                         "in netlink response"), vf);
 cleanup:
     return rc;
 }
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]