From nobody Sat Feb 7 03:13:22 2026 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 1530481518716867.8901340375703; Sun, 1 Jul 2018 14:45:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 838D732B683; Sun, 1 Jul 2018 21:45:17 +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 4629617D38; Sun, 1 Jul 2018 21:45:17 +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 E446F24F58; Sun, 1 Jul 2018 21:45:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjEpP009474 for ; Sun, 1 Jul 2018 17:45:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id D824D6017C; Sun, 1 Jul 2018 21:45:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFC446017B for ; Sun, 1 Jul 2018 21:45:03 +0000 (UTC) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) (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 96E0280F7B for ; Sun, 1 Jul 2018 21:44:51 +0000 (UTC) Received: by mail-pf0-f182.google.com with SMTP id l123-v6so3475508pfl.13 for ; Sun, 01 Jul 2018 14:44:51 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:50 -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=XjDXJ9jNYl/wsOF+GgskcC9+Csa8Kus1PeUjuSdKV98=; b=QzO/JRe5B6cQJn3g67dQi4/uVTdW5lR74TJXRBSuuZD46s4REF9Zn2+QR658Cw2YRe L2LSPD9rgGnc1e5BEei1LUSikJDx1WRlLCGuj0JDuburaIglM3hUPMyZbo21MHPqM4T0 EWKAZRcUiuwWHNdmLMNtC+cK133xogYBXX3OoF0HCVOQlnQXkrv7DyJgLIijyszKRtk+ wXV9VN+z4624o08rW2jEp8gsl20uNCzOytPM3L601NwQ9WZuhGXbSpu9jKUKAhuGZhbK K6Hs/FBd18SmpHYUNdRypJJ5IdCSYpbdMD/LQnghGG+0vwU60r6CD+YlpP5tMQPFnHpk 5fSw== 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=XjDXJ9jNYl/wsOF+GgskcC9+Csa8Kus1PeUjuSdKV98=; b=I4P+R/Tqt/agd+UkGOCMlA4mEWv5Kj5lwU95dMqtVDpdCmQ8qT9gTp7EDJwqxDZcyX 4XAGymHcTi7vXLYGwf4kTZ5J8oVwwqgf6ZtJP+KvzrIh1+xXyr+n6VyOo6qBMpvUt/Vt E5umxr4mydWDSK4tNE9jTGjfjLaaTqYZwb5LgJ42pliOyT4lvETvCtIEtT2YuQ2aPCRs Cyao88NOMVn/PVaJ2ahtj9FZbmBM4/X4q0+Z3wdnZB5gUyUqMawzoj2wIPzUjpEjT8oC P9yoLvqInlpaj9Q/+fyY6BcNQBtuZoEh5CKi0LfTSoZpTH1fe+w9mhC7TaPjw0qd8Hpz QxCA== X-Gm-Message-State: APt69E2CauCsc12SV79oTv91MSBQswvqzqqUW5QSfyAjd6L2zg1wfCUo 5RnFw9DD5IGh+SwlMQzRsDLtoATC X-Google-Smtp-Source: AAOMgpeXHIig1hvLzSoiZxoF1D7Q3OUWqmwVVpYHuNyagfHBcG/0nl67EQjj4DkgUqPL1tVP74msXQ== X-Received: by 2002:a62:d09:: with SMTP id v9-v6mr22521009pfi.163.1530481490830; Sun, 01 Jul 2018 14:44:50 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:25 +0530 Message-Id: <1530349239-22049-22-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.27]); Sun, 01 Jul 2018 21:44:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 01 Jul 2018 21:44:51 +0000 (UTC) for IP:'209.85.192.182' DOMAIN:'mail-pf0-f182.google.com' HELO:'mail-pf0-f182.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.182 mail-pf0-f182.google.com 209.85.192.182 mail-pf0-f182.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 21/35] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:45:18 +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 GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- 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..8c450b6 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(virAuthConfig) 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