[libvirt PATCH 2/7] Do not check return value of VIR_RESIZE_N

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/bhyve/bhyve_capabilities.c  |  5 +----
 src/bhyve/bhyve_parse_command.c | 11 ++--------
 src/conf/capabilities.c         | 36 ++++++++-------------------------
 src/conf/cpu_conf.c             | 11 ++--------
 src/conf/domain_capabilities.c  |  5 ++---
 src/esx/esx_driver.c            |  3 +--
 src/hyperv/hyperv_driver.c      |  3 +--
 src/qemu/qemu_domain.c          | 13 +++++-------
 src/util/virbitmap.c            |  5 ++---
 src/util/vircommand.c           | 16 +++++++--------
 src/util/virfile.c              |  3 +--
 src/util/virfirewall.c          |  5 +----
 src/util/virnetlink.c           |  7 +++----
 src/util/virtypedparam-public.c | 24 ++++++++--------------
 src/util/virtypedparam.c        |  6 ++----
 src/util/viruri.c               |  8 +-------
 src/util/virutil.c              | 14 ++++---------
 tests/viralloctest.c            |  3 +--
 18 files changed, 53 insertions(+), 125 deletions(-)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index e9b4e5176d..efd6a59aec 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -154,10 +154,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
 
     if (virDirOpenIfExists(&dir, firmware_dir) > 0) {
         while ((virDirRead(dir, &entry, firmware_dir)) > 0) {
-            if (VIR_RESIZE_N(firmwares->values,
-                firmwares_alloc, firmwares->nvalues, 1) < 0)
-                goto cleanup;
-
+            VIR_RESIZE_N(firmwares->values, firmwares_alloc, firmwares->nvalues, 1);
             firmwares->values[firmwares->nvalues] = g_strdup_printf("%s/%s",
                                                     firmware_dir, entry->d_name);
             firmwares->nvalues++;
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index 2762b7e921..8d9a21e671 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -153,10 +153,7 @@ bhyveCommandLineToArgv(const char *nativeConfig,
         else
             line = g_strdup(curr);
 
-        if (VIR_RESIZE_N(lines, lines_alloc, line_count, 2) < 0) {
-            VIR_FREE(line);
-            goto error;
-        }
+        VIR_RESIZE_N(lines, lines_alloc, line_count, 2);
 
         if (*line)
             lines[line_count++] = line;
@@ -203,11 +200,7 @@ bhyveCommandLineToArgv(const char *nativeConfig,
             if (next && (*next == '\'' || *next == '"'))
                 next++;
 
-            if (VIR_RESIZE_N(arglist, args_alloc, args_count, 2) < 0) {
-                VIR_FREE(arg);
-                goto error;
-            }
-
+            VIR_RESIZE_N(arglist, args_alloc, args_count, 2);
             arglist[args_count++] = arg;
             arglist[args_count] = NULL;
 
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index f610975ae5..14f0d48930 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -280,10 +280,8 @@ int
 virCapabilitiesAddHostFeature(virCapsPtr caps,
                               const char *name)
 {
-    if (VIR_RESIZE_N(caps->host.features, caps->host.nfeatures_max,
-                     caps->host.nfeatures, 1) < 0)
-        return -1;
-
+    VIR_RESIZE_N(caps->host.features, caps->host.nfeatures_max,
+                 caps->host.nfeatures, 1);
     caps->host.features[caps->host.nfeatures] = g_strdup(name);
     caps->host.nfeatures++;
 
@@ -301,10 +299,8 @@ int
 virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
                                        const char *name)
 {
-    if (VIR_RESIZE_N(caps->host.migrateTrans, caps->host.nmigrateTrans_max,
-                     caps->host.nmigrateTrans, 1) < 0)
-        return -1;
-
+    VIR_RESIZE_N(caps->host.migrateTrans, caps->host.nmigrateTrans_max,
+                 caps->host.nmigrateTrans, 1);
     caps->host.migrateTrans[caps->host.nmigrateTrans] = g_strdup(name);
     caps->host.nmigrateTrans++;
 
@@ -447,9 +443,7 @@ virCapabilitiesAddGuest(virCapsPtr caps,
     guest->arch.defaultInfo.emulator = g_strdup(emulator);
     guest->arch.defaultInfo.loader = g_strdup(loader);
 
-    if (VIR_RESIZE_N(caps->guests, caps->nguests_max,
-                     caps->nguests, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(caps->guests, caps->nguests_max, caps->nguests, 1);
     caps->guests[caps->nguests++] = guest;
 
     if (nmachines) {
@@ -458,10 +452,6 @@ virCapabilitiesAddGuest(virCapsPtr caps,
     }
 
     return guest;
-
- error:
-    virCapabilitiesFreeGuest(guest);
-    return NULL;
 }
 
 
@@ -493,9 +483,8 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
     dom->info.emulator = g_strdup(emulator);
     dom->info.loader = g_strdup(loader);
 
-    if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
-                     guest->arch.ndomains, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
+                 guest->arch.ndomains, 1);
     guest->arch.domains[guest->arch.ndomains] = dom;
     guest->arch.ndomains++;
 
@@ -505,10 +494,6 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
     }
 
     return dom;
-
- error:
-    virCapabilitiesFreeGuestDomain(dom);
-    return NULL;
 }
 
 
@@ -803,15 +788,10 @@ virCapabilitiesAddStoragePool(virCapsPtr caps,
 
     pool->type = poolType;
 
-    if (VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1);
     caps->pools[caps->npools++] = pool;
 
     return 0;
-
- error:
-    virCapabilitiesFreeStoragePool(pool);
-    return -1;
 }
 
 
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 8d800bd80d..380a74691d 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -593,10 +593,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
             return -1;
         }
 
-        if (VIR_RESIZE_N(def->features, def->nfeatures_max,
-                         def->nfeatures, n) < 0)
-            return -1;
-
+        VIR_RESIZE_N(def->features, def->nfeatures_max, def->nfeatures, n);
         def->nfeatures = n;
     }
 
@@ -898,12 +895,8 @@ virCPUDefAddFeatureInternal(virCPUDefPtr def,
         }
     }
 
-    if (VIR_RESIZE_N(def->features, def->nfeatures_max,
-                     def->nfeatures, 1) < 0)
-        return -1;
-
+    VIR_RESIZE_N(def->features, def->nfeatures_max, def->nfeatures, 1);
     def->features[def->nfeatures].name = g_strdup(name);
-
     def->features[def->nfeatures].policy = policy;
     def->nfeatures++;
 
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index fc48cc3fba..e0d7eddd2c 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -191,9 +191,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
 
     nameCopy = g_strdup(name);
 
-    if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max,
-                     cpuModels->nmodels, 1) < 0)
-        return -1;
+    VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max,
+                 cpuModels->nmodels, 1);
 
     cpu = cpuModels->models + cpuModels->nmodels;
     cpuModels->nmodels++;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 96cc8bda0d..9d73bc6de8 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4917,8 +4917,7 @@ esxConnectListAllDomains(virConnectPtr conn,
             continue;
         }
 
-        if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(doms, ndoms, count, 2);
 
         /* Only running/suspended virtual machines have an ID != -1 */
         if (powerState == esxVI_VirtualMachinePowerState_PoweredOff)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index e4f537bd12..17f5be1f0d 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -3524,8 +3524,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
             continue;
         }
 
-        if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(doms, ndoms, count, 2);
 
         domain = NULL;
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fff67481a7..3b54adc614 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4287,10 +4287,8 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def,
                 sveFeature->policy = VIR_CPU_FEATURE_REQUIRE;
             }
         } else {
-            if (VIR_RESIZE_N(def->cpu->features, def->cpu->nfeatures_max,
-                             def->cpu->nfeatures, 1) < 0) {
-                return -1;
-            }
+            VIR_RESIZE_N(def->cpu->features, def->cpu->nfeatures_max,
+                         def->cpu->nfeatures, 1);
 
             def->cpu->features[def->cpu->nfeatures].name = g_strdup("sve");
             def->cpu->features[def->cpu->nfeatures].policy = VIR_CPU_FEATURE_REQUIRE;
@@ -7340,10 +7338,9 @@ qemuDomainCleanupAdd(virDomainObjPtr vm,
             return 0;
     }
 
-    if (VIR_RESIZE_N(priv->cleanupCallbacks,
-                     priv->ncleanupCallbacks_max,
-                     priv->ncleanupCallbacks, 1) < 0)
-        return -1;
+    VIR_RESIZE_N(priv->cleanupCallbacks,
+                 priv->ncleanupCallbacks_max,
+                 priv->ncleanupCallbacks, 1);
 
     priv->cleanupCallbacks[priv->ncleanupCallbacks++] = cb;
     return 0;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index b2569b0b03..9242af6fb5 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -139,9 +139,8 @@ virBitmapExpand(virBitmapPtr map,
 
     /* resize the memory if necessary */
     if (map->map_len < new_len) {
-        if (VIR_RESIZE_N(map->map, map->map_alloc, map->map_len,
-                         new_len - map->map_len) < 0)
-            return -1;
+        VIR_RESIZE_N(map->map, map->map_alloc, map->map_len,
+                     new_len - map->map_len);
     }
 
     map->nbits = b + 1;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 99bb8b6506..d647463f35 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1358,7 +1358,7 @@ virCommandAddEnv(virCommandPtr cmd,
     }
 
     /* Arg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1));
+    VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1);
 
     cmd->env[cmd->nenv++] = g_steal_pointer(&env);
 }
@@ -1459,7 +1459,7 @@ virCommandAddEnvPassCommon(virCommandPtr cmd)
     if (virCommandHasError(cmd))
         return;
 
-    ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9));
+    VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9);
 
     virCommandAddEnvPair(cmd, "LC_ALL", "C");
 
@@ -1479,7 +1479,7 @@ virCommandAddEnvXDG(virCommandPtr cmd, const char *baseDir)
     if (virCommandHasError(cmd))
         return;
 
-    ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3));
+    VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3);
 
     virCommandAddEnvFormat(cmd, "XDG_DATA_HOME=%s/%s",
                            baseDir, ".local/share");
@@ -1509,7 +1509,7 @@ virCommandAddArg(virCommandPtr cmd, const char *val)
     }
 
     /* Arg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1));
+    VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1);
 
     cmd->args[cmd->nargs++] = g_strdup(val);
 }
@@ -1535,7 +1535,7 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferPtr buf)
         str = g_strdup("");
 
     /* Arg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1));
+    VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1);
 
     cmd->args[cmd->nargs] = g_steal_pointer(&str);
     cmd->nargs++;
@@ -1564,7 +1564,7 @@ virCommandAddArgFormat(virCommandPtr cmd, const char *format, ...)
     va_end(list);
 
     /* Arg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1));
+    VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1);
 
     cmd->args[cmd->nargs++] = arg;
 }
@@ -1611,7 +1611,7 @@ virCommandAddArgSet(virCommandPtr cmd, const char *const*vals)
         narg++;
 
     /* narg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1));
+    VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1);
 
     narg = 0;
     while (vals[narg] != NULL) {
@@ -1644,7 +1644,7 @@ virCommandAddArgList(virCommandPtr cmd, ...)
     va_end(list);
 
     /* narg plus trailing NULL. */
-    ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1));
+    VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1);
 
     va_start(list, cmd);
     while (1) {
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 180f2af405..56d6e0605e 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3123,8 +3123,7 @@ virFileOpenTty(int *ttyprimary, char **ttyName, int rawmode)
         name = g_new0(char, len);
 
         while ((rc = ttyname_r(secondary, name, len)) == ERANGE) {
-            if (VIR_RESIZE_N(name, len, len, len) < 0)
-                goto cleanup;
+            VIR_RESIZE_N(name, len, len, len);
         }
         if (rc != 0) {
             errno = rc;
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 0dc0cecd53..dd3e104dbe 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -262,10 +262,7 @@ void virFirewallFree(virFirewallPtr firewall)
 
 #define ADD_ARG(rule, str) \
     do { \
-        ignore_value(VIR_RESIZE_N(rule->args, \
-                                  rule->argsAlloc, \
-                                  rule->argsLen, 1)); \
- \
+        VIR_RESIZE_N(rule->args, rule->argsAlloc, rule->argsLen, 1); \
         rule->args[rule->argsLen++] = g_strdup(str); \
     } while (0)
 
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index cfb86550a5..c26c03de32 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -1146,9 +1146,8 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
     if (srv->handlesCount == srv->handlesAlloc) {
         VIR_DEBUG("Used %zu handle slots, adding at least %d more",
                   srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT);
-        if (VIR_RESIZE_N(srv->handles, srv->handlesAlloc,
-                         srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < 0)
-            goto error;
+        VIR_RESIZE_N(srv->handles, srv->handlesAlloc,
+                     srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT);
     }
     r = srv->handlesCount++;
 
@@ -1167,7 +1166,7 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
     VIR_DEBUG("added client to loop slot: %d. with macaddr ptr=%p", r, macaddr);
 
     ret = nextWatch++;
- error:
+
     virNetlinkEventServerUnlock(srv);
     return ret;
 }
diff --git a/src/util/virtypedparam-public.c b/src/util/virtypedparam-public.c
index 91603cfe1c..4cb54f7ab1 100644
--- a/src/util/virtypedparam-public.c
+++ b/src/util/virtypedparam-public.c
@@ -446,8 +446,7 @@ virTypedParamsAddInt(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -493,8 +492,7 @@ virTypedParamsAddUInt(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -540,8 +538,7 @@ virTypedParamsAddLLong(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -587,8 +584,7 @@ virTypedParamsAddULLong(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -634,8 +630,7 @@ virTypedParamsAddDouble(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -681,8 +676,7 @@ virTypedParamsAddBoolean(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssign(*params + n, name,
@@ -731,8 +725,7 @@ virTypedParamsAddString(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     str = g_strdup(value);
@@ -823,8 +816,7 @@ virTypedParamsAddFromString(virTypedParameterPtr *params,
 
     virResetLastError();
 
-    if (VIR_RESIZE_N(*params, max, n, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(*params, max, n, 1);
     *maxparams = max;
 
     if (virTypedParameterAssignFromStr(*params + n, name, type, value) < 0)
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index c4c26a1183..1b89233012 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -77,8 +77,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...)
     name = va_arg(ap, const char *);
     while (name) {
         type = va_arg(ap, int);
-        if (VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1);
 
         if (virStrcpyStatic(keys[nkeys].field, name) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -758,8 +757,7 @@ virTypedParamSetNameVPrintf(virTypedParameterPtr par,
 static virTypedParameterPtr
 virTypedParamListExtend(virTypedParamListPtr list)
 {
-    if (VIR_RESIZE_N(list->par, list->par_alloc, list->npar, 1) < 0)
-        return NULL;
+    VIR_RESIZE_N(list->par, list->par_alloc, list->npar, 1);
 
     list->npar++;
 
diff --git a/src/util/viruri.c b/src/util/viruri.c
index 1e8808ddc6..90594fce5e 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -45,8 +45,7 @@ virURIParamAppend(virURIPtr uri,
     pname = g_strdup(name);
     pvalue = g_strdup(value);
 
-    if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) < 0)
-        goto error;
+    VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1);
 
     uri->params[uri->paramsCount].name = pname;
     uri->params[uri->paramsCount].value = pvalue;
@@ -54,11 +53,6 @@ virURIParamAppend(virURIPtr uri,
     uri->paramsCount++;
 
     return 0;
-
- error:
-    VIR_FREE(pname);
-    VIR_FREE(pvalue);
-    return -1;
 }
 
 
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 118ceec0db..3f49a469e5 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -618,8 +618,7 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, char **dir, char **shell, bo
      *        The given name or uid was not found.
      */
     while ((rc = getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw)) == ERANGE) {
-        if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen);
     }
 
     if (rc != 0) {
@@ -687,10 +686,7 @@ static char *virGetGroupEnt(gid_t gid)
      *        The given name or gid was not found.
      */
     while ((rc = getgrgid_r(gid, &grbuf, strbuf, strbuflen, &gr)) == ERANGE) {
-        if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) {
-            VIR_FREE(strbuf);
-            return NULL;
-        }
+        VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen);
     }
     if (rc != 0 || gr == NULL) {
         if (rc != 0) {
@@ -765,8 +761,7 @@ virGetUserIDByName(const char *name, uid_t *uid, bool missing_ok)
     strbuf = g_new0(char, strbuflen);
 
     while ((rc = getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw)) == ERANGE) {
-        if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen);
     }
 
     if (!pw) {
@@ -846,8 +841,7 @@ virGetGroupIDByName(const char *name, gid_t *gid, bool missing_ok)
     strbuf = g_new0(char, strbuflen);
 
     while ((rc = getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr)) == ERANGE) {
-        if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
-            goto cleanup;
+        VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen);
     }
 
     if (!gr) {
diff --git a/tests/viralloctest.c b/tests/viralloctest.c
index 0867be8ce1..4794fd7f93 100644
--- a/tests/viralloctest.c
+++ b/tests/viralloctest.c
@@ -214,8 +214,7 @@ testResizeArray(const void *opaque G_GNUC_UNUSED)
         t[i].b = 20;
     }
 
-    if (VIR_RESIZE_N(t, at, nt, 8) < 0)
-        goto cleanup;
+    VIR_RESIZE_N(t, at, nt, 8);
 
     if (testCheckNonNull(t) < 0)
         goto cleanup;
-- 
2.31.0




[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