From nobody Tue May 13 18:37:27 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 15304815445841005.5250411173263; Sun, 1 Jul 2018 14:45:44 -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 4641D80F91; Sun, 1 Jul 2018 21:45:43 +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 0268F308BDA5; Sun, 1 Jul 2018 21:45:43 +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 65678245FE; Sun, 1 Jul 2018 21:45:42 +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 w61LjYTT009679 for ; Sun, 1 Jul 2018 17:45:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C097308BDBC; Sun, 1 Jul 2018 21:45:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72BBC308BDBB for ; Sun, 1 Jul 2018 21:45:32 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) (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 51249C04AC4C for ; Sun, 1 Jul 2018 21:45:21 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id y8-v6so6528428pfm.10 for ; Sun, 01 Jul 2018 14:45:21 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:20 -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=IJSR/J5eHqR3zCxPH+ThM8bw0XEoeOMsSCZuN7EsHCA=; b=tIGjef1LIWZye7yFvuSq3VyQ/aEv6QH3T6/uRT3TY+Fs4b4BbzEg07DtImamCy6IBS Xj39q/DbLLxxX1gy8aC1KaIFm7E5J9XgLM29kUozlbh1f5reQBgo/98WnowAE4uuPhYc mi1qc71J8xfAS3E+uGQj0URJsScBQ2EmI9AxNe+t+I9zK2WMfItDeIRkPLxlsCPJRJ6I zyN4IC4RDkW+iraFVVXwNsEBK9l5fmAUFcnrcdEIVjqBNP3poBQFCtu8hJYYTNmqMTIE Dm/U5JdKQ2JiOw0+iw2yn/M02yF4oz+bl1HYQyDU8ymEL5z4VSDIlnuLkCw3Aa/4fmy1 4FPg== 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=IJSR/J5eHqR3zCxPH+ThM8bw0XEoeOMsSCZuN7EsHCA=; b=CLDNNn7sEhEnLdLy3VuXG7om4+BCDgKrzBq+2dRUYriIgqPEkwkVzQUUTrRdyVSA1i RgZ9q645/aE3vhdoKZc9a/RdOUSM0e5cQaIkH8JwgghugVbL2sjPmXoLFpsoC6V2q0Kd O87MFR6805g0nf7q2CzTWFHzAsQbKM8Hhe7vPJoVCdjjrcCXPCAGw+l8jV5JH6Kg27e2 +A9DUsM18rU5UdLPZ7AY0Qvz/UAk08N0zXTb6MAoqVKTyAv7eobS7PZkFWcdm0M1sChc edPRBRV1mullSsMUm3/yvFxX2Gnd6OqOqe/c1sTaZzTzwT1hwgRdy++ytxM2kpStThdx Zj9g== X-Gm-Message-State: APt69E1YHmkY5AeycnLPTfXsTpwUXqEYk5pB199JIC/4+4F3fD3/m0sm 0yQIzaXGHv01eNhxL3zh744EpNd0 X-Google-Smtp-Source: AAOMgpf5xFViOVh5bELNmISSVB7thXy7hwxOrO+A7rnLvgltGgc39AeqJlrWwFdIuIKtr3wuPAJfow== X-Received: by 2002:a62:8917:: with SMTP id v23-v6mr23062121pfd.127.1530481520503; Sun, 01 Jul 2018 14:45:20 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:36 +0530 Message-Id: <1530349239-22049-33-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.31]); Sun, 01 Jul 2018 21:45:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 01 Jul 2018 21:45:21 +0000 (UTC) for IP:'209.85.192.174' DOMAIN:'mail-pf0-f174.google.com' HELO:'mail-pf0-f174.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.174 mail-pf0-f174.google.com 209.85.192.174 mail-pf0-f174.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 32/35] util: fcp: use VIR_AUTOFREE instead of VIR_FREE for scalar 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.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.27]); Sun, 01 Jul 2018 21:45:44 +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_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- src/util/virfcp.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 7660ba7..b703744 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -40,16 +40,12 @@ bool virFCIsCapableRport(const char *rport) { - bool ret =3D false; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) return false; =20 - ret =3D virFileExists(path); - VIR_FREE(path); - - return ret; + return virFileExists(path); } =20 int @@ -57,8 +53,8 @@ virFCReadRportValue(const char *rport, const char *entry, char **result) { - int ret =3D -1; - char *buf =3D NULL, *p =3D NULL; + VIR_AUTOFREE(char *) buf =3D NULL; + char *p =3D NULL; =20 if (virFileReadValueString(&buf, "%s/%s/%s", SYSFS_FC_RPORT_PATH, rport, entry) < 0) { @@ -69,13 +65,9 @@ virFCReadRportValue(const char *rport, *p =3D '\0'; =20 if (VIR_STRDUP(*result, buf) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - VIR_FREE(buf); - return ret; + return 0; } =20 #else --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list