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

conf: Get rid of "no_memory" labels

As pointed out by Ján Tomko, "no_memory seems suspicious in the times of
abort()".

As libvirt decided to take the path to not report OOM and simply abort
when it happens, let's get rid of the no_memory labels and simplify the
code around them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-12-20 13:43:11 +01:00 committed by Cole Robinson
parent 110fef7677
commit ca49b6eccf
2 changed files with 13 additions and 43 deletions

View File

@ -619,26 +619,16 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
const char *type,
const char *label)
{
char *t = NULL, *l = NULL;
if (type == NULL || label == NULL)
return -1;
t = g_strdup(type);
l = g_strdup(label);
if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0)
goto no_memory;
return -1;
secmodel->labels[secmodel->nlabels - 1].type = t;
secmodel->labels[secmodel->nlabels - 1].label = l;
secmodel->labels[secmodel->nlabels - 1].type = g_strdup(type);
secmodel->labels[secmodel->nlabels - 1].label = g_strdup(label);
return 0;
no_memory:
VIR_FREE(l);
VIR_FREE(t);
return -1;
}

View File

@ -89,12 +89,12 @@ virDomainAuditGenericDev(virDomainObjPtr vm,
const char *reason,
bool success)
{
char *newdev = NULL;
char *olddev = NULL;
g_autofree char *newdev = NULL;
g_autofree char *olddev = NULL;
g_autofree char *vmname = NULL;
g_autofree char *oldsrc = NULL;
g_autofree char *newsrc = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = NULL;
char *oldsrc = NULL;
char *newsrc = NULL;
const char *virt = virDomainAuditGetVirtType(vm->def);
/* if both new and old source aren't provided don't log anything */
@ -107,29 +107,17 @@ virDomainAuditGenericDev(virDomainObjPtr vm,
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name)))
goto no_memory;
return;
if (!(newsrc = virAuditEncode(newdev, VIR_AUDIT_STR(newsrcpath))))
goto no_memory;
return;
if (!(oldsrc = virAuditEncode(olddev, VIR_AUDIT_STR(oldsrcpath))))
goto no_memory;
return;
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
"virt=%s resrc=%s reason=%s %s uuid=%s %s %s",
virt, type, reason, vmname, uuidstr, oldsrc, newsrc);
cleanup:
VIR_FREE(newdev);
VIR_FREE(olddev);
VIR_FREE(vmname);
VIR_FREE(oldsrc);
VIR_FREE(newsrc);
return;
no_memory:
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
@ -957,13 +945,13 @@ virDomainAuditInput(virDomainObjPtr vm,
bool success)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
g_autofree char *vmname = NULL;
const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name)))
goto no_memory;
return;
switch ((virDomainInputType) input->type) {
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
@ -980,12 +968,4 @@ virDomainAuditInput(virDomainObjPtr vm,
case VIR_DOMAIN_INPUT_TYPE_LAST:
break;
}
cleanup:
VIR_FREE(vmname);
return;
no_memory:
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}