提交 ca49b6ec 编写于 作者: F Fabiano Fidêncio 提交者: Cole Robinson

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: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NFabiano Fidêncio <fidencio@redhat.com>
上级 110fef76
......@@ -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;
}
......
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册