From nobody Sun Feb 8 17:21:17 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 1532174983298324.6501186946433; Sat, 21 Jul 2018 05:09:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 262A230E686B; Sat, 21 Jul 2018 12:09:37 +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 E63662016206; Sat, 21 Jul 2018 12:09:35 +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 A27384EE0B; Sat, 21 Jul 2018 12:09:34 +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 w6LC8hLx016542 for ; Sat, 21 Jul 2018 08:08:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90CDD600C7; Sat, 21 Jul 2018 12:08:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8467B600C4 for ; Sat, 21 Jul 2018 12:08:43 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) (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 78748308A943 for ; Sat, 21 Jul 2018 12:08:32 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id s7-v6so5535413pgv.3 for ; Sat, 21 Jul 2018 05:08:32 -0700 (PDT) Received: from centos.localdomain ([42.106.1.69]) by smtp.gmail.com with ESMTPSA id s16-v6sm5861694pfm.114.2018.07.21.05.08.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 05:08:31 -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=AwcQfhJEKRZOlhi+TvAwaC2eCIxdR4pQnw6bvxjf5mg=; b=KWjtq2nC/thr8GwQimDVg8+xFqwFYY/g7WnwzCx8sz2KtCYIbRMLjxQNTn5o0QAgXY djwU9xh74fdoSPaVK+Jzb9xZXAv+lE2bH7zFKbl51YjdNDoFoXJfGA8q5JCEYHTYBLxd t3e2qxoL+MsEKXY2Vm9Z1Rueqyrt/hswPnKGIH0BZUgxdorK3tC/Sz40kjhshhEf6s6r BjbofauRk8kymG5xv68MwAjjc1+oDF4yXG+m1WBfa5cNPDUSF4dxGzLvHKC4sjjzwtFw DelsDQQdwOcvnQy4qFYf6IU7SRL+hFLzWSLz3zs2zV/vfeIb3IwRYhL6Pa/cKbRo/GCg NQgA== 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=AwcQfhJEKRZOlhi+TvAwaC2eCIxdR4pQnw6bvxjf5mg=; b=Mjoenw5gS87dv1wkDQvyUdyioaahbIF69bc/QKfeRKiX6nHbQxnFmsfMAQW0c/fXoI AQUBWYbGqRg4zkBHAgA9rfYo9bsdnkjdq6fJcci30BLdGp5hLWkqxgrni978i1TWIgZS Il7dctiHgyskldYuy9io09Ynb8RPF4/OjEFKlXJyOMid6/1hUxm++1/YatTG+Jj30rav cU24soEqfg0PmIJJebMlalyimq7bEW3rm0ymq2wd0Vl02pxodt5SFSM7sModFI2Qj4GN EFIYP4nmfKUJB0w1uDOhBZPHbMhiQ+2hWs2NxB3KpRZ2NI23IpgDJXeUahdInpr5sOcX yeog== X-Gm-Message-State: AOUpUlG/oM2SlhsemXUL/GZkpTvnTnl+obMhxr/llEpeLmgPTsXvc3GG 3e2wyO/ZfB7exqNwgk0XCVHARPmC X-Google-Smtp-Source: AAOMgpcxR8Zq0orCW1BOisP2XNPPtnrPduGKPAQp9BqhMFzRRkeQihS6VW91wd3K9CZeuU+a7uamhA== X-Received: by 2002:a63:2803:: with SMTP id o3-v6mr5525907pgo.158.1532174911779; Sat, 21 Jul 2018 05:08:31 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 21 Jul 2018 17:36:59 +0530 Message-Id: <1532174832-21644-28-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532174832-21644-1-git-send-email-skrtbhtngr@gmail.com> References: <1532174832-21644-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.41]); Sat, 21 Jul 2018 12:08:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sat, 21 Jul 2018 12:08:32 +0000 (UTC) for IP:'209.85.215.194' DOMAIN:'mail-pg1-f194.google.com' HELO:'mail-pg1-f194.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.215.194 mail-pg1-f194.google.com 209.85.215.194 mail-pg1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 27/40] 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.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 21 Jul 2018 12:09:42 +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