1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

conf: nwfilter_params: use g_new0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Ján Tomko 2020-10-07 21:15:19 +02:00
parent d5b05614df
commit 1eb1413410

View File

@ -70,8 +70,7 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val)
size_t i;
char *str;
if (VIR_ALLOC(res) < 0)
return NULL;
res = g_new0(virNWFilterVarValue, 1);
res->valType = val->valType;
switch (res->valType) {
@ -79,8 +78,7 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val)
res->u.simple.value = g_strdup(val->u.simple.value);
break;
case NWFILTER_VALUE_TYPE_ARRAY:
if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0)
goto err_exit;
res->u.array.values = g_new0(char *, val->u.array.nValues);
res->u.array.nValues = val->u.array.nValues;
for (i = 0; i < val->u.array.nValues; i++) {
str = g_strdup(val->u.array.values[i]);
@ -92,10 +90,6 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val)
}
return res;
err_exit:
virNWFilterVarValueFree(res);
return NULL;
}
virNWFilterVarValuePtr
@ -109,8 +103,7 @@ virNWFilterVarValueCreateSimple(char *value)
return NULL;
}
if (VIR_ALLOC(val) < 0)
return NULL;
val = g_new0(virNWFilterVarValue, 1);
val->valType = NWFILTER_VALUE_TYPE_SIMPLE;
val->u.simple.value = value;
@ -219,10 +212,7 @@ virNWFilterVarValueAddValue(virNWFilterVarValuePtr val, char *value)
case NWFILTER_VALUE_TYPE_SIMPLE:
/* switch to array */
tmp = val->u.simple.value;
if (VIR_ALLOC_N(val->u.array.values, 2) < 0) {
val->u.simple.value = tmp;
return -1;
}
val->u.array.values = g_new0(char *, 2);
val->valType = NWFILTER_VALUE_TYPE_ARRAY;
val->u.array.nValues = 2;
val->u.array.values[0] = tmp;
@ -870,8 +860,7 @@ virNWFilterVarAccessParse(const char *varAccess)
virNWFilterVarAccessPtr dest;
const char *input = varAccess;
if (VIR_ALLOC(dest) < 0)
return NULL;
dest = g_new0(virNWFilterVarAccess, 1);
idx = strspn(input, VALID_VARNAME);