From nobody Tue Jul 1 11:32:04 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 1531504617053891.1880061102836; Fri, 13 Jul 2018 10:56:57 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B331230820E3; Fri, 13 Jul 2018 17:56:53 +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 5897F1073033; Fri, 13 Jul 2018 17:56:53 +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 F0F0924F12; Fri, 13 Jul 2018 17:56:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6DHuUkd009027 for ; Fri, 13 Jul 2018 13:56:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27D8E17BBF; Fri, 13 Jul 2018 17:56:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BD0160BE5 for ; Fri, 13 Jul 2018 17:56:27 +0000 (UTC) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 C3DF63E2D4 for ; Fri, 13 Jul 2018 17:56:16 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id r5-v6so5184275pgv.0 for ; Fri, 13 Jul 2018 10:56:16 -0700 (PDT) Received: from centos.localdomain ([42.106.1.21]) by smtp.gmail.com with ESMTPSA id n5-v6sm26866817pgr.24.2018.07.13.10.56.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 10:56:15 -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=eE5kj7rTY+m161eHKV29sBCOk+vyqMwzi44Xgyx9u6M=; b=nHsf9+7H1/upeoHuNIsvH2yARpUXw+lBdtxO47mQeKWvaffAbNRYXACVHZzZjD8CdS 44OuQ52O/YcS17yTSzDSTptKxQQ8zaMA4H3VSTKmvDJK2u66aAZO2H9dSDCFrcfCS7GX //5SBmfYqefYlh6In0WAH3ZUNujNCGNlFYEcZQeC0Br/X6DANsIoHbxi47YrTPyKNYvr sndttu9Eklx5fQPOX4E68RzlEWnYz/AC+UHd95pS0Nb7OTWyHwTXLv6xUIEXfqUWX0LX RcNYPJMsirn70kHSOBkCh3G+qgn8j206R6l0LMrhfMHsJXuMbr9UZIXFkAWpiTxqAs8a TbNQ== 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=eE5kj7rTY+m161eHKV29sBCOk+vyqMwzi44Xgyx9u6M=; b=oLgRplsLojgY7otLFsp34Ris2eZx6p8VflvOxKu7a+Pq2pdQcrfHxf2ItXKmFuBrxi FgxSJCUrH1vlhdcLRfHcEbSKbOzBI/4eynLgiDXxoSydK4MZozWbnYY6GK490U2WS2sm cpWMJbRiF+jxaJNMqkjorBXRxOyu/amgxKl7uLNnsiLmWyGXrspj6AuoiCyH3slaO13j U1Ej6yatJqYDkBFozkABP2ohSNaYmeyvf4pa5cwV7BAfb6YO8IDABqqz8FYTVD1zZcF5 bVFvzzXnyh1JR/OvU6sFK+kMHA0eeJGqKIQ54pEZRroIN3h73Fglb3IkUpy4RDAoq1ZT /O9w== X-Gm-Message-State: AOUpUlGL78s/PPr3rIXDswzYmW6gq+8/WE3Wn4ysAvR8wxXg+mW6hOAm 1Z9kzsAW/n5OVI49SpcTCOgauJvV X-Google-Smtp-Source: AAOMgpdknCnfFZS5N9CL99kPLTXcg1C/NY2YRndbEbybqOfImWIqTmMpvMepUHp9yJQeeTrIYZwYFg== X-Received: by 2002:a63:5025:: with SMTP id e37-v6mr7065824pgb.341.1531504576067; Fri, 13 Jul 2018 10:56:16 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 13 Jul 2018 23:25:06 +0530 Message-Id: <1531504509-7930-29-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1531504509-7930-1-git-send-email-skrtbhtngr@gmail.com> References: <1531504509-7930-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.30]); Fri, 13 Jul 2018 17:56:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 13 Jul 2018 17:56:16 +0000 (UTC) for IP:'209.85.215.169' DOMAIN:'mail-pg1-f169.google.com' HELO:'mail-pg1-f169.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.215.169 mail-pg1-f169.google.com 209.85.215.169 mail-pg1-f169.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 28/31] 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 13 Jul 2018 17:56:56 +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 Reviewed-by: Erik Skultety --- 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; + return -1; =20 - ret =3D 0; - - 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