From nobody Mon Dec 15 01:36:58 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 1528400151620177.47023724126075; Thu, 7 Jun 2018 12:35:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 853AC30832F2; Thu, 7 Jun 2018 19:35:50 +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 49DDF5D750; Thu, 7 Jun 2018 19:35:50 +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 EAF684CA8E; Thu, 7 Jun 2018 19:35:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZXuJ019037 for ; Thu, 7 Jun 2018 15:35:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0E44308BDAA; Thu, 7 Jun 2018 19:35:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C896F308BDA9 for ; Thu, 7 Jun 2018 19:35:33 +0000 (UTC) Received: from mail-pl0-f48.google.com (mail-pl0-f48.google.com [209.85.160.48]) (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 0F1D381E02 for ; Thu, 7 Jun 2018 19:35:23 +0000 (UTC) Received: by mail-pl0-f48.google.com with SMTP id t12-v6so6749340plo.7 for ; Thu, 07 Jun 2018 12:35:23 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:21 -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=mW458JRyMBk2ZPneYEefo/QnYUiZw2DleW+8AzIxjuw=; b=lRDHNF68ZBygyPf2GvXw9KCAscDqPKhYAWAaZ761jr4P3zJ7QPDsJ56PpYexhqdmHQ jPE6jTIUtPnOKZUxBGB0tOpaAq/htz33NLrBd3Xi0JGp0NiqW9Oeuxq+VQPt6EmZZMZn oWlEsxnjQasz+1y+3G3nuYCMSI97KXKf0FE0sSOrJSQuAhjZ2ABdMPQUCgiqdBBf3GaI IHQcUGFsly0PaS+Au+RWeh/zf2Zfh+l5BNmcX8IS0B+jtrrXeourRHRRut0fVgxBloON e02rnGQ3jktRZJd0Q1LCGf5mcbwQ2vAXizQ1N02d/OyjxcIZe+ZknH18O7mcrKNs6VrD Ot+Q== 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=mW458JRyMBk2ZPneYEefo/QnYUiZw2DleW+8AzIxjuw=; b=hBJpRpRbtM83WvSX42ssrzXIJgoOoaC3Lzui+R9i6VsVMlhxcITUOgPY+yCZ6SrjO1 sbb7op2Bc44hjEKIyGFXDVcC5WJbbV9e0vNluKQ2Q7rtDTt4G+PAa3eAEdV2z5t6qZ09 noO2w1MaewdY4hPFxFvwhY3gErC36uatO456GbINvHReoY8s6ck37ke1WUrCBpPBtXD3 PuNbXCKuGGh8wPRIwnArmJ1apc2kdkvFhd0WrVHdJWWpKAguPiUcif07/IvsbpzlDSWo /hUqUcxdTXyhbJRHK6dst3maibQlpvFVCwbP/XvlwlZ5ehWPOnTNJdHM8RhyGluzINAB Z29g== X-Gm-Message-State: APt69E0w/DbaYtpsRriz4TuBLxaq8+YIsZao7qlUi2X4BxiYKlfU8YXo y8ew5JbhW1R8AZys5pJFyy5vm3YY X-Google-Smtp-Source: ADUXVKIVR9UU39hvcbbqiulCIRomKyaJD0Frx7oY4nGMt0sB+KBBwzwyWyPrwTN68O8woxNl5F7Q2w== X-Received: by 2002:a17:902:2884:: with SMTP id f4-v6mr3359242plb.204.1528400122229; Thu, 07 Jun 2018 12:35:22 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:35 +0530 Message-Id: <1528400083-6788-14-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.25]); Thu, 07 Jun 2018 19:35:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Jun 2018 19:35:23 +0000 (UTC) for IP:'209.85.160.48' DOMAIN:'mail-pl0-f48.google.com' HELO:'mail-pl0-f48.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.160.48 mail-pl0-f48.google.com 209.85.160.48 mail-pl0-f48.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 13/21] util: auth: use VIR_AUTOPTR for aggregate types 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 07 Jun 2018 19:35:51 +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" By making use of the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR macro, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virauth.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index d3a5cc7..f000d45 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename, const char *path, char **value) { - int ret =3D -1; - virAuthConfigPtr config =3D NULL; + VIR_AUTOPTR(virAuthConfigPtr) config =3D NULL; const char *tmp; =20 *value =3D NULL; @@ -121,23 +120,19 @@ virAuthGetCredential(const char *servicename, return 0; =20 if (!(config =3D virAuthConfigNew(path))) - goto cleanup; + return -1; =20 if (virAuthConfigLookup(config, servicename, hostname, credname, &tmp) < 0) - goto cleanup; + return -1; =20 if (VIR_STRDUP(*value, tmp) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - virAuthConfigFree(config); - return ret; + return 0; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list