From nobody Mon Feb 9 01:22:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1673972479; cv=none; d=zohomail.com; s=zohoarc; b=LMzS29lT6RUIpLD3lR+SDnQEkeFrQGjyRjGOCLeq6a1a5sIGnCeSvzF5AxlD0jnDCikSN0TeEsIVj1sATgxvuqSHIo5PL3ABkLl6yRWoi6rOtIpoqELuievU47ESzjlJ5ldrpw97G+37Rpjm4qws8aGvZAR0TEcMmdOy4jVtelY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673972479; 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=Q85R+e0ShCD/47TfczxldapEEEzObVtb8iwFB/M6hHY=; b=D+Wb25haUOejPw45oAEu4DMyQu6eBjZDlyjAfwlcYJPYoZKoEeTcV4Z+XC93Kgkx/V7GnrZug91CsAmrqjvCBjNXRBjr449Vp3sX0nnPam977cctxFGU+Q29iwn5x0fzz81c7aq9j8i39WovdD6EWApD0SZDzCf2WKwX9OmwQfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1673972479687434.1676066223347; Tue, 17 Jan 2023 08:21:19 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-aet4u14hMh-d3f-Y7a9W2Q-1; Tue, 17 Jan 2023 11:21:14 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD5241C07825; Tue, 17 Jan 2023 16:20:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8EBF1415108; Tue, 17 Jan 2023 16:20:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B363819465A4; Tue, 17 Jan 2023 16:20:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 76D3719465A3 for ; Tue, 17 Jan 2023 16:20:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 591DA1121318; Tue, 17 Jan 2023 16:20:45 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFD2B1121315 for ; Tue, 17 Jan 2023 16:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673972478; 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=Q85R+e0ShCD/47TfczxldapEEEzObVtb8iwFB/M6hHY=; b=OAAqqkEhJ4NHVGn3HoU2sAiVmwtB+2DbVNfbIo7YS4ytuDtKYodKtz6iXHZzEaBoN0wZih SBjbkdMxsdvcBEKi/R0eUPe7gqoAjK4BypjCJPvT/YNO7lEVJ3tqfnFE2ZcaRp/eVYbj4A NwJ9N4JO1IcaDCMDoG1yxdKibdbQUog= X-MC-Unique: aet4u14hMh-d3f-Y7a9W2Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/15] util: authconfig: Use automatic pointer clearing for virAuthConfig Date: Tue, 17 Jan 2023 17:20:28 +0100 Message-Id: <4959b56e93b5f8ecc59a76e1ffbaf7ae5aa9fef9.1673972406.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673972480687100003 Content-Type: text/plain; charset="utf-8" Fix and clean up the error paths in virAuthConfigNew*. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma --- src/util/virauthconfig.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index dabd7cd217..983ac47f6b 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -37,23 +37,17 @@ VIR_LOG_INIT("util.authconfig"); virAuthConfig *virAuthConfigNew(const char *path) { - virAuthConfig *auth; - - auth =3D g_new0(virAuthConfig, 1); + g_autoptr(virAuthConfig) auth =3D g_new0(virAuthConfig, 1); auth->path =3D g_strdup(path); if (!(auth->keyfile =3D g_key_file_new())) - goto error; + return NULL; if (!g_key_file_load_from_file(auth->keyfile, path, 0, NULL)) - goto error; - - return auth; + return NULL; - error: - virAuthConfigFree(auth); - return NULL; + return g_steal_pointer(&auth); } @@ -61,23 +55,17 @@ virAuthConfig *virAuthConfigNewData(const char *path, const char *data, size_t len) { - virAuthConfig *auth; - - auth =3D g_new0(virAuthConfig, 1); + g_autoptr(virAuthConfig) auth =3D g_new0(virAuthConfig, 1); auth->path =3D g_strdup(path); if (!(auth->keyfile =3D g_key_file_new())) - goto error; + return NULL; if (!g_key_file_load_from_data(auth->keyfile, data, len, 0, NULL)) - goto error; - - return auth; + return NULL; - error: - virAuthConfigFree(auth); - return NULL; + return g_steal_pointer(&auth); } --=20 2.38.1