From nobody Wed May 14 01:24:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528124181630653.9171141081146; Mon, 4 Jun 2018 07:56:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FC3BE8CC8; Mon, 4 Jun 2018 14:56:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D59C1308BDC2; Mon, 4 Jun 2018 14:56:18 +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 33E241800FD9; Mon, 4 Jun 2018 14:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w54EaeI6008071 for ; Mon, 4 Jun 2018 10:36:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id A2DD72016A87; Mon, 4 Jun 2018 14:36:40 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96C142016A85 for ; Mon, 4 Jun 2018 14:36:40 +0000 (UTC) Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27B52175826 for ; Mon, 4 Jun 2018 14:36:29 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id a13-v6so14531776pgu.4 for ; Mon, 04 Jun 2018 07:36:29 -0700 (PDT) Received: from centos.localdomain ([42.106.2.208]) by smtp.gmail.com with ESMTPSA id f63-v6sm23448806pfe.143.2018.06.04.07.36.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 07:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=d438f0vrStWV041NTAU3meoX8etVbS7ZTOD4O2Ywdog=; b=qBeF3wIacx/jH5waMkGF7hlEx1ZE8C0PslucGR8Q6vLAX1YQvCSwKLV5X9F9sYPL/v POF48vJ/Zu/3xY13Z2MInQ6J1tjJdbP+YKzk9NjvUteWb8eUhk4LBxJY8qSlhF34z8XF yz5PK0dMgYuwHZle3qPax52Zj+o5K9fz+sEAUOnLFrSELZV2hk8m+A4sEHWDuJ6F79Gr zn4qKfU5T0AkfZdeTMfedltvj8fH9h1IM0AYY8CJBmuJbnZLw3260UdZr+DXN2zIIfyR +KAd5YCy76XjniPzNX0GHaGfKJ0btb2PWCaWtYvvpttjvErtlu6a4/SnFoU9s3uMwPqj 9SAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d438f0vrStWV041NTAU3meoX8etVbS7ZTOD4O2Ywdog=; b=CTkvgF8KXWZRnzsXcOviMler1XahDmd1k539Qg13ng9r8qerE68jky2uAbaVW0S4/d eWE5N7QmnsE86HT2N6KGSEcqwd/RQnNmd0HLJatFp6U257lDGKKRi5O2rKiHyOOo0f74 KIavNokpPLA1t4dUJ6B6WnE4qSO28SMosiifTDxlo0Ijm3wZ7pYXbuTr2sMpBFvWuytu +6HczklXyWc9sYIpdyBUq6Ecw7DT8O4x/j4Qe7PaixrEBG/E6eWP+jbTRGqMqW2Cx20r YmxIoQhEF9/6rsCvbOGM6oqEBss86XBEyFcOXY0MOFv1JVoG4pEx3wAWfZmw97LrMtVg Hqkw== X-Gm-Message-State: ALKqPwe3N1eZyNumKBILBvw1k8D533Af6TSNXdHXoCAwax2KiURD7Mx9 lNJ6VdIgr4ZKJNye7v40HNFFQqOo X-Google-Smtp-Source: ADUXVKJHd4cCgpbW5Dp18kZpwaERb6Xpq4OzFWy7bjG4VvaTzmjcuVJv+DgXdMG/QKEVYWfEok/3XQ== X-Received: by 2002:a62:c8a:: with SMTP id 10-v6mr21630426pfm.27.1528122988329; Mon, 04 Jun 2018 07:36:28 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sun, 3 Jun 2018 13:42:02 +0530 Message-Id: <1528013536-22196-5-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528013536-22196-1-git-send-email-skrtbhtngr@gmail.com> References: <1528013536-22196-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 04 Jun 2018 14:36:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 04 Jun 2018 14:36:29 +0000 (UTC) for IP:'74.125.83.67' DOMAIN:'mail-pg0-f67.google.com' HELO:'mail-pg0-f67.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.83.67 mail-pg0-f67.google.com 74.125.83.67 mail-pg0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 04/18] use VIR_AUTOFREE in src/util/virauthconfig.c 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Jun 2018 14:56:20 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify code to use VIR_AUTOFREE macro wherever required. Signed-off-by: Sukrit Bhatnagar --- src/util/virauthconfig.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 91c9c0c..66f7f7e 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -106,10 +106,9 @@ int virAuthConfigLookup(virAuthConfigPtr auth, const char *credname, const char **value) { - char *authgroup =3D NULL; - char *credgroup =3D NULL; + VIR_AUTOFREE(char *) authgroup =3D NULL; + VIR_AUTOFREE(char *) credgroup =3D NULL; const char *authcred; - int ret =3D -1; =20 *value =3D NULL; =20 @@ -119,47 +118,38 @@ int virAuthConfigLookup(virAuthConfigPtr auth, hostname =3D "localhost"; =20 if (virAsprintf(&authgroup, "auth-%s-%s", service, hostname) < 0) - goto cleanup; + return -1; =20 if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { VIR_FREE(authgroup); if (virAsprintf(&authgroup, "auth-%s-%s", service, "default") < 0) - goto cleanup; + return -1; } =20 - if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { - ret =3D 0; - goto cleanup; - } + if (!virKeyFileHasGroup(auth->keyfile, authgroup)) + return 0; =20 if (!(authcred =3D virKeyFileGetValueString(auth->keyfile, authgroup, = "credentials"))) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing item 'credentials' in group '%s' in '%s'= "), authgroup, auth->path); - goto cleanup; + return -1; } =20 if (virAsprintf(&credgroup, "credentials-%s", authcred) < 0) - goto cleanup; + return -1; =20 if (!virKeyFileHasGroup(auth->keyfile, credgroup)) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing group 'credentials-%s' referenced from g= roup '%s' in '%s'"), authcred, authgroup, auth->path); - goto cleanup; + return -1; } =20 - if (!virKeyFileHasValue(auth->keyfile, credgroup, credname)) { - ret =3D 0; - goto cleanup; - } + if (!virKeyFileHasValue(auth->keyfile, credgroup, credname)) + return 0; =20 *value =3D virKeyFileGetValueString(auth->keyfile, credgroup, credname= ); =20 - ret =3D 0; - - cleanup: - VIR_FREE(authgroup); - VIR_FREE(credgroup); - return ret; + return 0; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list