From nobody Tue Feb 10 07:40:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613152659; cv=none; d=zohomail.com; s=zohoarc; b=AQetzrFBS6u9y1yboxSLY1bJE+kus48Zt6tqaXNU6MRaypxP+k6UWTwnDG1h1Ijs7gj9ipqDn+RIAgJzpZhX0CTZx6pV+KqXOf4S91oBfgorbR+7+2KBfEVun/m93oTX9v4NYYPV5qlIwh7QMytMQz+H/C/IFFn7Y1REDc2UlN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152659; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y/r20xcHEcqLLyPNkAyfUHyC36BwVf0naoAwEWD6Cho=; b=MTUKwzHG7/Z/qWOUNg7B03uooB1CqzjT+flV+Ttun2B72tH70IFcdQUxv0z8kpclMtjSauIg3h3qhjsmOQz+bfOxeXh5ueXldWcglufJXtbxCbUs0wvtq9Ej4kTvP9gVrizNhWqtW8QvtFOZ8tLLF8ajzQV0A58zVjpAJv9KDhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613152658521284.53270978685816; Fri, 12 Feb 2021 09:57:38 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-bQoTUjNJOT-Uv6CTB7zSFQ-1; Fri, 12 Feb 2021 12:57:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5D581DE1B; Fri, 12 Feb 2021 17:57:10 +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 89A9919D6C; Fri, 12 Feb 2021 17:57:10 +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 4E5AB18095C9; Fri, 12 Feb 2021 17:57:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CHupub011057 for ; Fri, 12 Feb 2021 12:56:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5059367CC2; Fri, 12 Feb 2021 17:56:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8922E5C23D for ; Fri, 12 Feb 2021 17:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152657; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Y/r20xcHEcqLLyPNkAyfUHyC36BwVf0naoAwEWD6Cho=; b=Y0u0jJBv7o5eih7MsZY2bfatUpM7yxTArpQkgkKk3X3qy16lVqrydF/qcF4wgKaHT5g/eo HTolsA7fc5iPpc/erwnRPGhqKOqNVw1xUA+DAOlhhl/UjPvCiqCH/esEWOoIXcT5O1V7Gb IGZHZP/z+a5I0z6SLlmI1rAXkKWZVrk= X-MC-Unique: bQoTUjNJOT-Uv6CTB7zSFQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/25] virJSONParserInsertValue: Take double pointer for @value Date: Fri, 12 Feb 2021 18:55:38 +0100 Message-Id: <74a6771a9f17c28ce3b9f2367733e0681676bf09.1613152442.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function calls virJSONValueObjectAppend/virJSONValueArrayAppend, so by taking a double pointer we can drop the pointer clearing from callers. Signed-off-by: Peter Krempa --- src/util/virjson.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index b21b1fc63f..b952ad500d 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1550,10 +1550,10 @@ virJSONValueCopy(const virJSONValue *in) #if WITH_YAJL static int virJSONParserInsertValue(virJSONParserPtr parser, - virJSONValuePtr value) + virJSONValuePtr *value) { if (!parser->head) { - parser->head =3D value; + parser->head =3D g_steal_pointer(value); } else { virJSONParserStatePtr state; if (!parser->nstate) { @@ -1572,7 +1572,7 @@ virJSONParserInsertValue(virJSONParserPtr parser, if (virJSONValueObjectAppend(state->value, state->key, - &value) < 0) + value) < 0) return -1; VIR_FREE(state->key); @@ -1585,7 +1585,7 @@ virJSONParserInsertValue(virJSONParserPtr parser, } if (virJSONValueArrayAppend(state->value, - &value) < 0) + value) < 0) return -1; } break; @@ -1607,9 +1607,8 @@ virJSONParserHandleNull(void *ctx) VIR_DEBUG("parser=3D%p", parser); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; return 1; } @@ -1624,9 +1623,8 @@ virJSONParserHandleBoolean(void *ctx, VIR_DEBUG("parser=3D%p boolean=3D%d", parser, boolean_); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; return 1; } @@ -1642,9 +1640,8 @@ virJSONParserHandleNumber(void *ctx, VIR_DEBUG("parser=3D%p str=3D%s", parser, value->data.number); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; return 1; } @@ -1661,9 +1658,8 @@ virJSONParserHandleString(void *ctx, VIR_DEBUG("parser=3D%p str=3D%p", parser, (const char *)stringVal); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; return 1; } @@ -1699,9 +1695,8 @@ virJSONParserHandleStartMap(void *ctx) VIR_DEBUG("parser=3D%p", parser); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; if (VIR_REALLOC_N(parser->state, parser->nstate + 1) < 0) { @@ -1748,9 +1743,8 @@ virJSONParserHandleStartArray(void *ctx) VIR_DEBUG("parser=3D%p", parser); - if (virJSONParserInsertValue(parser, value) < 0) + if (virJSONParserInsertValue(parser, &value) < 0) return 0; - value =3D NULL; if (VIR_REALLOC_N(parser->state, parser->nstate + 1) < 0) --=20 2.29.2