]> xenbits.xensource.com Git - libvirt.git/commitdiff
Remove redundant two-state integers
authorJán Tomko <jtomko@redhat.com>
Fri, 24 May 2013 10:29:28 +0000 (12:29 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 6 Jun 2013 15:22:53 +0000 (17:22 +0200)
src/conf/network_conf.c
src/conf/storage_conf.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/qemu/qemu_process.c
src/util/virnetdev.c

index 8cddcc294147bdab79affa2f144480f8d7e54a48..2b4845ca995054d2e2856b0af47a08c32ebb6874 100644 (file)
@@ -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);
index cc3d3d90e74112c9f04eabfefbe39756bdc7caa5..c58b728a5c0fcc31e7ad529c32fd84a5057cea23 100644 (file)
@@ -1922,7 +1922,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 */
@@ -1948,7 +1947,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);
@@ -1960,9 +1959,9 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
                            def->name, uuidstr);
             goto cleanup;
         }
+        ret = 0;
     }
 
-    ret = dupPool;
 cleanup:
     if (pool)
         virStoragePoolObjUnlock(pool);
index 242f87f5fe8cde357891f0a2eea65af7dd2c7aea..708e67f9e503a7887b781939c7f7dc37bd0e3520 100644 (file)
@@ -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;
index 7870a2d5dc55b9de7f0122751d1bbed52681e026..fb625c94e77a75cc7cdca4d23a5407688248a7cd 100644 (file)
@@ -2622,7 +2622,6 @@ static int
 qemuProcessFiltersInstantiate(virConnectPtr conn,
                               virDomainDefPtr def)
 {
-    int err = 0;
     int i;
 
     if (!conn)
@@ -2631,14 +2630,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
index cee40013ad38387c9e96072c2dbd39f5b00d6f65..1a22126d1e2ed2e828d02914595ef780201116b6 100644 (file)
@@ -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;
 }