[PATCH 15/15] virBitmapNew: Don't check return value

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

 



Remove return value check from all callers.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/capabilities.c          |  7 ++-----
 src/conf/checkpoint_conf.c       |  3 +--
 src/conf/domain_addr.c           |  6 ++----
 src/conf/domain_conf.c           | 12 ++++--------
 src/conf/node_device_conf.c      |  6 ++----
 src/conf/storage_conf.c          |  3 +--
 src/conf/virnetworkobj.c         |  3 +--
 src/libxl/libxl_capabilities.c   |  4 ----
 src/libxl/libxl_driver.c         |  6 ++----
 src/lxc/lxc_controller.c         |  3 ---
 src/qemu/qemu_capabilities.c     |  3 +--
 src/qemu/qemu_conf.c             |  3 +--
 src/qemu/qemu_domain_address.c   |  5 +----
 src/qemu/qemu_driver.c           | 11 +++--------
 src/qemu/qemu_hotplug.c          |  3 +--
 src/qemu/qemu_migration_cookie.c |  5 ++---
 src/qemu/qemu_migration_params.c | 12 ++----------
 src/qemu/qemu_monitor.c          |  3 +--
 src/qemu/qemu_namespace.c        |  5 ++---
 src/qemu/qemu_process.c          |  5 +----
 src/qemu/qemu_slirp.c            |  4 +---
 src/qemu/qemu_snapshot.c         |  3 +--
 src/test/test_driver.c           | 12 +++---------
 src/util/virbitmap.c             | 12 ++----------
 src/util/vircommand.c            |  3 +--
 src/util/virdnsmasq.c            |  7 +------
 src/util/virhostcpu.c            | 10 +++-------
 src/util/virnetdev.c             |  3 +--
 src/util/virnuma.c               |  6 ++----
 src/util/virportallocator.c      |  6 +-----
 src/util/virprocess.c            |  6 ++----
 src/util/virresctrl.c            | 10 +---------
 src/util/virstoragefile.c        |  3 +--
 src/vmx/vmx.c                    |  2 --
 src/vz/vz_sdk.c                  |  3 +--
 tests/qemumonitorjsontest.c      |  3 ---
 tests/testutils.c                | 11 ++---------
 tests/virbitmaptest.c            | 12 ++----------
 tools/virsh-domain.c             |  9 +++------
 39 files changed, 58 insertions(+), 175 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 610e6e8242..4a85c63628 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1411,9 +1411,7 @@ virCapabilitiesHostNUMAGetCpus(virCapsHostNUMAPtr caps,
     unsigned int maxcpu = virCapabilitiesHostNUMAGetMaxcpu(caps);
     ssize_t node = -1;

-    if (!(ret = virBitmapNew(maxcpu + 1)))
-        return NULL;
-
+    ret = virBitmapNew(maxcpu + 1);

     while ((node = virBitmapNextSetBit(nodemask, node)) >= 0) {
         if (virCapabilitiesHostNUMAGetCellCpus(caps, node, ret) < 0) {
@@ -1591,8 +1589,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr caps)
                         cpus[cid].die_id = 0;
                         cpus[cid].socket_id = s;
                         cpus[cid].core_id = c;
-                        if (!(cpus[cid].siblings = virBitmapNew(ncpus)))
-                            goto error;
+                        cpus[cid].siblings = virBitmapNew(ncpus);
                         virBitmapCopy(cpus[cid].siblings, siblings);
                         cid++;
                     }
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index 914af4305d..f97621dabf 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -323,8 +323,7 @@ virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr def)
     if (!def->ndisks)
         checkpoint_default = VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP;

-    if (!(map = virBitmapNew(def->parent.dom->ndisks)))
-        goto cleanup;
+    map = virBitmapNew(def->parent.dom->ndisks);

     /* Double check requested disks.  */
     for (i = 0; i < def->ndisks; i++) {
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 6e77a72f7c..9114f2d8d0 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1595,8 +1595,7 @@ virDomainVirtioSerialAddrSetAddController(virDomainVirtioSerialAddrSetPtr addrs,
     if (VIR_ALLOC(cnt) < 0)
         goto cleanup;

-    if (!(cnt->ports = virBitmapNew(ports)))
-        goto cleanup;
+    cnt->ports = virBitmapNew(ports);
     cnt->idx = cont->idx;

     if ((insertAt = virDomainVirtioSerialAddrPlaceController(addrs, cnt)) < -1)
@@ -2043,8 +2042,7 @@ virDomainUSBAddressHubNew(size_t nports)
     if (VIR_ALLOC(hub) < 0)
         goto cleanup;

-    if (!(hub->portmap = virBitmapNew(nports)))
-        goto cleanup;
+    hub->portmap = virBitmapNew(nports);

     if (VIR_ALLOC_N(hub->ports, nports) < 0)
         goto cleanup;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b80d7c7c6c..2fbfd949fd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2032,12 +2032,9 @@ virDomainDefGetVcpus(const virDomainDef *def)
 virBitmapPtr
 virDomainDefGetOnlineVcpumap(const virDomainDef *def)
 {
-    virBitmapPtr ret = NULL;
+    virBitmapPtr ret = virBitmapNew(def->maxvcpus);
     size_t i;

-    if (!(ret = virBitmapNew(def->maxvcpus)))
-        return NULL;
-
     for (i = 0; i < def->maxvcpus; i++) {
         if (def->vcpus[i]->online)
             ignore_value(virBitmapSetBit(ret, i));
@@ -3311,8 +3308,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
         return 0;

     /* iothread's are numbered starting at 1, account for that */
-    if (!(thrmap = virBitmapNew(iothreads + 1)))
-        return -1;
+    thrmap = virBitmapNew(iothreads + 1);
     virBitmapSetAll(thrmap);

     /* Clear 0 since we don't use it, then mark those which are
@@ -4505,8 +4501,8 @@ virDomainDefRejectDuplicateControllers(virDomainDefPtr def)
     max_idx[VIR_DOMAIN_CONTROLLER_TYPE_USB] = -1;

     for (i = 0; i < VIR_DOMAIN_CONTROLLER_TYPE_LAST; i++) {
-        if (max_idx[i] >= 0 && !(bitmaps[i] = virBitmapNew(max_idx[i] + 1)))
-            goto cleanup;
+        if (max_idx[i] >= 0)
+            bitmaps[i] = virBitmapNew(max_idx[i] + 1);
         nbitmaps++;
     }

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index a9a03ad6c2..e478238675 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1143,10 +1143,8 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
     if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
         goto out;

-    if (n > 0) {
-        if (!(net->features = virBitmapNew(VIR_NET_DEV_FEAT_LAST)))
-            goto out;
-    }
+    if (n > 0)
+        net->features = virBitmapNew(VIR_NET_DEV_FEAT_LAST);

     for (i = 0; i < n; i++) {
         int val;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index d53d50479b..ae63cc725e 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1444,8 +1444,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
         if (!def->target.compat)
             def->target.compat = g_strdup("1.1");

-        if (!(def->target.features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST)))
-            return NULL;
+        def->target.features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);

         for (i = 0; i < n; i++) {
             int f = virStorageFileFeatureTypeFromString((const char*)nodes[i]->name);
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 8b12ce0482..aefe23fde1 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -110,8 +110,7 @@ virNetworkObjNew(void)
     if (!(obj = virObjectLockableNew(virNetworkObjClass)))
         return NULL;

-    if (!(obj->classIdMap = virBitmapNew(INIT_CLASS_ID_BITMAP_SIZE)))
-        goto error;
+    obj->classIdMap = virBitmapNew(INIT_CLASS_ID_BITMAP_SIZE);

     /* The first three class IDs are already taken */
     if (virBitmapSetBitExpand(obj->classIdMap, 0) < 0 ||
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index e3472acb4b..622cba1bfc 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -296,10 +296,6 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
         cpus[node][nr_cpus_node[node]-1].core_id = cpu_topo[i].core;
         /* Allocate the siblings maps. We will be filling them later */
         cpus[node][nr_cpus_node[node]-1].siblings = virBitmapNew(nr_cpus);
-        if (!cpus[node][nr_cpus_node[node]-1].siblings) {
-            virReportOOMError();
-            goto cleanup;
-        }
     }

     /* Let's now populate the siblings bitmaps */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 80ee3ac5d0..446449fb33 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2571,8 +2571,7 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
     /* Make sure coverity knows targetDef is valid at this point. */
     sa_assert(targetDef);

-    if (!(hostcpus = virBitmapNew(libxl_get_max_cpus(cfg->ctx))))
-        goto cleanup;
+    hostcpus = virBitmapNew(libxl_get_max_cpus(cfg->ctx));
     virBitmapSetAll(hostcpus);

     ret = virDomainDefGetVcpuPinInfoHelper(targetDef, maplen, ncpumaps, cpumaps,
@@ -4952,8 +4951,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
                 virReportOOMError();
                 goto cleanup;
             }
-            if (!(nodes = virBitmapNew(numnodes)))
-                goto cleanup;
+            nodes = virBitmapNew(numnodes);

             rc = libxl_domain_get_nodeaffinity(cfg->ctx,
                                                vm->def->id,
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index c3cf485e2c..f70731bc64 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -756,9 +756,6 @@ static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
         maxcpu = hostcpus;

     cpumap = virBitmapNew(maxcpu);
-    if (!cpumap)
-        return -1;
-
     cpumapToSet = cpumap;

     if (ctrl->def->cpumask) {
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ea2e4c0948..e3a934363b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1800,8 +1800,7 @@ virQEMUCapsNew(void)
         return NULL;

     qemuCaps->invalidation = true;
-    if (!(qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST)))
-        goto error;
+    qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST);

     if (!(qemuCaps->domCapsCache = virQEMUDomainCapsCacheNew()))
         goto error;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4ed1fa061..2f5809e1ad 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -278,8 +278,7 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged,
     cfg->glusterDebugLevel = 4;
     cfg->stdioLogD = true;

-    if (!(cfg->namespaces = virBitmapNew(QEMU_DOMAIN_NS_LAST)))
-        return NULL;
+    cfg->namespaces = virBitmapNew(QEMU_DOMAIN_NS_LAST);

     if (privileged &&
         qemuDomainNamespaceAvailable(QEMU_DOMAIN_NS_MOUNT) &&
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 61eb53ea2c..a2b19da5ea 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -3056,13 +3056,10 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def)
 static virBitmapPtr
 qemuDomainGetMemorySlotMap(const virDomainDef *def)
 {
-    virBitmapPtr ret;
+    virBitmapPtr ret = virBitmapNew(def->mem.memory_slots);
     virDomainMemoryDefPtr mem;
     size_t i;

-    if (!(ret = virBitmapNew(def->mem.memory_slots)))
-        return NULL;
-
     for (i = 0; i < def->nmems; i++) {
         mem = def->mems[i];

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 85b6a6a321..c23dca9970 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19280,18 +19280,13 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
     virTypedParameterPtr par = NULL;
     int npar = 0;
     int maxpar = 0;
-    virBitmapPtr vcpus = NULL;
-    virBitmapPtr online = NULL;
-    virBitmapPtr offlinable = NULL;
+    virBitmapPtr vcpus = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
+    virBitmapPtr online = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
+    virBitmapPtr offlinable = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
     g_autofree char *tmp = NULL;
     size_t i;
     int ret = -1;

-    if (!(vcpus = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)) ||
-        !(online = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)) ||
-        !(offlinable = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)))
-        goto cleanup;
-
     for (i = 0; i < ninfo; i++) {
         if (virBitmapSetBit(vcpus, info[i].id) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 11b549b12b..86ccb9bac4 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -6150,8 +6150,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDefPtr def,
     unsigned int curvcpus = virDomainDefGetVcpus(def);
     ssize_t i;

-    if (!(ret = virBitmapNew(maxvcpus)))
-        return NULL;
+    ret = virBitmapNew(maxvcpus);

     if (nvcpus > curvcpus) {
         *enable = true;
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index c128f541dd..4b73a98f7e 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1122,9 +1122,8 @@ qemuMigrationCookieCapsXMLParse(xmlXPathContextPtr ctxt)
     if (VIR_ALLOC(caps) < 0)
         return NULL;

-    if (!(caps->supported = virBitmapNew(QEMU_MIGRATION_CAP_LAST)) ||
-        !(caps->automatic = virBitmapNew(QEMU_MIGRATION_CAP_LAST)))
-        goto cleanup;
+    caps->supported = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
+    caps->automatic = virBitmapNew(QEMU_MIGRATION_CAP_LAST);

     if ((n = virXPathNodeSet("./capabilities[1]/cap", ctxt, &nodes)) < 0)
         goto cleanup;
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 5fde915963..df5560d39f 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -224,12 +224,9 @@ G_STATIC_ASSERT(G_N_ELEMENTS(qemuMigrationParamTypes) == QEMU_MIGRATION_PARAM_LA
 virBitmapPtr
 qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty party)
 {
-    virBitmapPtr caps = NULL;
+    virBitmapPtr caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
     size_t i;

-    if (!(caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST)))
-        return NULL;
-
     for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsAlwaysOn); i++) {
         if (!(qemuMigrationParamsAlwaysOn[i].party & party))
             continue;
@@ -248,8 +245,7 @@ qemuMigrationParamsNew(void)

     params = g_new0(qemuMigrationParams, 1);

-    if (!(params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST)))
-        return NULL;
+    params->caps = virBitmapNew(QEMU_MIGRATION_CAP_LAST);

     return g_steal_pointer(&params);
 }
@@ -1373,8 +1369,6 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver,
         return 0;

     priv->migrationCaps = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
-    if (!priv->migrationCaps)
-        return -1;

     for (capStr = caps; *capStr; capStr++) {
         int cap = qemuMigrationCapabilityTypeFromString(*capStr);
@@ -1389,8 +1383,6 @@ qemuMigrationCapsCheck(virQEMUDriverPtr driver,

     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT)) {
         migEvent = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
-        if (!migEvent)
-            return -1;

         ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS));

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index eb4b04dc1a..c6be72dabc 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1937,8 +1937,7 @@ qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
     if (rc < 0)
         goto cleanup;

-    if (!(ret = virBitmapNew(maxvcpus)))
-        goto cleanup;
+    ret = virBitmapNew(maxvcpus);

     for (i = 0; i < ncpuentries; i++) {
         if (cpuentries[i].halted)
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
index b0d1d0d083..ec52fe7ea5 100644
--- a/src/qemu/qemu_namespace.c
+++ b/src/qemu/qemu_namespace.c
@@ -799,9 +799,8 @@ qemuDomainEnableNamespace(virDomainObjPtr vm,
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;

-    if (!priv->namespaces &&
-        !(priv->namespaces = virBitmapNew(QEMU_DOMAIN_NS_LAST)))
-        return -1;
+    if (!priv->namespaces)
+        priv->namespaces = virBitmapNew(QEMU_DOMAIN_NS_LAST);

     if (virBitmapSetBit(priv->namespaces, ns) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9122069cc9..8814e61314 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5870,12 +5870,9 @@ qemuProcessValidateHotpluggableVcpus(virDomainDefPtr def)
     unsigned int maxvcpus = virDomainDefGetVcpusMax(def);
     size_t i = 0;
     size_t j;
-    virBitmapPtr ordermap = NULL;
+    virBitmapPtr ordermap = virBitmapNew(maxvcpus + 1);
     int ret = -1;

-    if (!(ordermap = virBitmapNew(maxvcpus + 1)))
-        goto cleanup;
-
     /* validate:
      * - all hotpluggable entities to be hotplugged have the correct data
      * - vcpus belonging to a hotpluggable entity share configuration
diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index d9105b0ff6..d2e4ed79be 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -83,9 +83,7 @@ qemuSlirpNew(void)
 {
     g_autoptr(qemuSlirp) slirp = g_new0(qemuSlirp, 1);

-    if (!(slirp->features = virBitmapNew(QEMU_SLIRP_FEATURE_LAST)))
-        return NULL;
-
+    slirp->features = virBitmapNew(QEMU_SLIRP_FEATURE_LAST);
     slirp->pid = (pid_t)-1;
     slirp->fd[0] = slirp->fd[1] = -1;

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index c2953c179b..47df102817 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -163,8 +163,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
     if (!(qemuImgPath = qemuFindQemuImgBinary(driver)))
         goto cleanup;

-    if (!(created = virBitmapNew(snapdef->ndisks)))
-        goto cleanup;
+    created = virBitmapNew(snapdef->ndisks);

     /* If reuse is true, then qemuSnapshotPrepare already
      * ensured that the new files exist, and it was up to the user to
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d582c207f4..af8fd03308 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1360,8 +1360,6 @@ testOpenDefault(virConnectPtr conn)
     }
     for (i = 0; i < 16; i++) {
         virBitmapPtr siblings = virBitmapNew(16);
-        if (!siblings)
-            goto error;
         ignore_value(virBitmapSetBit(siblings, i));
         privconn->cells[i / 8].cpus[(i % 8)].id = i;
         privconn->cells[i / 8].cpus[(i % 8)].socket_id = i / 8;
@@ -2788,8 +2786,7 @@ testDomainGetEmulatorPinInfo(virDomainPtr dom,
     } else if (def->cpumask) {
         cpumask = def->cpumask;
     } else {
-        if (!(bitmap = virBitmapNew(hostcpus)))
-            goto cleanup;
+        bitmap = virBitmapNew(hostcpus);
         virBitmapSetAll(bitmap);
         cpumask = bitmap;
     }
@@ -2966,9 +2963,7 @@ static int testDomainGetVcpus(virDomainPtr domain,
     statbase = g_get_real_time();

     hostcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo);
-    if (!(allcpumap = virBitmapNew(hostcpus)))
-        goto cleanup;
-
+    allcpumap = virBitmapNew(hostcpus);
     virBitmapSetAll(allcpumap);

     /* Clamp to actual number of vcpus */
@@ -3081,8 +3076,7 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
     if (!(def = virDomainObjGetOneDef(privdom, flags)))
         goto cleanup;

-    if (!(hostcpus = virBitmapNew(VIR_NODEINFO_MAXCPUS(driver->nodeInfo))))
-        goto cleanup;
+    hostcpus = virBitmapNew(VIR_NODEINFO_MAXCPUS(driver->nodeInfo));
     virBitmapSetAll(hostcpus);

     ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps,
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 1bff5d4ae6..74d1883d94 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -433,8 +433,7 @@ virBitmapParseSeparator(const char *str,
     size_t i;
     int start, last;

-    if (!(*bitmap = virBitmapNew(bitmapSize)))
-        return -1;
+    *bitmap = virBitmapNew(bitmapSize);

     if (!str)
         goto error;
@@ -664,10 +663,7 @@ virBitmapParseUnlimited(const char *str)
 virBitmapPtr
 virBitmapNewCopy(virBitmapPtr src)
 {
-    virBitmapPtr dst;
-
-    if ((dst = virBitmapNew(src->nbits)) == NULL)
-        return NULL;
+    virBitmapPtr dst = virBitmapNew(src->nbits);

     if (virBitmapCopy(dst, src) != 0) {
         virBitmapFree(dst);
@@ -699,8 +695,6 @@ virBitmapNewData(const void *data,
     const unsigned char *bytes = data;

     bitmap = virBitmapNew(len * CHAR_BIT);
-    if (!bitmap)
-        return NULL;

     /* le64toh is not available, so we do the conversion by hand */
     p = bitmap->map;
@@ -1115,8 +1109,6 @@ virBitmapNewString(const char *string)
     }

     bitmap = virBitmapNew(len * 4);
-    if (!bitmap)
-        return NULL;

     for (i = 0; i < len; i++) {
         unsigned long nibble = g_ascii_xdigit_value(string[len - i - 1]);
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 76f7eb9a3d..31c8c79fb3 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -571,8 +571,7 @@ virCommandMassClose(virCommandPtr cmd,
         return -1;
     }

-    if (!(fds = virBitmapNew(openmax)))
-        return -1;
+    fds = virBitmapNew(openmax);

 #  ifdef __linux__
     if (virCommandMassCloseGetFDsLinux(cmd, fds) < 0)
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index f60577b221..44aa7ad95d 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -768,14 +768,9 @@ dnsmasqCapsNewEmpty(const char *binaryPath)
         return NULL;
     if (!(caps = virObjectNew(dnsmasqCapsClass)))
         return NULL;
-    if (!(caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST)))
-        goto error;
+    caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST);
     caps->binaryPath = g_strdup(binaryPath ? binaryPath : DNSMASQ);
     return caps;
-
- error:
-    virObjectUnref(caps);
-    return NULL;
 }

 dnsmasqCapsPtr
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index c00a393def..28f032b972 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -268,8 +268,7 @@ virHostCPUGetSiblingsList(unsigned int cpu)
     if (rv == -2) {
         /* If the file doesn't exist, the threadis its only sibling */
         ret = virBitmapNew(cpu + 1);
-        if (ret)
-            ignore_value(virBitmapSetBit(ret, cpu));
+        ignore_value(virBitmapSetBit(ret, cpu));
     }

     return ret;
@@ -332,8 +331,7 @@ virHostCPUParseNode(const char *node,
         goto cleanup;

     /* Keep track of the CPUs that belong to the current node */
-    if (!(node_cpus_map = virBitmapNew(npresent_cpus)))
-        goto cleanup;
+    node_cpus_map = virBitmapNew(npresent_cpus);

     /* enumerate sockets in the node */
     sockets_map = virBitmapNew(0);
@@ -1119,9 +1117,7 @@ virHostCPUGetAvailableCPUsBitmap(void)
         if ((hostcpus = virHostCPUGetCount()) < 0)
             return NULL;

-        if (!(bitmap = virBitmapNew(hostcpus)))
-            return NULL;
-
+        bitmap = virBitmapNew(hostcpus);
         virBitmapSetAll(bitmap);
     }

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index c43823c747..76aeeba22a 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3331,8 +3331,7 @@ virNetDevGetFeatures(const char *ifname,
     struct ifreq ifr;
     VIR_AUTOCLOSE fd = -1;

-    if (!(*out = virBitmapNew(VIR_NET_DEV_FEAT_LAST)))
-        return -1;
+    *out = virBitmapNew(VIR_NET_DEV_FEAT_LAST);

     if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
         return -1;
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 5a1218cdf2..6728f62a87 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -273,8 +273,7 @@ virNumaGetNodeCPUs(int node,
         return -2;
     }

-    if (!(cpumap = virBitmapNew(max_n_cpus)))
-        return -1;
+    cpumap = virBitmapNew(max_n_cpus);

     for (i = 0; i < max_n_cpus; i++) {
         if (MASK_CPU_ISSET(mask, i)) {
@@ -1027,8 +1026,7 @@ virNumaGetHostMemoryNodeset(void)
     if (maxnode < 0)
         return NULL;

-    if (!(nodeset = virBitmapNew(maxnode + 1)))
-        return NULL;
+    nodeset = virBitmapNew(maxnode + 1);

     for (i = 0; i <= maxnode; i++) {
         if (!virNumaNodeIsAvailable(i))
diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index 2d34b617a6..f450740318 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -70,13 +70,9 @@ virPortAllocatorNew(void)
     if (!(pa = virObjectLockableNew(virPortAllocatorClass)))
         return NULL;

-    if (!(pa->bitmap = virBitmapNew(VIR_PORT_ALLOCATOR_NUM_PORTS)))
-        goto error;
+    pa->bitmap = virBitmapNew(VIR_PORT_ALLOCATOR_NUM_PORTS);

     return pa;
- error:
-    virObjectUnref(pa);
-    return NULL;
 }

 static int
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index e9df563896..d379f7446f 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -520,8 +520,7 @@ virProcessGetAffinity(pid_t pid)
         goto cleanup;
     }

-    if (!(ret = virBitmapNew(ncpus)))
-          goto cleanup;
+    ret = virBitmapNew(ncpus);

     for (i = 0; i < ncpus; i++) {
          /* coverity[overrun-local] */
@@ -580,8 +579,7 @@ virProcessGetAffinity(pid_t pid)
         return NULL;
     }

-    if (!(ret = virBitmapNew(sizeof(mask) * 8)))
-        return NULL;
+    ret = virBitmapNew(sizeof(mask) * 8);

     for (i = 0; i < sizeof(mask) * 8; i++)
         if (CPU_ISSET(i, &mask))
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 2d945ff934..dabfa9990e 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -1157,13 +1157,9 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr alloc,
                      cache - a_type->nmasks + 1) < 0)
         return -1;

-    if (!a_type->masks[cache]) {
+    if (!a_type->masks[cache])
         a_type->masks[cache] = virBitmapNew(virBitmapSize(mask));

-        if (!a_type->masks[cache])
-            return -1;
-    }
-
     return virBitmapCopy(a_type->masks[cache], mask);
 }

@@ -1874,8 +1870,6 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)

             virBitmapFree(mask);
             mask = virBitmapNew(i_type->bits);
-            if (!mask)
-                goto error;
             virBitmapSetAll(mask);

             for (k = 0; k <= i_type->max_cache_id; k++) {
@@ -2102,8 +2096,6 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc,
     }

     a_mask = virBitmapNew(i_type->bits);
-    if (!a_mask)
-        return -1;

     for (i = last_pos; i < last_pos + need_bits; i++)
         ignore_value(virBitmapSetBit(a_mask, i));
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 229de14935..a669b4ca99 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -852,8 +852,7 @@ qcow2GetFeatures(virBitmapPtr *features,
     if (len < QCOW2v3_HDR_SIZE)
         return -1;

-    if (!(feat = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST)))
-        return -1;
+    feat = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST);

     /* todo: check for incompatible or autoclear features? */
     bits = virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE);
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 4b1b04c6e1..fa4e685d97 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1509,8 +1509,6 @@ virVMXParseConfig(virVMXContext *ctx,
         size_t naffs;

         def->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
-        if (!def->cpumask)
-            goto cleanup;

         if (!(afflist = virStringSplitCount(sched_cpu_affinity, ",", 0, &naffs)))
             goto cleanup;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 3e7d55c50b..3e2f8ee01c 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1481,8 +1481,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
         return -1;

     if (strlen(buf) == 0) {
-        if (!(def->cpumask = virBitmapNew(hostcpus)))
-            return -1;
+        def->cpumask = virBitmapNew(hostcpus);
         virBitmapSetAll(def->cpumask);
     } else {
         if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index a0dcbba07b..3973c762f0 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2252,9 +2252,6 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
     }

     bitmap = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
-    if (!bitmap)
-        goto cleanup;
-
     ignore_value(virBitmapSetBit(bitmap, QEMU_MIGRATION_CAP_XBZRLE));
     if (!(json = qemuMigrationCapsToJSON(bitmap, bitmap)))
         goto cleanup;
diff --git a/tests/testutils.c b/tests/testutils.c
index b747f65eea..2e586e98bf 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -832,8 +832,7 @@ int virTestMain(int argc,
         }
     }

-    if (!(failedTests = virBitmapNew(1)))
-        return EXIT_FAILURE;
+    failedTests = virBitmapNew(1);

     ret = (func)();

@@ -980,9 +979,7 @@ virTestCapsBuildNUMATopology(int seq)
             cell_cpus[core_id].id = id + core_id;
             cell_cpus[core_id].socket_id = cell_id + seq;
             cell_cpus[core_id].core_id = id + core_id;
-            if (!(cell_cpus[core_id].siblings =
-                  virBitmapNew(MAX_CPUS_IN_CELL)))
-                goto error;
+            cell_cpus[core_id].siblings = virBitmapNew(MAX_CPUS_IN_CELL);
             ignore_value(virBitmapSetBit(cell_cpus[core_id].siblings, id));
         }
         id++;
@@ -997,10 +994,6 @@ virTestCapsBuildNUMATopology(int seq)
     }

     return g_steal_pointer(&caps);
-
- error:
-    VIR_FREE(cell_cpus);
-    return NULL;
 }

 static virDomainDefParserConfig virTestGenericDomainDefParserConfig = {
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 255492c9e8..5d2f1b0bad 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -36,8 +36,7 @@ test1(const void *data G_GNUC_UNUSED)

     size = 1024;
     bit = 100;
-    if (!(bitmap = virBitmapNew(size)))
-        return -1;
+    bitmap = virBitmapNew(size);

     if (virBitmapSetBit(bitmap, bit) < 0)
         return -1;
@@ -140,8 +139,7 @@ test3(const void *data G_GNUC_UNUSED)
     int size = 5;
     size_t i;

-    if ((bitmap = virBitmapNew(size)) == NULL)
-        return -1;
+    bitmap = virBitmapNew(size);

     for (i = 0; i < size; i++)
         ignore_value(virBitmapSetBit(bitmap, i));
@@ -195,8 +193,6 @@ test4(const void *data G_GNUC_UNUSED)
     /* 1. zero set */

     bitmap = virBitmapNew(size);
-    if (!bitmap)
-        return -1;

     if (virBitmapNextSetBit(bitmap, -1) != -1)
         return -1;
@@ -337,8 +333,6 @@ test6(const void *v G_GNUC_UNUSED)
     int size = 64;

     bitmap = virBitmapNew(size);
-    if (!bitmap)
-        return -1;

     str = virBitmapFormat(bitmap);
     if (!str)
@@ -416,8 +410,6 @@ test7(const void *v G_GNUC_UNUSED)

     for (i = 0; i < nmaxBit; i++) {
         g_autoptr(virBitmap) bitmap = virBitmapNew(maxBit[i]);
-        if (!bitmap)
-            return -1;

         if (virBitmapIsAllSet(bitmap))
             return -1;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index dfcba04682..b5e7d8f705 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6840,8 +6840,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl,
     if (curvcpus == 0)
         curvcpus = maxvcpus;

-    if (!(ret = virBitmapNew(maxvcpus)))
-        goto cleanup;
+    ret = virBitmapNew(maxvcpus);

     if ((nnodes = virXPathNodeSet("/domain/vcpus/vcpu", ctxt, &nodes)) <= 0) {
         /* if the specific vcpu state is missing provide a fallback */
@@ -7118,8 +7117,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
     virBitmapPtr map = NULL;

     if (cpulist[0] == 'r') {
-        if (!(map = virBitmapNew(maxcpu)))
-            return NULL;
+        map = virBitmapNew(maxcpu);
         virBitmapSetAll(map);
     } else {
         int lastcpu;
@@ -11989,8 +11987,7 @@ virshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2)
     if (n1_child_size == 0 && n2_child_size == 0)
         return true;

-    if (!(bitmap = virBitmapNew(n1_child_size)))
-        return false;
+    bitmap = virBitmapNew(n1_child_size);

     child2 = n2->children;
     while (child2) {
-- 
2.26.2




[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]

  Powered by Linux