diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index da54591c1122893f9f18228d4fc630cb3736dd5d..82129feaac6b133f08110b81d4efb62ff0e9050e 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -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; } diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index a55dcd5f91ace5e7c51b7cf9ecadcfa45f7b9202..fdccc585fbf0de7a0acaed6765473219905788dd 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -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; }