From nobody Sun Feb 8 06:05:24 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 1532806930834487.42030879576953; Sat, 28 Jul 2018 12:42:10 -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 676C15F73F; Sat, 28 Jul 2018 19:42:01 +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 1429210842A0; Sat, 28 Jul 2018 19:42:01 +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 BF7AA1800B75; Sat, 28 Jul 2018 19:42:00 +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 w6SJftYZ021273 for ; Sat, 28 Jul 2018 15:41:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id F29BF60172; Sat, 28 Jul 2018 19:41:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB9D560170 for ; Sat, 28 Jul 2018 19:41:44 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 1A34983F44 for ; Sat, 28 Jul 2018 19:41:43 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id y4-v6so5071693pgp.9 for ; Sat, 28 Jul 2018 12:41:43 -0700 (PDT) Received: from centos.localdomain ([49.32.98.239]) by smtp.gmail.com with ESMTPSA id m26-v6sm20270426pfi.102.2018.07.28.12.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41:41 -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=3IDdh8E10qDObB3pQuUH/CXOdvHqWjVrzsBp+Aw5WOg=; b=nBkFGqtrgPlNgf/772GIVGfajznIrxCJQAa49rWbMTM6r8qsY1tbtHEzvoaWcIBOyu K0m3HjUzYeg36+eiinIL5mRc+iGqwVtkd99aUpmly73i8tP3x/xDbO0EYMK3r9aRcc7o iv2x29lTHH/G/bByQkaiOB4SsxkMfSdLSU+A3gogsNsbeHeJd2Sjld+QNHYfYl46G0pi ucBJ1ypqzymFllrPOZ4gon8072VOwnLwrUdnIs5FWEyZq4z/dIba+nEdH8iI+dSQMaJ4 zkTWX7Xux8kwKZftZoC+L2LIN8S8zeLfHHXVvdAmLBwjHNXS14tgJbNfC0c7QW1/bF3q QC5w== 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=3IDdh8E10qDObB3pQuUH/CXOdvHqWjVrzsBp+Aw5WOg=; b=kGWZ076RZbjWe2Y1ZdA1ro4VtcvszjsWR8GzDfTW32ST19bXMooyYfiPahSF5TisuF DD91AlETFhG1wB/uC+GQ6Cd1U3Rf+Ov7o/NcY0++FSJoYznZfRtJvGNIjh8KB8RZXurG UXCtDLS2qaCRTsq/m9JsLHiciJGuTqjpmfKmeel6MZ0yrlmv3hOr7HXSC/IaFzuCmPKp uuPrVqWhM1/7jo2i+YlUhQ1jRilhXqm9qyiwgzR2DCkAtgzQv0nyth7W7Bo34ykSbOX5 HCZZcdJu5o5sYiv51F7RWHohpNNCy/WF8jfVYJAXlET81ypCDa5YsEOWUieU3ymYpg2u nbjg== X-Gm-Message-State: AOUpUlFmQ77LbCjhAZPjo4bnnVt5SMcTt9dTZ5eHstIoLV9MH/jMmlIr bW3pxLvdPd3pbKnVNr15CXj1U6f8 X-Google-Smtp-Source: AAOMgpen/cmo0ptkSwpwjo/nUpEdRkKits35g34h//My2zh1ZmcWRhd6gLy94ytLB3DZMQpmNbgA+Q== X-Received: by 2002:a65:46ca:: with SMTP id n10-v6mr10837107pgr.345.1532806902378; Sat, 28 Jul 2018 12:41:42 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:47 +0530 Message-Id: <1532800907-29115-33-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> References: <1532800907-29115-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.27]); Sat, 28 Jul 2018 19:41:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 28 Jul 2018 19:41:43 +0000 (UTC) for IP:'209.85.215.178' DOMAIN:'mail-pg1-f178.google.com' HELO:'mail-pg1-f178.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.178 mail-pg1-f178.google.com 209.85.215.178 mail-pg1-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 32/32] util: qemu: 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sat, 28 Jul 2018 19:42:02 +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 --- src/util/virqemu.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 4089b8e..cb42d38 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -56,7 +56,7 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key, { ssize_t pos =3D -1; ssize_t end; - virBitmapPtr bitmap =3D NULL; + VIR_AUTOPTR(virBitmap) bitmap =3D NULL; =20 if (virJSONValueGetArrayAsBitmap(array, &bitmap) < 0) return -1; @@ -73,8 +73,6 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key, } } =20 - virBitmapFree(bitmap); - return 0; } =20 @@ -267,21 +265,19 @@ virQEMUBuildObjectCommandlineFromJSON(virBufferPtr bu= f, char * virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *ret =3D NULL; + VIR_AUTOPTR(virBuffer) buf =3D NULL; =20 - if (virQEMUBuildCommandLineJSON(srcdef, &buf, + if (VIR_ALLOC(buf) < 0) + return NULL; + + if (virQEMUBuildCommandLineJSON(srcdef, buf, virQEMUBuildCommandLineJSONArrayNumber= ed) < 0) - goto cleanup; + return NULL; =20 - if (virBufferCheckError(&buf) < 0) - goto cleanup; + if (virBufferCheckError(buf) < 0) + return NULL; =20 - ret =3D virBufferContentAndReset(&buf); - - cleanup: - virBufferFreeAndReset(&buf); - return ret; + return virBufferContentAndReset(buf); } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list