From nobody Tue Sep 9 19:27:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1753104383; cv=none; d=zohomail.com; s=zohoarc; b=nGd9gd5j1jIb4OQ+C1eEIwBhCP0TXibZNQiLNs+LYxev6f3qPE33cha/UsKiIGo0+81bd9cvGuPskVJuZRq8MhHmAIksHFCmctp1yXJPZXBzL+kPsCRQ+aHxGjVjpgM3dzifLhvNG/lNS5EJUyL5kNfYFr1DwCOpOXeRlMT+BSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753104383; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=YHWdrxhbqzR7G534HgyjQxvnd+MsxMq48LchEsEku+A=; b=d/e7UXhTPgXBS2NWlNgu7d37kTDmqqcgEVO8A/6UxKj8lJGjOQsvvSdlIGcL5OPFgxwQk+i7WqmDZEzzRBt1TnX3opN3+xlsft+XfpqaP9YulLVKMX5DsNQpNaw2ZFjD72dMwuqY18Y9CRZ+qqNA7XFgMHYJyepE0AzM9DYrc7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1753104383249166.18398893722906; Mon, 21 Jul 2025 06:26:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 51981143B; Mon, 21 Jul 2025 09:26:22 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3C94B11F4; Mon, 21 Jul 2025 09:21:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D359911A8; Mon, 21 Jul 2025 09:21:38 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 58EE811A8 for ; Mon, 21 Jul 2025 09:21:20 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-O0jMAJRwN_2-c2wqfbhv9g-1; Mon, 21 Jul 2025 09:21:18 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD9D018001F7 for ; Mon, 21 Jul 2025 13:21:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.44.22.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1AE59180035E for ; Mon, 21 Jul 2025 13:21:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753104080; h=from:from: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; bh=Ij68HOqfxNJIuSAVX9JqXrYndeWgpuITzXNUO13fHXw=; b=WH5MJfiUsl7pwNon6UualuctcvpEyWWq3hotimSt/449FO5G+4SCVItCevmv5w81nvDySm so/mXNa6HIX+Xv5YLqP4lsFTw6ZHF2Kv+PBSTXrIouzVkqB/qPtZkgifJlP8VnH/xsBOCP xFf+Nsl0GHiDdKIKbpZK/PM/AFt9E8s= X-MC-Unique: O0jMAJRwN_2-c2wqfbhv9g-1 X-Mimecast-MFC-AGG-ID: O0jMAJRwN_2-c2wqfbhv9g_1753104077 To: devel@lists.libvirt.org Subject: [PATCH 12/19] virSecuritySELinuxContextAddRange: Refactor cleanup of 'context_t' Date: Mon, 21 Jul 2025 15:20:53 +0200 Message-ID: <2024a71eb89bb8c99787745fba599e495066bdd4.1753103831.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JNt4lp58TlK9fyqkk7puficZP84esObh0DaxWzloRs4_1753104077 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JIJH4Y4GHOGXDSSZXDYDVJYPI6VZQLDS X-Message-ID-Hash: JIJH4Y4GHOGXDSSZXDYDVJYPI6VZQLDS X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1753104385512116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Use the new autoptr helper to free the temporary variables and refactor cleanup. Signed-off-by: Peter Krempa --- src/security/security_selinux.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 87348f36fa..55a5593fa5 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -572,37 +572,31 @@ virSecuritySELinuxContextAddRange(const char *src, const char *dst) { const char *str =3D NULL; - char *ret =3D NULL; - context_t srccon =3D NULL; - context_t dstcon =3D NULL; + g_autoptr(context_s_t) srccon =3D NULL; + g_autoptr(context_s_t) dstcon =3D NULL; if (!src || !dst) - return ret; + return NULL; if (!(srccon =3D context_new(src)) || !(dstcon =3D context_new(dst))) { virReportSystemError(errno, "%s", _("unable to allocate security context")); - goto cleanup; + return NULL; } if (context_range_set(dstcon, context_range_get(srccon)) =3D=3D -1) { virReportSystemError(errno, _("unable to set security context range '%1$s= '"), dst); - goto cleanup; + return NULL; } if (!(str =3D context_str(dstcon))) { virReportSystemError(errno, "%s", _("Unable to format SELinux context")); - goto cleanup; + return NULL; } - ret =3D g_strdup(str); - - cleanup: - if (srccon) context_free(srccon); - if (dstcon) context_free(dstcon); - return ret; + return g_strdup(str); } --=20 2.50.0