From nobody Tue May 13 22:25:36 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 1528400152087816.6166230027903; Thu, 7 Jun 2018 12:35:52 -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 F22EB81E04; Thu, 7 Jun 2018 19:35:50 +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 AED5F60C4E; Thu, 7 Jun 2018 19:35:50 +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 620F24CA91; Thu, 7 Jun 2018 19:35:50 +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 w57JZmrB019120 for ; Thu, 7 Jun 2018 15:35:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BBE15D750; Thu, 7 Jun 2018 19:35:48 +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 345BF5B683 for ; Thu, 7 Jun 2018 19:35:47 +0000 (UTC) Received: from mail-pg0-f45.google.com (mail-pg0-f45.google.com [74.125.83.45]) (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 BD56E308626E for ; Thu, 7 Jun 2018 19:35:36 +0000 (UTC) Received: by mail-pg0-f45.google.com with SMTP id l65-v6so5224252pgl.8 for ; Thu, 07 Jun 2018 12:35:36 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:32 -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=FqZoJFujBMNhdqgOGJHCk+ELdPHk+aT56JOQTKLCnLI=; b=GjIiQPH4O1Gnstqhlf07mAhUwEw5pALjOgdKmmmg93j3TFRGfQxbxnUhcchcjmsaNk gYZ4TMqYjBnG7bkj6VEyF/9qILH+lKsCXytwsc/u4dHbTf6F6SpU/Jfg/CGOjG7PDLla 76/11Le1oHidGUuJ6HTlnh/OLTU3jkH3s9D0cDsoJH2DwW48XJe/zvaUmgabQAky8tYj jwBaeKfja/lR+0q6lWpVmFzSQ79pIrSNK4SE3dNQbvok4brjAb9OtJ3qLNZOkEakfJzz UWgBBYEzh+twIS96wyYVPmL9Ten+IIgxBetJu8MC0Q2b2DWHn12sjTta1LIEGJjYC4gQ KDUQ== 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=FqZoJFujBMNhdqgOGJHCk+ELdPHk+aT56JOQTKLCnLI=; b=BLB+ccEC5sznFh4vQeFebJk8rPvGgW3xLbrXy1sIen6JWlE9Fo7jOWGLZodjuu098y 9n/ZFIULtLcEQ7HTaBH77cMqlHmM0JN0p/3axN3Ew53N7WfQ5O8+AjbZ0JXLO6ofVx/I x5pW1e2k2l2NeX0fCD15qOYIlA+c6znWQfZ1fz1/FDHdPF0Gnk0g8v/psrzkpu+cmPrl RkPKQoibvz8d5UUPozDaWjDmkapKMihnJV7ELdrK94pemXTNCWVGjDe9k+aetZfaxJyX V7aOceUZ8mBaOCV7+wqVKJbviJVM/u+x3FWLaYB+2ikSeUDa8Z+VuAt3r6opcW376qlM h8iQ== X-Gm-Message-State: APt69E3m3ErLY/Y05cdASxpN5dVk1HVNPyIM1qaGfcLMXRNn8XbabxB6 NLON7U8fbondFp7g8WrYkMOcd0/9 X-Google-Smtp-Source: ADUXVKKk2STb9W+Ig4xHXGtb4NPJH28iFEZH/bfBTSFQKi5jY76R3YLMKPfNh6vew7DtYwuPJC/6cg== X-Received: by 2002:a63:6c03:: with SMTP id h3-v6mr2633804pgc.28.1528400132502; Thu, 07 Jun 2018 12:35:32 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:39 +0530 Message-Id: <1528400083-6788-18-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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]); Thu, 07 Jun 2018 19:35:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:36 +0000 (UTC) for IP:'74.125.83.45' DOMAIN:'mail-pg0-f45.google.com' HELO:'mail-pg0-f45.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.45 mail-pg0-f45.google.com 74.125.83.45 mail-pg0-f45.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 17/21] util: json: 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.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.25]); Thu, 07 Jun 2018 19:35: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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR macro, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virjson.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 1391a3b..3b54d94 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -2033,16 +2033,12 @@ char * virJSONStringReformat(const char *jsonstr, bool pretty) { - virJSONValuePtr json; - char *ret; + VIR_AUTOPTR(virJSONValuePtr) json =3D NULL; =20 if (!(json =3D virJSONValueFromString(jsonstr))) return NULL; =20 - ret =3D virJSONValueToString(json, pretty); - - virJSONValueFree(json); - return ret; + return virJSONValueToString(json, pretty); } =20 =20 @@ -2131,7 +2127,7 @@ virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json) { - virJSONValuePtr deflattened; + VIR_AUTOPTR(virJSONValuePtr) deflattened =3D NULL; virJSONValuePtr ret =3D NULL; =20 if (!(deflattened =3D virJSONValueNewObject())) @@ -2140,12 +2136,9 @@ virJSONValueObjectDeflatten(virJSONValuePtr json) if (virJSONValueObjectForeachKeyValue(json, virJSONValueObjectDeflattenWorke= r, deflattened) < 0) - goto cleanup; + return NULL; =20 VIR_STEAL_PTR(ret, deflattened); =20 - cleanup: - virJSONValueFree(deflattened); - return ret; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list