From nobody Tue May 13 18:30:10 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 1530481489074256.2743479889324; Sun, 1 Jul 2018 14:44:49 -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 E90E9308A95A; Sun, 1 Jul 2018 21:44:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1C3B20155E2; Sun, 1 Jul 2018 21:44:47 +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 6508C18037EF; Sun, 1 Jul 2018 21:44:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61Lihv2009171 for ; Sun, 1 Jul 2018 17:44:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3FC9017481; Sun, 1 Jul 2018 21:44:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35BFA94968 for ; Sun, 1 Jul 2018 21:44:40 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) (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 4F55881DF2 for ; Sun, 1 Jul 2018 21:44:29 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id h20-v6so4604589pfn.4 for ; Sun, 01 Jul 2018 14:44:29 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:28 -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=R9m95y8hUrtRCR9P2uOJz5RbVEFHf9MIDYaVVXDKwGQ=; b=eFpHlj/EP0bd/Mi/O/PQ8w3qvmQmTNCVjce/xvEiOv4OC/ZNhpfFKzzLnv6VsDCXU3 XyijQ4e7eLLhIglDVva2e5I8OqgVxA5JirtrCPUCmbo/BrNST4Gh4ogLjqfeV19TFF0m TCnGhod72eMhwIDAruVK4p5FQGpFm+ru7e158BB+7cxO8ZzHbXuAWtBQ0hXCZVw+4q/c ILZ15eugVNKjkki9HRSwmHG8bCR+OzWKr2uJ6eGEhLlUXvNjB4Tb+7vVRi8GflTxVYij oPA3U6RnbvtzZ56jZmU0uoLnv+xC5iwytHd4/H/2/NiDFFq7NGk8ZKN1cOezYi3ZDMtk bn+A== 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=R9m95y8hUrtRCR9P2uOJz5RbVEFHf9MIDYaVVXDKwGQ=; b=jyr8CWF+qhMmY593iSdg/iJuXIgmScZR0Imw914P71ukGwmO6DQMh10cv7SrYNDTN4 ADePWVP2YSO3pQr5+Gs+kalGkM85HdvUd8vLYRAaYG+YtWg+7bNmABP3sZrsrBbAzgME XD+D6XClrgZRyQJfHqb/PD5kvT+FeKdGDnDr9zVLrF8PZWL0uMnaOtWRL6Tent+uXGU7 JxYnsyyqR8W6r8aS1sorGLyI9iOCGpaARj/ogwFDxlTdPI7SNVeX+qK6zgzfOjm9OOZO /2oIThyQBZk5BrQ/8YBGh6F1JdJ5ds/U3G9fw1NY47ajF2NDKds6qrp63SWaenflHcH6 eIXw== X-Gm-Message-State: APt69E1aBU7xlu3g286ttzkHjS3NyyKaihtJBPC7tzqTCRh30oPEemQC rbMk8MSfFGZzOrM8Dj6/tjWysmQb X-Google-Smtp-Source: ADUXVKJIvxDfXHKuueizzl+VSqZeVfEhqqb/zwB/0pzvXWbbgL0zcOdYE23N9r4l8mdr51G5NVOxtg== X-Received: by 2002:a63:2dc2:: with SMTP id t185-v6mr19954616pgt.204.1530481468586; Sun, 01 Jul 2018 14:44:28 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:19 +0530 Message-Id: <1530349239-22049-16-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.25]); Sun, 01 Jul 2018 21:44:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 01 Jul 2018 21:44:29 +0000 (UTC) for IP:'209.85.192.193' DOMAIN:'mail-pf0-f193.google.com' HELO:'mail-pf0-f193.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.193 mail-pf0-f193.google.com 209.85.192.193 mail-pf0-f193.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 15/35] util: file: 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:48 +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/virfile.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 3a7445f..6b94885 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -888,20 +888,19 @@ int virFileNBDDeviceAssociate(const char *file, { VIR_AUTOFREE(char *) nbddev =3D NULL; VIR_AUTOFREE(char *) qemunbd =3D NULL; - virCommandPtr cmd =3D NULL; - int ret =3D -1; + VIR_AUTOPTR(virCommand) cmd =3D NULL; const char *fmtstr =3D NULL; =20 if (!virFileNBDLoadDriver()) - goto cleanup; + return -1; =20 if (!(nbddev =3D virFileNBDDeviceFindUnused())) - goto cleanup; + return -1; =20 if (!(qemunbd =3D virFindFileInPath("qemu-nbd"))) { virReportSystemError(ENOENT, "%s", _("Unable to find 'qemu-nbd' binary in $PATH"= )); - goto cleanup; + return -1; } =20 if (fmt > 0) @@ -926,17 +925,14 @@ int virFileNBDDeviceAssociate(const char *file, /* qemu-nbd will daemonize itself */ =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 VIR_DEBUG("Associated NBD device %s with file %s and format %s", nbddev, file, fmtstr); *dev =3D nbddev; nbddev =3D NULL; - ret =3D 0; =20 - cleanup: - virCommandFree(cmd); - return ret; + return 0; } =20 #else /* __linux__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list