From: Peter Krempa <pkre...@redhat.com> Automatically free temporary variables in order to remove 'cleanup' section.
Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/security/security_selinux.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 67d9da461a..3004320380 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1025,8 +1025,8 @@ virSecuritySELinuxReserveLabel(virSecurityManager *mgr, virDomainDef *def, pid_t pid) { - char *pctx; - context_t ctx = NULL; + g_autofree char *pctx = NULL; + g_autoptr(context_s_t) ctx = NULL; const char *mcs; int rv; virSecurityLabelDef *seclabel; @@ -1045,31 +1045,23 @@ virSecuritySELinuxReserveLabel(virSecurityManager *mgr, ctx = context_new(pctx); if (!ctx) - goto error; + return -1; mcs = context_range_get(ctx); if (!mcs) - goto error; + return -1; if ((rv = virSecuritySELinuxMCSAdd(mgr, mcs)) < 0) - goto error; + return -1; if (rv == 1) { virReportError(VIR_ERR_INTERNAL_ERROR, _("MCS level for existing domain label %1$s already reserved"), (char*)pctx); - goto error; + return -1; } - freecon(pctx); - context_free(ctx); - return 0; - - error: - freecon(pctx); - context_free(ctx); - return -1; } -- 2.50.0