From nobody Fri May 3 10:04:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615456018; cv=none; d=zohomail.com; s=zohoarc; b=IZLCHqoNhTtpEv9sgWV+qyz4cCC6ZdVyTvAMyazj8GNW51DNyWj/TNO7cpssCoHMGX8OnxbYOKzIo1omLtN8L9Jw+6Cr+nkwLut88rKIoZL9yhi00WgdmoKYwQ1O09nNAEq+kK40s7owhkMTfCphUg9ddM4M0ZWU8gkhWWTkF00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615456018; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=T9A2JzdE5Ja+fRQ559iVC36n5ss+KDOV5/awXIRt8mc=; b=g14WMezutRKmq0xuXdsINqEHKEIVWMqTbm72uk2T7hLMK9Zn+s9ti9hUS/kGZGyu3tmDEZKzSr1SMIkW95KI/mcmvgnpYFWOc5/TwapjL91YzL7dm84yE5RkkfHSGaLxrmV4glwGofPpGkOJ9ZAKpZGPyRfsUnb5BzZlbJ/ZFIo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615456017872742.0967862581035; Thu, 11 Mar 2021 01:46:57 -0800 (PST) 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-579-qTKNPeMfMS2o1IeGLpGfag-1; Thu, 11 Mar 2021 04:46:53 -0500 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 4FCE226863; Thu, 11 Mar 2021 09:46:47 +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 EF8EB10023AB; Thu, 11 Mar 2021 09:46:46 +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 66B6757DC2; Thu, 11 Mar 2021 09:46:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12B9kiLG015759 for ; Thu, 11 Mar 2021 04:46:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 73B31202A424; Thu, 11 Mar 2021 09:46:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DF7A202A423 for ; Thu, 11 Mar 2021 09:46:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 125871018AA5 for ; Thu, 11 Mar 2021 09:46:42 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-8uAeXRnvPv2hu86D5rZJrw-1; Thu, 11 Mar 2021 04:46:38 -0500 Received: from localhost (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id C89801CB4 for ; Thu, 11 Mar 2021 17:46:31 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P13114T139929564739328S1615455984210629_; Thu, 11 Mar 2021 17:46:32 +0800 (CST) X-MC-Unique: qTKNPeMfMS2o1IeGLpGfag-1 X-MC-Unique: 8uAeXRnvPv2hu86D5rZJrw-1 X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: libvir-list@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Yi Li To: libvir-list@redhat.com Subject: [PATCH] virConfLoadConfig: Refactor cleanup Date: Thu, 11 Mar 2021 17:46:18 +0800 Message-Id: <20210311094618.745840-1-yili@winhong.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 12B9kiLG015759 X-loop: libvir-list@redhat.com Cc: Yi Li 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 Content-Type: text/plain; charset="utf-8" Switch to using the 'g_auto*' helpers. Signed-off-by: Yi Li --- src/util/virconf.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index 16107bce96..11046a1d45 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -1505,26 +1505,19 @@ virConfLoadConfigPath(const char *name) int virConfLoadConfig(virConfPtr *conf, const char *name) { - char *path =3D NULL; - int ret =3D -1; + g_autofree char *path =3D NULL; =20 *conf =3D NULL; =20 if (!(path =3D virConfLoadConfigPath(name))) - goto cleanup; + return -1; =20 - if (!virFileExists(path)) { - ret =3D 0; - goto cleanup; - } + if (!virFileExists(path)) + return 0; =20 VIR_DEBUG("Loading config file '%s'", path); if (!(*conf =3D virConfReadFile(path, 0))) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - VIR_FREE(path); - return ret; + return 0; } --=20 2.25.3