From nobody Tue May 13 11:32:42 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 1532639142874233.12111405386418; Thu, 26 Jul 2018 14:05:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A45730E6844; Thu, 26 Jul 2018 21:05:41 +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 DF37B3001A70; Thu, 26 Jul 2018 21:05:40 +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 8E5F724F64; Thu, 26 Jul 2018 21:05:40 +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 w6QL5cvd024978 for ; Thu, 26 Jul 2018 17:05:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 244C560C9A; Thu, 26 Jul 2018 21:05:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1ABDB60C80 for ; Thu, 26 Jul 2018 21:05:38 +0000 (UTC) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 29E5D308FBA2 for ; Thu, 26 Jul 2018 21:05:37 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id r5-v6so1894748pgv.0 for ; Thu, 26 Jul 2018 14:05:37 -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.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:35 -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=sbWlC9MNiyeubz7ne1KG9lU90gKuJ09YxOq7q6pKuTM=; b=dAYqsbyxb4ITjBukTqMpZ3YzlJEj13SqHSClS2OTjJlDaAHqaYaMRE3n8ZChLiUIQu RUZcXcox3Y0wHTpNcD7uUv2rzF7TFcM2BBbNacS0FG/1hIpHXzbg+J9Jd6mwf0wRfRYb DcCNtidh8jS5EdQS4j/kYj24ActMDpXg3oYsO4pSTjchCkRH1q19a2rpVSY+Bi5KN+oS NZ3ZkoEyZQDm5wUf3uVGPnAcFzZ23ESLz/HhFFOK79w0jK6Mk7BduFp3i36hY29KMJA7 vb3mfawHFQfHVy05Vpjf8xQnPnYuBWQWrlyFjpNbYDA5A+MMVzM6t6EcOCDMGFRIkhMw ALzw== 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=sbWlC9MNiyeubz7ne1KG9lU90gKuJ09YxOq7q6pKuTM=; b=Hrkg66gVFibx319J9IFEDRZNJMCKHS0CZVVYs89tVruNNW7GgV/PL3MK7YnS2WMWQ9 3LRcWcVM5X80tbyLy9gw66i3IlnHg7z/mJ+/CKyLinZ06aXZm02UnoiOi7zCXbGCWKxJ x0VxaBBNSbmn9Wjl/bd8yBo/bzkw4vkoQOWCuHpyknyq6iWz8ftUs2uvN3zkj4DMLqCN B7PcuYHnHYIh2YJnE08b3Xwq+64Ic1ujnB9QJRQadVfdbj293QBr8Zt3TvQVg0SA/yn8 q2TG5nhR77bcHLqHHsFMC5Gh7ghTjZL1Aea7Hqk/0neC/53YzPmb8Ohq/ByMam07+SpY oHLg== X-Gm-Message-State: AOUpUlGnsThaIEkNMrDGJX5il3Xu5f4qcnToUkloNU51Nnml1FxGw6Qf pvpSe9tePnr/cXL1qTIj1OizhPOV X-Google-Smtp-Source: AAOMgpdsvONHGSKGRmJnP2DYQghjXi3rvyT/KghyCEWWE6ADhFdMwWeaM722ezHZJ4fX0bDklUGEdw== X-Received: by 2002:a65:49c7:: with SMTP id t7-v6mr3410195pgs.23.1532639136402; Thu, 26 Jul 2018 14:05:36 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:31 +0530 Message-Id: <1532447562-24010-31-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.43]); Thu, 26 Jul 2018 21:05:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 26 Jul 2018 21:05:37 +0000 (UTC) for IP:'209.85.215.179' DOMAIN:'mail-pg1-f179.google.com' HELO:'mail-pg1-f179.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.179 mail-pg1-f179.google.com 209.85.215.179 mail-pg1-f179.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 30/41] util: scsivhost: 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 26 Jul 2018 21:05:41 +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/virscsivhost.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index ef216b3..280d0dc 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -109,8 +109,7 @@ void virSCSIVHostDeviceListDel(virSCSIVHostDeviceListPtr list, virSCSIVHostDevicePtr dev) { - virSCSIVHostDevicePtr tmp =3D virSCSIVHostDeviceListSteal(list, dev); - virSCSIVHostDeviceFree(tmp); + VIR_AUTOPTR(virSCSIVHostDevice) tmp =3D virSCSIVHostDeviceListSteal(li= st, dev); } =20 =20 @@ -253,7 +252,8 @@ virSCSIVHostDeviceGetPath(virSCSIVHostDevicePtr dev) virSCSIVHostDevicePtr virSCSIVHostDeviceNew(const char *name) { - virSCSIVHostDevicePtr dev; + VIR_AUTOPTR(virSCSIVHostDevice) dev =3D NULL; + virSCSIVHostDevicePtr ret =3D NULL; =20 if (VIR_ALLOC(dev) < 0) return NULL; @@ -262,22 +262,18 @@ virSCSIVHostDeviceNew(const char *name) virReportError(VIR_ERR_INTERNAL_ERROR, _("dev->name buffer overflow: %s"), name); - goto error; + return NULL; } =20 if (virAsprintf(&dev->path, "%s/%s", SYSFS_VHOST_SCSI_DEVICES, name) < 0) - goto error; + return NULL; =20 VIR_DEBUG("%s: initialized", dev->name); =20 - cleanup: - return dev; + VIR_STEAL_PTR(ret, dev); =20 - error: - virSCSIVHostDeviceFree(dev); - dev =3D NULL; - goto cleanup; + return ret; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list