From nobody Sun Feb 8 15:01:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623926763; cv=none; d=zohomail.com; s=zohoarc; b=iY/1+dYRdJMgbKe131J150cxm5YwjijGb69CFwPLSTSIu5efI1MPcMyTKHyob/whxtmxTXwseZBTQOGjatgix8PFT7LyQX11Lr159NZjCToXVHtQANyy3iFNgUc+cqpGFt86DAAQ8kKMrangJPz/mxY41huKvveqQPMcOsEVC38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623926763; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g5T+LjQ0cWr6IuOtp6eJTxqctvCfkly9N6A3oe0rV0U=; b=gbsQNLU0nhjAr5jOpg/wFjD5l2+dNNtaCzOxPY11faDT8ZK5R9/7pqB2YJeiw7Kbc6GT24e2FUGwRo4+lUrhT9FC3ITNNFjbDIk7FJ0adE631P5qdvEPpJRRFY7ukjyTTMEpTzgEIoGZ2dy+y+wVHSSAx3OG3qvi39xjRXvED2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623926763785563.7636255539678; Thu, 17 Jun 2021 03:46:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-I3GujYJqPeiuTc0ifpeQ0A-1; Thu, 17 Jun 2021 06:45:07 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42698802575; Thu, 17 Jun 2021 10:45:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 176B51007623; Thu, 17 Jun 2021 10:45:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C800B46F5F; Thu, 17 Jun 2021 10:45:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15HAgGZr018874 for ; Thu, 17 Jun 2021 06:42:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5356B19D9D; Thu, 17 Jun 2021 10:42:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB4B819D7D for ; Thu, 17 Jun 2021 10:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623926762; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=g5T+LjQ0cWr6IuOtp6eJTxqctvCfkly9N6A3oe0rV0U=; b=fbk4J92VALylvuAK5zPnwSAtH2Rp3qyS1i+P84Q7L3nYgKXLMYaxV53Td0pBLIvZ6LkyR+ sxZ4C+4pLzyhO2O2oo0odgxU+2IxEbke5++v53TE/YCYJFNberINZSzFroZWHITS/Y4yjC jaXkhIvfVAEytxR6Z1ZM5nH/XksgmFc= X-MC-Unique: I3GujYJqPeiuTc0ifpeQ0A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/8] security_dac: Introduce g_autoptr for virSecurityDACChownList Date: Thu, 17 Jun 2021 12:42:03 +0200 Message-Id: <000a4dc6fe6d688e1ba5caa1c09cfc26ba5497c8.1623926317.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/security/security_dac.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 70617759c9..6b8ff5cdef 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -143,6 +143,8 @@ virSecurityDACChownListFree(void *opaque) g_free(list); } =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSecurityDACChownList, virSecurityDACChown= ListFree); + =20 /** * virSecurityDACTransactionAppend: @@ -552,10 +554,9 @@ virSecurityDACPreFork(virSecurityManager *mgr) static int virSecurityDACTransactionStart(virSecurityManager *mgr) { - virSecurityDACChownList *list; + g_autoptr(virSecurityDACChownList) list =3D NULL; =20 - list =3D virThreadLocalGet(&chownList); - if (list) { + if (virThreadLocalGet(&chownList)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Another relabel transaction is already started")= ); return -1; @@ -568,9 +569,9 @@ virSecurityDACTransactionStart(virSecurityManager *mgr) if (virThreadLocalSet(&chownList, list) < 0) { virReportSystemError(errno, "%s", _("Unable to set thread local variable")); - virSecurityDACChownListFree(list); return -1; } + list =3D NULL; =20 return 0; } @@ -601,21 +602,20 @@ virSecurityDACTransactionCommit(virSecurityManager *m= gr G_GNUC_UNUSED, pid_t pid, bool lock) { - virSecurityDACChownList *list; + g_autoptr(virSecurityDACChownList) list =3D NULL; int rc; - int ret =3D -1; =20 list =3D virThreadLocalGet(&chownList); if (!list) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No transaction is set")); - goto cleanup; + return -1; } =20 if (virThreadLocalSet(&chownList, NULL) < 0) { virReportSystemError(errno, "%s", _("Unable to clear thread local variable")); - goto cleanup; + return -1; } =20 list->lock =3D lock; @@ -628,7 +628,7 @@ virSecurityDACTransactionCommit(virSecurityManager *mgr= G_GNUC_UNUSED, if (virGetLastErrorCode() =3D=3D VIR_ERR_SYSTEM_ERROR) pid =3D -1; else - goto cleanup; + return -1; } } =20 @@ -640,12 +640,9 @@ virSecurityDACTransactionCommit(virSecurityManager *mg= r G_GNUC_UNUSED, } =20 if (rc < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - virSecurityDACChownListFree(list); - return ret; + return 0; } =20 /** @@ -657,7 +654,7 @@ virSecurityDACTransactionCommit(virSecurityManager *mgr= G_GNUC_UNUSED, static void virSecurityDACTransactionAbort(virSecurityManager *mgr G_GNUC_UNUSED) { - virSecurityDACChownList *list; + g_autoptr(virSecurityDACChownList) list =3D NULL; =20 list =3D virThreadLocalGet(&chownList); if (!list) @@ -665,7 +662,6 @@ virSecurityDACTransactionAbort(virSecurityManager *mgr = G_GNUC_UNUSED) =20 if (virThreadLocalSet(&chownList, NULL) < 0) VIR_DEBUG("Unable to clear thread local variable"); - virSecurityDACChownListFree(list); } =20 =20 --=20 2.31.1