From nobody Sat Feb 7 05:35: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 1533714270686429.0529577470843; Wed, 8 Aug 2018 00:44:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D9F03150088; Wed, 8 Aug 2018 07:44:28 +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 0EABD65F41; Wed, 8 Aug 2018 07:44:28 +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 B31EA24B77; Wed, 8 Aug 2018 07:44:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iPGZ006013 for ; Wed, 8 Aug 2018 03:44:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id DBFBF10694EC; Wed, 8 Aug 2018 07:44:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6D0F1062246 for ; Wed, 8 Aug 2018 07:44:23 +0000 (UTC) Received: from mail-pl0-f51.google.com (mail-pl0-f51.google.com [209.85.160.51]) (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 DBBD3D5531 for ; Wed, 8 Aug 2018 07:44:21 +0000 (UTC) Received: by mail-pl0-f51.google.com with SMTP id t17-v6so649287ply.13 for ; Wed, 08 Aug 2018 00:44:21 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.44.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:20 -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=0uu1wqr/HeAWRNMDbQN3It67Fu0wXBTg5/FMZPnT4sk=; b=ibfkK3/L9lBNe67DDvFIiit9nQR8kQ0fkPBfJQR5eDWu/wNeZOBUP2WCRo8IBzJidO cmDsMfl+JA5lKxNaNH/yDZY7Sx4gpAJTfKMa/7+xTAAklacq1sg3IozCPHIueKTJCyxg M5cdWdwpu8MRISaNRIoE5YFQQyBVsSHMK6yj3YJp9bVACG06nBYcBaT8LL39JIVDvFsV wpNPF+D6LfCErErvOM86RgwlfDENHmezKvp3Kn+pjDFXlFEkkiJd1DqCbi6AXvPfGVOk RRJ3lwKt3CWmMCcz9SrlNFZNq/1NQZYkA+1dKZmWohdZ5fk+Twq0zyp5DxkV+asB1NCQ TQNA== 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=0uu1wqr/HeAWRNMDbQN3It67Fu0wXBTg5/FMZPnT4sk=; b=XOPERh2qOMUXkdhXG5btBUHm/5jFdiutxuhvLVP07UxwLbapLBPyPajNmz8XAknrdJ r+uI3O2oty1zJfYG+jI/kZPQ4cYR4k20AzIqJ2rB+zpSlc3YMZPRVQpN7jWJnymZe44O S2l5mqkijqF4zqpX6sx3zLIHdZIUO8zh7Mx4GCk+BwLelN1ZHgnLpjYMuc89q0Nxy1LL x4CqkzcjhfFrDJ1162GdX1kO80J+N9MJgwk8l96g+CVgb34TNbuQCdqyCowOr0+F+B6f HQ5yPXAQAAjGoeSnG1ieePuFUK2Om+2Uxpa+iZZpk3Hv+KO6gfvgHD5ip/ame1v6zu02 7gHg== X-Gm-Message-State: AOUpUlGtR/jPk8/A4l10D0icBkRqzN2tdmpYvftD2x8TWY0FIcg2mL8n ZEuSX0jXUyhTIlV+ZXzfRorsEGOs X-Google-Smtp-Source: AA+uWPwv9qmOJbmLpmseqEc5k60pgjERYIomjwxCjJyfJMJwz0ILTuiLLAvSukpuB/GfDLF5BjUwWw== X-Received: by 2002:a17:902:403:: with SMTP id 3-v6mr1542890ple.39.1533714261154; Wed, 08 Aug 2018 00:44:21 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:14:01 +0530 Message-Id: <1533501842-24503-35-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> References: <1533501842-24503-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.38]); Wed, 08 Aug 2018 07:44:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 08 Aug 2018 07:44:22 +0000 (UTC) for IP:'209.85.160.51' DOMAIN:'mail-pl0-f51.google.com' HELO:'mail-pl0-f51.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.160.51 mail-pl0-f51.google.com 209.85.160.51 mail-pl0-f51.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 34/35] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 08 Aug 2018 07:44:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 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/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