From nobody Sun Feb 8 10:50:27 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 1532806912260283.3182812122974; Sat, 28 Jul 2018 12:41:52 -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 8BE63307D86C; Sat, 28 Jul 2018 19:41:50 +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 571A760175; Sat, 28 Jul 2018 19:41:48 +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 1FBCF1800B77; Sat, 28 Jul 2018 19:41:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJffGW021113 for ; Sat, 28 Jul 2018 15:41:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDA163083320; Sat, 28 Jul 2018 19:41:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6BE83001A6A for ; Sat, 28 Jul 2018 19:41:41 +0000 (UTC) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E882B3086267 for ; Sat, 28 Jul 2018 19:41:40 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id u24-v6so2874211pfn.13 for ; Sat, 28 Jul 2018 12:41:40 -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.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41:39 -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=p2Hiuq1eALjtD0yaJTBq5ZX8g5VmXX/7/YzApzVKh14=; b=KM2sJnRSAD5D39Ul67MQSj4yT+c5dLuaCQTTJj0IeUeVbTqqQ7GnSac4uuvQfBOiKL k0yXZ/ilYjmnv7wQ2dse64FMXes0uyEUOejeLeQrUO0kD2ETi/3osbzKNGH/MIKs84bW aQIq7F7Q7JV1a9pQEDDL/i1BxbFp8lgiSY45oroYJ5F/F+ka883kAqYs5l8ycMd+oAYr Y26i++TCQUzQrSU4St7CN9uUrf3djycxGr+36/Yptd1imMFilJeY4TecNTKUr1HmvA0r +sDfsGkl2hAvjvNwfEPITgMMuIcAUBvKeu076E0j7hNKQs4hl/XWQX4KUdFvKCW8DIZs Sq+Q== 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=p2Hiuq1eALjtD0yaJTBq5ZX8g5VmXX/7/YzApzVKh14=; b=bD7ooT5biVt3Etj2dYrWajjrBf/AXZVLyarNpV49PVTKtFHF/KftJbcGcYxoZZAOg5 zXouj8GYZW0ErqZeJoyaT1xHkhErYPAPFyg8Xppn/321UBEh7xpXShuRo60Sf9/Wv6jK w9BJr6en2y2C06sozK6i1rZfYQqRmwrAso1d+OuSfDi8LoG6S8A/ZjGo3Cp/4Hly4hwJ hZbX188e8pKyTTJw8tZXZaVlGozpCUsy9piDQTCoADr+eTDiA5P7o0HO+KUIWA0H/fDt kejQ96X6EN5ZdBOPa2cZdNi8iv2U/ALr3FSs52Wz2t3cO9AlgQszOBjJfxJsuRWd6fJ8 9mQg== X-Gm-Message-State: AOUpUlGlMuHzhF41QRpCMewgNwN9kPRs3IVHCzGkOML8PE40JiDDipcq Jf/fkNHLHh73NJVdafLqubGqz7g2 X-Google-Smtp-Source: AAOMgpdAFCtdm0StHJ+fO1iPCmxeZ5/wr4XAdNL7TBxTgkHhTTkDANsmIcPaFvyRRDaczV6H0kY9tQ== X-Received: by 2002:a63:a042:: with SMTP id u2-v6mr10495350pgn.80.1532806900227; Sat, 28 Jul 2018 12:41:40 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:46 +0530 Message-Id: <1532800907-29115-32-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.49]); Sat, 28 Jul 2018 19:41:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sat, 28 Jul 2018 19:41:41 +0000 (UTC) for IP:'209.85.210.174' DOMAIN:'mail-pf1-f174.google.com' HELO:'mail-pf1-f174.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.174 mail-pf1-f174.google.com 209.85.210.174 mail-pf1-f174.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 31/32] util: qemu: 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.48]); Sat, 28 Jul 2018 19:41:51 +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 --- src/util/virqemu.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 30b8dc1..4089b8e 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -85,29 +85,22 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *ke= y, virBufferPtr buf) { virJSONValuePtr member; - char *prefix =3D NULL; size_t i; - int ret =3D 0; =20 for (i =3D 0; i < virJSONValueArraySize(array); i++) { + VIR_AUTOFREE(char *) prefix =3D NULL; member =3D virJSONValueArrayGet((virJSONValuePtr) array, i); =20 if (virAsprintf(&prefix, "%s.%zu", key, i) < 0) - goto cleanup; + return 0; =20 if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, virQEMUBuildCommandLineJSON= ArrayNumbered, true) < 0) - goto cleanup; - - VIR_FREE(prefix); + return 0; } =20 - ret =3D 0; - - cleanup: - VIR_FREE(prefix); - return ret; + return 0; } =20 =20 @@ -118,23 +111,18 @@ virQEMUBuildCommandLineJSONIterate(const char *key, void *opaque) { struct virQEMUCommandLineJSONIteratorData *data =3D opaque; - char *tmpkey =3D NULL; - int ret =3D -1; =20 if (data->prefix) { + VIR_AUTOFREE(char *) tmpkey =3D NULL; if (virAsprintf(&tmpkey, "%s.%s", data->prefix, key) < 0) return -1; =20 - ret =3D virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->bu= f, + return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf, data->arrayFunc, false); - - VIR_FREE(tmpkey); } else { - ret =3D virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, + return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, data->arrayFunc, false); } - - 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