From nobody Tue May 13 11:21:51 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 1532639177484668.4306293355583; Thu, 26 Jul 2018 14:06:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1AC6530001D7; Thu, 26 Jul 2018 21:06:11 +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 DA8DB60190; Thu, 26 Jul 2018 21:06:10 +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 8850F24B79; Thu, 26 Jul 2018 21:06:10 +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 w6QL5vVt025125 for ; Thu, 26 Jul 2018 17:05:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1744F308BDB4; Thu, 26 Jul 2018 21:05:57 +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 0BA2C308BDB2 for ; Thu, 26 Jul 2018 21:05:48 +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 6B86B36809 for ; Thu, 26 Jul 2018 21:05:31 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id p23-v6so1875439pgv.13 for ; Thu, 26 Jul 2018 14:05:31 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.05.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:30 -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=X0AEIpzywkf0vNrj3j1yOJnfQCkFRVddfvbvz+e19kY=; b=uqbOwsmjPA8Ci9bGsIKpE1J3j23rRpP2cjpne2VkL6O3/KpVo7YyDvbWOKfkwxG7Y2 a3N5TKb9faMU0UPwGGkUlktkrJIkGNoyp+uXXc0ZaMsDfoF/ZkVhLrFGVuSGCZGtPQlC lGE3gAzf2CNONshKxcZVeKUE9O9gy9D9j8OdyelTga7KqpDTVyUqTcBm0MeM51USBg/k Hn0GQGAtS9Lz4AoRou7Yvcbk/mV2dfhlaQNnI7mUdgk3jvLjtqulyKCsSTH7QQUGoKMY HSlz4z0wzld/VF5i9an7rJrfxB75kEEYUKHCNmFi3kIXHW+NVsUOA2+13IVqP1gfuymg L4cg== 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=X0AEIpzywkf0vNrj3j1yOJnfQCkFRVddfvbvz+e19kY=; b=qQGaahjxqJt8jMmvHAsM56HI7fum8Ajevj1D8M0hSkYjYqNGVug36es2LXq4vlHnex S8Vu3ljOJR6fJFmj5wwpvJI0XOwgNfFl5j5+ZuP9+cF2M7dAX/Kkr7ECEWtPFgFvLn8F Se3dRSMRddCN0GmmxKLrlRlAh6Q8Efyxu5PTfEj1Wjy2wbdKJCrjkWwvDwfcshNUt0mA b68h9VH+ixliqHuDr+5xrJ8wfgGY8VqsEAvaZr3kXZKWQsY76uqVwgis82x7MTuE9gyz JFOdk4CCz5hkklCh+uZO8i6ioduMmEHSK5RMujxUO2mGWil/2tCkc+/i4/FVnnzFtUtt mXLQ== X-Gm-Message-State: AOUpUlGKgIdVSbYbUR9RJUmmLNPVwmwvkYOLO9l+Ey7WEGeleL154QYD DZynauuYIQpVzJc592BeVEquXFDQ X-Google-Smtp-Source: AAOMgpcp5nKdJVSuqo76SN22Ipj/yuGPBt0dzZJpzyzoILGhXB3mIS7bg6UhM6ORiHj7zf+UDe9BCg== X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr3694988pfb.157.1532639130706; Thu, 26 Jul 2018 14:05:30 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:28 +0530 Message-Id: <1532447562-24010-28-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> References: <1532447562-24010-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]); Thu, 26 Jul 2018 21:05:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Jul 2018 21:05:47 +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.39 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_PASS) 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.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 27/41] util: scsi: 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 26 Jul 2018 21:06:16 +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/virscsi.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 33292f6..ba0a688 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -115,7 +115,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, { DIR *dir =3D NULL; struct dirent *entry; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; char *sg =3D NULL; unsigned int adapter_id; const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICE= S; @@ -139,7 +139,6 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, =20 cleanup: VIR_DIR_CLOSE(dir); - VIR_FREE(path); return sg; } =20 @@ -155,7 +154,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, { DIR *dir =3D NULL; struct dirent *entry; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; char *name =3D NULL; unsigned int adapter_id; const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICE= S; @@ -178,7 +177,6 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, =20 cleanup: VIR_DIR_CLOSE(dir); - VIR_FREE(path); return name; } =20 @@ -192,11 +190,11 @@ virSCSIDeviceNew(const char *sysfs_prefix, bool shareable) { virSCSIDevicePtr dev, ret =3D NULL; - char *sg =3D NULL; - char *vendor_path =3D NULL; - char *model_path =3D NULL; - char *vendor =3D NULL; - char *model =3D NULL; + VIR_AUTOFREE(char *) sg =3D NULL; + VIR_AUTOFREE(char *) vendor_path =3D NULL; + VIR_AUTOFREE(char *) model_path =3D NULL; + VIR_AUTOFREE(char *) vendor =3D NULL; + VIR_AUTOFREE(char *) model =3D NULL; const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICE= S; =20 if (VIR_ALLOC(dev) < 0) @@ -247,11 +245,6 @@ virSCSIDeviceNew(const char *sysfs_prefix, =20 ret =3D dev; cleanup: - VIR_FREE(sg); - VIR_FREE(vendor); - VIR_FREE(model); - VIR_FREE(vendor_path); - VIR_FREE(model_path); if (!ret) virSCSIDeviceFree(dev); return ret; --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list