From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1640175722; cv=none; d=zohomail.com; s=zohoarc; b=I3pYUeJBZp3WiwMkQG4i7SepFr1JbCckIwQzAz29COX3jJ/4/kAHIP1Grl+lbE0e3HCsTwfqEYfjn4H4n4h+pUvDUI8QQXOzdGe7GK1dTXs3sIqKwwPfidE+azY6qZn3fYFVyMsAOqmmXnu7UccCtsjbKOwysXjZDUd9pEKor6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175722; 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=ePnRyf6EQeaVYYduVsB2Bp0dxg86VVfWZ3JcGD3H4C0=; b=OKS1SBb5j4RtkDPQp3jzxWSvwj1KHO+10eultiNkc8HfuEscKOekWjow6+Wuy97wCme0UFiMSy9nJWnF8DMr+UwEbDqAxLWJoFIA9jnkCBFnkMaGlwBjS9riY1WkWwJMwuQ4LFDBl/sS8H8dPkQZ/DsI6pxm0vQYhPrDlr6mwuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1640175722634197.04950251094704; Wed, 22 Dec 2021 04:22:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-txOmsQhqNSu0VpG3Nh7OpQ-1; Wed, 22 Dec 2021 07:21:57 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 675F885EE68; Wed, 22 Dec 2021 12:21:53 +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 42D2F7B03F; Wed, 22 Dec 2021 12:21:53 +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 0806A4A7CD; Wed, 22 Dec 2021 12:21:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3Raa008365 for ; Wed, 22 Dec 2021 07:03:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id DB2F173146; Wed, 22 Dec 2021 12:03:27 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C6B709AA for ; Wed, 22 Dec 2021 12:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175721; 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=ePnRyf6EQeaVYYduVsB2Bp0dxg86VVfWZ3JcGD3H4C0=; b=epVuPcSQRxwrFX+C2SsMD8KdcEvTEdDvHV7Bx2tkLJJoOBdCvLCVd1RtyrdnNIIC/ZdfFF DdhpUptoaUR9xIbZzWZlxUZz453osBqRr/jKP1KlnoTFediJvorXClMiFmRjKgXXAU8IaS DRp8dwsKpkaaZakkgg1+wcRWQjcMw10= X-MC-Unique: txOmsQhqNSu0VpG3Nh7OpQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] qemuBlockStorageSourceGetRBDProps: Simplify generation of auth modes Date: Wed, 22 Dec 2021 13:02:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.12 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) X-ZM-MESSAGEID: 1640175722893100001 Content-Type: text/plain; charset="utf-8" The auth mode array is static, parse it from a JSON string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/qemu/qemu_block.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 2e606e99b4..e5ff653a60 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -881,7 +881,6 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src, const char *encformat; const char *username =3D NULL; g_autoptr(virJSONValue) authmodes =3D NULL; - g_autoptr(virJSONValue) mode =3D NULL; const char *keysecret =3D NULL; if (src->nhosts > 0 && @@ -892,14 +891,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *sr= c, username =3D srcPriv->secinfo->username; keysecret =3D srcPriv->secinfo->alias; /* the auth modes are modelled after our old command line generato= r */ - authmodes =3D virJSONValueNewArray(); - - if (!(mode =3D virJSONValueNewString("cephx")) || - virJSONValueArrayAppend(authmodes, &mode) < 0) - return NULL; - - if (!(mode =3D virJSONValueNewString("none")) || - virJSONValueArrayAppend(authmodes, &mode) < 0) + if (!(authmodes =3D virJSONValueFromString("[\"cephx\",\"none\"]")= )) return NULL; } --=20 2.31.1 From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1640175703; cv=none; d=zohomail.com; s=zohoarc; b=c7aiUuWzjE9cqdTnOH227X5zA26n63DR43DCAeUu+lP7ieaVqXmQAWkTrF6mx8detuUT2aG0y17fvV6pEpFKALg9KrN2lrXwfLOMoLaoA7S9bfTflJMJi7VndXeW7LdxkJq14UNVHkQAs7RwtvUQ10SKkLKn6Maxo0rRe/lq78g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175703; 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=ST/s460K6Y/ArzYNLRZrp3rSK7hBEoNonOOBVW1uoTY=; b=Y+0ghum9HStmSZ73Bm29GMLfa5AQOsgASoMT7K4blMwTmf+GBljzMBrWqh6OYWxPvmJ1+lVaD2K718PVdsyH/f57oTvtji6GAOxHvOSwIVLMjSC4Gyp/Wnj/QW4eBejAxoJwDuDriztX+k/AqUtNQ7ZHH6y/jJMba8zbF1H1s9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1640175703963560.0770522775231; Wed, 22 Dec 2021 04:21:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-4xd_3TiTPpm_H-VIZ2O6Uw-1; Wed, 22 Dec 2021 07:21:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E92B0760C6; Wed, 22 Dec 2021 12:21:33 +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 DB5AF5F914; Wed, 22 Dec 2021 12:21:32 +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 01E594A7C8; Wed, 22 Dec 2021 12:21:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3SGQ008405 for ; Wed, 22 Dec 2021 07:03:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id E803B7314B; Wed, 22 Dec 2021 12:03:28 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A444709AA for ; Wed, 22 Dec 2021 12:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175703; 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=ST/s460K6Y/ArzYNLRZrp3rSK7hBEoNonOOBVW1uoTY=; b=NQA9EX2KwxqRC450tg81TS72jBPEXoDVBUyrlNpL5z5Dmao9yfggEBvEh+XHEGnXA2yIba ki2sB6c2UExMzUGS3nSojx7ga9SdXo459C8vCHsWYoMVbN5h4xyh9SFsTV0knLDXlWcxcn Sp5BBjRRCBMA16Fm5fGjWCf1YAj3NNI= X-MC-Unique: 4xd_3TiTPpm_H-VIZ2O6Uw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] Replace open coded virJSONValueArrayAppendString Date: Wed, 22 Dec 2021 13:02:38 +0100 Message-Id: <92b1a6a5ade6cab94e4fc964af76618430afd75b.1640174526.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1640175705546100001 Content-Type: text/plain; charset="utf-8" In two instances we've created a string virJSONValue just to append it to the array. Replace it by use of the virJSONValueArrayAppendString helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/qemu/qemu_agent.c | 4 +--- src/util/virmacmap.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index e2107e5cbf..cb3bf97415 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1168,9 +1168,7 @@ qemuAgentMakeStringsArray(const char **strings, unsig= ned int len) g_autoptr(virJSONValue) ret =3D virJSONValueNewArray(); for (i =3D 0; i < len; i++) { - g_autoptr(virJSONValue) str =3D virJSONValueNewString(strings[i]); - - if (virJSONValueArrayAppend(ret, &str) < 0) + if (virJSONValueArrayAppendString(ret, strings[i]) < 0) return NULL; } diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index 0b7b758c6d..cf554205a8 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -214,9 +214,7 @@ virMACMapHashDumper(void *payload, GSList *next; for (next =3D macs; next; next =3D next->next) { - g_autoptr(virJSONValue) m =3D virJSONValueNewString((const char *)= next->data); - - if (virJSONValueArrayAppend(arr, &m) < 0) + if (virJSONValueArrayAppendString(arr, (const char *) next->data) = < 0) return -1; } --=20 2.31.1 From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1640175794; cv=none; d=zohomail.com; s=zohoarc; b=QxdZ5zX7c3+NNhBaclsTvlDM+OK6A6TumQ1PKh0dpwb/jLni8npS7MY0aUnD9t3yeeKE6UwMmImzMuGodNPPi9Lmxerx1KPb7taE9fh7bifrhyQVSE3CBKLiEtQ2zl/e36ImaIYOsJBb36oD0nLFzfJA8txinv7bbldZNAVjf+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175794; 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=xxm5A6pfbprpREeSurRbzEfksIKWWy9UNRQtJ/ZWQgE=; b=LPc1y6xzcrYRZqV4bL1PSYaX6CwnIYt5vJbHZpc5GKXOcZ+bIRqIIMb0FwrcgKlpiSx/ivuJhp/bFQGoUFrwSe2Pki5tZ2VoO+VtwXmsN85eNIo7GKu5wUNZG8vtzi6DnzQtq2/URqPZvlJcZEk6EBI6p6gupIEQAwdQXKkwtEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1640175794771643.3382950338455; Wed, 22 Dec 2021 04:23:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-UPcC7pEkNf-2LBKu0vk52A-1; Wed, 22 Dec 2021 07:22:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 204B285EE69; Wed, 22 Dec 2021 12:21:57 +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 EE88C5F913; Wed, 22 Dec 2021 12:21:56 +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 5D1131806D2B; Wed, 22 Dec 2021 12:21:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3Uk1008420 for ; Wed, 22 Dec 2021 07:03:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0DED17314B; Wed, 22 Dec 2021 12:03:30 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60113709AA for ; Wed, 22 Dec 2021 12:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175793; 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=xxm5A6pfbprpREeSurRbzEfksIKWWy9UNRQtJ/ZWQgE=; b=eZENOItUbU1gML9DRK3FhdFcFjOW3oPbopIIqLX9R6Z3QAJzLHtxL1xSH+bOQfrt0VPj7j ftFOqnFm0ygFx7elUhhNFNsUBhIXMl+rclxydxi5dlYsuMzNAF/ry6O/5np7NejhXo4S/F K06+CVEKGo579Lg0mGV6ewwXBjy7XEE= X-MC-Unique: UPcC7pEkNf-2LBKu0vk52A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] util: json: Don't copy string in virJSONValueNewString Date: Wed, 22 Dec 2021 13:02:39 +0100 Message-Id: <854c4680219cd8e5b15d7c82513888613708bf25.1640174526.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1640175796042100001 Content-Type: text/plain; charset="utf-8" With 'g_strdup' not needing error handling we can ask callers to pass a copy of the string which will be adopted by the JSON value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/util/virjson.c | 17 +++++++---------- src/util/virjson.h | 2 +- tests/virjsontest.c | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index dbc5b7840c..37301bb87e 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -412,7 +412,7 @@ virJSONValueHashFree(void *opaque) virJSONValue * -virJSONValueNewString(const char *data) +virJSONValueNewString(char *data) { virJSONValue *val; @@ -422,7 +422,7 @@ virJSONValueNewString(const char *data) val =3D g_new0(virJSONValue, 1); val->type =3D VIR_JSON_TYPE_STRING; - val->data.string =3D g_strdup(data); + val->data.string =3D data; return val; } @@ -608,12 +608,9 @@ virJSONValueObjectInsertString(virJSONValue *object, const char *value, bool prepend) { - virJSONValue *jvalue =3D virJSONValueNewString(value); - if (!jvalue) - return -1; - if (virJSONValueObjectInsert(object, key, &jvalue, prepend) < 0) - return -1; - return 0; + g_autoptr(virJSONValue) jvalue =3D virJSONValueNewString(g_strdup(valu= e)); + + return virJSONValueObjectInsert(object, key, &jvalue, prepend); } @@ -775,7 +772,7 @@ int virJSONValueArrayAppendString(virJSONValue *object, const char *value) { - g_autoptr(virJSONValue) jvalue =3D virJSONValueNewString(value); + g_autoptr(virJSONValue) jvalue =3D virJSONValueNewString(g_strdup(valu= e)); if (virJSONValueArrayAppend(object, &jvalue) < 0) return -1; @@ -1438,7 +1435,7 @@ virJSONValueCopy(const virJSONValue *in) /* No need to error out in the following cases */ case VIR_JSON_TYPE_STRING: - out =3D virJSONValueNewString(in->data.string); + out =3D virJSONValueNewString(g_strdup(in->data.string)); break; case VIR_JSON_TYPE_NUMBER: out =3D virJSONValueNewNumber(g_strdup(in->data.number)); diff --git a/src/util/virjson.h b/src/util/virjson.h index 361b0190e8..71b88183fe 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -50,7 +50,7 @@ int virJSONValueObjectAddVArgs(virJSONValue **objptr, va_= list args) ATTRIBUTE_NONNULL(1); -virJSONValue *virJSONValueNewString(const char *data); +virJSONValue *virJSONValueNewString(char *data); virJSONValue *virJSONValueNewStringLen(const char *data, size_t length); virJSONValue *virJSONValueNewNumberInt(int data); virJSONValue *virJSONValueNewNumberUint(unsigned int data); diff --git a/tests/virjsontest.c b/tests/virjsontest.c index ddb93803b7..78283b632a 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -441,8 +441,8 @@ testJSONObjectFormatSteal(const void *opaque G_GNUC_UNU= SED) g_autoptr(virJSONValue) t1 =3D NULL; g_autoptr(virJSONValue) t2 =3D NULL; - if (!(a1 =3D virJSONValueNewString("test")) || - !(a2 =3D virJSONValueNewString("test"))) { + if (!(a1 =3D virJSONValueNewString(g_strdup("test"))) || + !(a2 =3D virJSONValueNewString(g_strdup("test")))) { VIR_TEST_VERBOSE("Failed to create json object"); } --=20 2.31.1 From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1640175787; cv=none; d=zohomail.com; s=zohoarc; b=nsoJj8XYTe8ZqUDd55dFTu8ghRVp5YFzXda642RvnH1P+2N/j+H740WEhi1GHPd7cJOQ66sFpY2TzTNrjc9bJNcOEkBWPgZDQLzTAI14W8gOK32x8f0eUW7NkOyk/t3R952rmt9IvVS2OHNgnvjYcfnIhYO9GevtiQ8Yj+N2r5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175787; 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=EoxvDBBmF12GJdmx81ea2GRKzRstcfMoEE4QeG4X/20=; b=asir1FPqdenq4s6LmkvdQJUTqaicoLJFf7a+6eNGQGu/slsGai65Z+QXiI6l3VAajInL2bkmOLMKLbJupytmEFEExB293lGdV4lcsHY+osG1hJdUMG/fVLxlKy7PWknqdQN1wzHoMMxk4e7tjwTA26kbBm4i/zS58eJJXY0azkE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1640175787372463.85259415667497; Wed, 22 Dec 2021 04:23:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-ZRaho-hbMzaNFr7H8yliPQ-1; Wed, 22 Dec 2021 07:21:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF6B8101F003; Wed, 22 Dec 2021 12:21:52 +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 CA21873159; Wed, 22 Dec 2021 12:21:52 +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 8E8114A7C9; Wed, 22 Dec 2021 12:21:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3V7U008445 for ; Wed, 22 Dec 2021 07:03:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 385C77314B; Wed, 22 Dec 2021 12:03:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 816A7709AA for ; Wed, 22 Dec 2021 12:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175786; 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=EoxvDBBmF12GJdmx81ea2GRKzRstcfMoEE4QeG4X/20=; b=gH2GRRIdpUDikqa66k40Ogeo2XeStPs3ltA4YM/55Uge+Zj3GINA19/B0gEprh83iETreZ MwZLGOIEQM0FkU5+ic+Qz5rUM+DnnawrCJAeSbu51mYxXyDFwuR4/nHsIGQ5gUHj7E2wiW ykYt4FiYyFqjVV9/ZuUGxmcxOz16RJA= X-MC-Unique: ZRaho-hbMzaNFr7H8yliPQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] util: json: Open-code only call of virJSONValueNewStringLen Date: Wed, 22 Dec 2021 13:02:40 +0100 Message-Id: <80bf311546fa4937f690821fc5752852ed63ac38.1640174526.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.13 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) X-ZM-MESSAGEID: 1640175788655100001 Content-Type: text/plain; charset="utf-8" Replace the function by a call to virJSONValueNewString, when we copy the string using g_strndup. Remove the unused helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/libvirt_private.syms | 1 - src/util/virjson.c | 21 +-------------------- src/util/virjson.h | 1 - 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2c16c469d..bf5d0f54f3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2536,7 +2536,6 @@ virJSONValueNewNumberUint; virJSONValueNewNumberUlong; virJSONValueNewObject; virJSONValueNewString; -virJSONValueNewStringLen; virJSONValueObjectAdd; virJSONValueObjectAddVArgs; virJSONValueObjectAppend; diff --git a/src/util/virjson.c b/src/util/virjson.c index 37301bb87e..719f4de1bf 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -428,24 +428,6 @@ virJSONValueNewString(char *data) } -virJSONValue * -virJSONValueNewStringLen(const char *data, - size_t length) -{ - virJSONValue *val; - - if (!data) - return virJSONValueNewNull(); - - val =3D g_new0(virJSONValue, 1); - - val->type =3D VIR_JSON_TYPE_STRING; - val->data.string =3D g_strndup(data, length); - - return val; -} - - /** * virJSONValueNewNumber: * @data: string representing the number @@ -1558,8 +1540,7 @@ virJSONParserHandleString(void *ctx, size_t stringLen) { virJSONParser *parser =3D ctx; - g_autoptr(virJSONValue) value =3D virJSONValueNewStringLen((const char= *)stringVal, - stringLen); + g_autoptr(virJSONValue) value =3D virJSONValueNewString(g_strndup((con= st char *)stringVal, stringLen)); VIR_DEBUG("parser=3D%p str=3D%p", parser, (const char *)stringVal); diff --git a/src/util/virjson.h b/src/util/virjson.h index 71b88183fe..cb2315d13e 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -51,7 +51,6 @@ int virJSONValueObjectAddVArgs(virJSONValue **objptr, va_= list args) virJSONValue *virJSONValueNewString(char *data); -virJSONValue *virJSONValueNewStringLen(const char *data, size_t length); virJSONValue *virJSONValueNewNumberInt(int data); virJSONValue *virJSONValueNewNumberUint(unsigned int data); virJSONValue *virJSONValueNewNumberLong(long long data); --=20 2.31.1 From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1640175782; cv=none; d=zohomail.com; s=zohoarc; b=KjpMSO9U7T2AYSXr9tIjzirVKOiW50gVSlkjGc47LPgNLFvjhNDVwxxDWDPrUjlDGSCUB/UG7D9CCik6z3YqGOvPeIrVXEwHiDzbh7iC5zyQVW/6XIcTjbibyftHmD6SH6ZDVVIvEHKkHoHhY6VsAVUGfg9fizqc/OsGYT3Fyk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175782; 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=7Xy6B5RBCrpdLFlG+2AcctBc+LkRuS6A4isAnhP1nZw=; b=AlTHF9BJEMGMHtxP5tyxsdCay8DUXKCOT9jbka2z50HAx3zPSoUcR6k9T3Z5nWi1Qxq9MnQb7MNbAnSjZHlHY32BOpUBIW5zOvsJckrhQ8UEKKgo1BbvSm55S3+AtolE8pPORCb42p0XhxHe6SrGpYAUsQFNOEtP6bWmvZMaCy0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 164017578297819.948597263565944; Wed, 22 Dec 2021 04:23:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-iiUS27aZOm6-PoN1jcoPqg-1; Wed, 22 Dec 2021 07:22:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3CFF1030C2C; Wed, 22 Dec 2021 12:22:01 +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 7BA4347383; Wed, 22 Dec 2021 12:22: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 3FCFD4A710; Wed, 22 Dec 2021 12:22:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3WAj008470 for ; Wed, 22 Dec 2021 07:03:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 567DB7314B; Wed, 22 Dec 2021 12:03:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6735709AA for ; Wed, 22 Dec 2021 12:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175781; 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=7Xy6B5RBCrpdLFlG+2AcctBc+LkRuS6A4isAnhP1nZw=; b=MM7BKpr643etUA7IqRSu82DceKMXrdhRWwpiMCykNE8qI+x1FB1Nw4NXUC5wtzg0YuElZ1 La51T9UskPsbUeAm25x11GLXW3khF6U10mqzAB+yeC1IWr9LuGeSC+4M/YvLgRrZvWUL9A /EaZ1ndroC4tOoJrY+PNzCr8Pbv1wQI= X-MC-Unique: iiUS27aZOm6-PoN1jcoPqg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] util: json: Remove virJSONValueIsNull/virJSONValueObjectIsNull Date: Wed, 22 Dec 2021 13:02:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.15 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) X-ZM-MESSAGEID: 1640175784119100001 Content-Type: text/plain; charset="utf-8" If needed 'virJSONValueIsNull' can be easily replaced by 'virJSONValueGetType(obj) =3D=3D VIR_JSON_TYPE_NULL'. 'virJSONValueObjectIsNull' has confusing name because it checks that a virJSONValue of OBJECT type has a key which is NULL, not that the object itself is NULL. This can be replaced according to the needs e.g. by virJSONValueObjectHasKey or the above check. Both are unused. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/libvirt_private.syms | 2 -- src/util/virjson.c | 19 ------------------- src/util/virjson.h | 2 -- 3 files changed, 23 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bf5d0f54f3..435ee8054c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2524,7 +2524,6 @@ virJSONValueGetString; virJSONValueGetType; virJSONValueHashFree; virJSONValueIsArray; -virJSONValueIsNull; virJSONValueIsObject; virJSONValueNewArray; virJSONValueNewBoolean; @@ -2565,7 +2564,6 @@ virJSONValueObjectGetString; virJSONValueObjectGetStringArray; virJSONValueObjectGetValue; virJSONValueObjectHasKey; -virJSONValueObjectIsNull; virJSONValueObjectKeysNumber; virJSONValueObjectPrependString; virJSONValueObjectRemoveKey; diff --git a/src/util/virjson.c b/src/util/virjson.c index 719f4de1bf..1c6fef22da 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1136,13 +1136,6 @@ virJSONValueGetBoolean(virJSONValue *val, } -bool -virJSONValueIsNull(virJSONValue *val) -{ - return val->type =3D=3D VIR_JSON_TYPE_NULL; -} - - const char * virJSONValueObjectGetString(virJSONValue *object, const char *key) @@ -1296,18 +1289,6 @@ virJSONValueObjectStealObject(virJSONValue *object, } -int -virJSONValueObjectIsNull(virJSONValue *object, - const char *key) -{ - virJSONValue *val =3D virJSONValueObjectGet(object, key); - - if (!val) - return -1; - - return virJSONValueIsNull(val); -} - char ** virJSONValueObjectGetStringArray(virJSONValue *object, const char *key) { diff --git a/src/util/virjson.h b/src/util/virjson.h index cb2315d13e..24ac51f4f8 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -99,7 +99,6 @@ int virJSONValueGetNumberLong(virJSONValue *object, long = long *value); int virJSONValueGetNumberUlong(virJSONValue *object, unsigned long long *v= alue); int virJSONValueGetNumberDouble(virJSONValue *object, double *value); int virJSONValueGetBoolean(virJSONValue *object, bool *value); -bool virJSONValueIsNull(virJSONValue *object); virJSONValue *virJSONValueObjectGetObject(virJSONValue *object, const char *key); virJSONValue *virJSONValueObjectGetArray(virJSONValue *object, @@ -118,7 +117,6 @@ int virJSONValueObjectGetNumberLong(virJSONValue *objec= t, const char *key, long int virJSONValueObjectGetNumberUlong(virJSONValue *object, const char *key= , unsigned long long *value); int virJSONValueObjectGetNumberDouble(virJSONValue *object, const char *ke= y, double *value); int virJSONValueObjectGetBoolean(virJSONValue *object, const char *key, bo= ol *value); -int virJSONValueObjectIsNull(virJSONValue *object, const char *key); int virJSONValueObjectAppendString(virJSONValue *object, const char *key, = const char *value); int virJSONValueObjectAppendStringPrintf(virJSONValue *object, const char = *key, const char *fmt, ...) --=20 2.31.1 From nobody Mon Apr 29 16:27:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1640175800; cv=none; d=zohomail.com; s=zohoarc; b=iwM1QgNW8T3d1MxzO/Ahf3J8uJSRKXDOWhO81SD2kRfC3zUKcojLBTCyFyrUn79sN8pc61r7wVsswLsudeo3dWAwrfELWFiibO50KIo98a3vHJ10TELrnV6y7JhCetOjA9ZOU8lrOm+EtEF7k9S5wyLk2Xv5gHJxxxxC74GKL4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640175800; 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=UrjyJKJyBjMVgSDKDHscrEWvlq2DaqXNNPTgAmdFJFE=; b=hpjSvAc2sztIWvB05qd1wEF7LriSv8aZI8vqFVz23kQIEawNp9RrwMUl0NOVESZpCM4Hnq3fN3lLelImkw4DACaVIXKsaA6KyfUTxOdGVcULxukSdUutL09+QProUaBkojjfQljjIAiNcoRVTusdGQhIfN8IuctHWCHew3RCAbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16401758006702.661472305426173; Wed, 22 Dec 2021 04:23:20 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-R8DEBUgMMx6-syoc18hhYA-1; Wed, 22 Dec 2021 07:22:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54F3F101F008; Wed, 22 Dec 2021 12:21:57 +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 2F76D79594; Wed, 22 Dec 2021 12:21:57 +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 BC0674A70B; Wed, 22 Dec 2021 12:21:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BMC3XIA008500 for ; Wed, 22 Dec 2021 07:03:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 815D8709AA; Wed, 22 Dec 2021 12:03:33 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA7437314D for ; Wed, 22 Dec 2021 12:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640175799; 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=UrjyJKJyBjMVgSDKDHscrEWvlq2DaqXNNPTgAmdFJFE=; b=QCVvgg2RtVhFajVcPGe3b/kg1cGL1SOPamKLkD/JXcf0fYSHya32Sy69jgX8dGzDpp375H 4s79sXLGA7MCcMmtnPNOxBziIDVmqNcyfwsiXVTj4JI9O0m0wlsXRdVeGpCmE/C1983F9F IRwT8144cfjNkDs+joRoTvS49hX6x5Q= X-MC-Unique: R8DEBUgMMx6-syoc18hhYA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] util: virjson.h: Reformat headers to conform with new style Date: Wed, 22 Dec 2021 13:02:42 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1640175802543100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Tim Wiederhake --- src/util/virjson.h | 312 +++++++++++++++++++++++++++++++-------------- 1 file changed, 218 insertions(+), 94 deletions(-) diff --git a/src/util/virjson.h b/src/util/virjson.h index 24ac51f4f8..f0b8c419de 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -39,123 +39,247 @@ typedef enum { typedef struct _virJSONValue virJSONValue; -void virJSONValueFree(virJSONValue *value); -void virJSONValueHashFree(void *opaque); +void +virJSONValueFree(virJSONValue *value); +void +virJSONValueHashFree(void *opaque); -virJSONType virJSONValueGetType(const virJSONValue *value); +virJSONType +virJSONValueGetType(const virJSONValue *value); -int virJSONValueObjectAdd(virJSONValue **obj, ...) +int +virJSONValueObjectAdd(virJSONValue **obj, ...) ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED; -int virJSONValueObjectAddVArgs(virJSONValue **objptr, va_list args) +int +virJSONValueObjectAddVArgs(virJSONValue **objptr, + va_list args) ATTRIBUTE_NONNULL(1); -virJSONValue *virJSONValueNewString(char *data); -virJSONValue *virJSONValueNewNumberInt(int data); -virJSONValue *virJSONValueNewNumberUint(unsigned int data); -virJSONValue *virJSONValueNewNumberLong(long long data); -virJSONValue *virJSONValueNewNumberUlong(unsigned long long data); -virJSONValue *virJSONValueNewNumberDouble(double data); -virJSONValue *virJSONValueNewBoolean(int boolean); -virJSONValue *virJSONValueNewNull(void); -virJSONValue *virJSONValueNewArray(void); -virJSONValue *virJSONValueNewObject(void); +virJSONValue * +virJSONValueNewString(char *data); +virJSONValue * +virJSONValueNewNumberInt(int data); +virJSONValue * +virJSONValueNewNumberUint(unsigned int data); +virJSONValue * +virJSONValueNewNumberLong(long long data); +virJSONValue * +virJSONValueNewNumberUlong(unsigned long long data); +virJSONValue * +virJSONValueNewNumberDouble(double data); +virJSONValue * +virJSONValueNewBoolean(int boolean); +virJSONValue * +virJSONValueNewNull(void); +virJSONValue * +virJSONValueNewArray(void); +virJSONValue * +virJSONValueNewObject(void); + +int +virJSONValueObjectAppend(virJSONValue *object, + const char *key, + virJSONValue **value); +int +virJSONValueArrayAppend(virJSONValue *object, + virJSONValue **value); +int +virJSONValueArrayConcat(virJSONValue *a, + virJSONValue *c); + +int +virJSONValueObjectHasKey(virJSONValue *object, + const char *key); +virJSONValue * +virJSONValueObjectGet(virJSONValue *object, + const char *key); +virJSONValue * +virJSONValueObjectGetByType(virJSONValue *object, + const char *key, + virJSONType type); + +bool +virJSONValueIsObject(virJSONValue *object); + +bool +virJSONValueIsArray(virJSONValue *array); +size_t +virJSONValueArraySize(const virJSONValue *array); +virJSONValue * +virJSONValueArrayGet(virJSONValue *object, + unsigned int element); +virJSONValue * +virJSONValueArraySteal(virJSONValue *object, + unsigned int element); -int virJSONValueObjectAppend(virJSONValue *object, - const char *key, - virJSONValue **value); -int virJSONValueArrayAppend(virJSONValue *object, - virJSONValue **value); -int virJSONValueArrayConcat(virJSONValue *a, - virJSONValue *c); - -int virJSONValueObjectHasKey(virJSONValue *object, const char *key); -virJSONValue *virJSONValueObjectGet(virJSONValue *object, const char *key); -virJSONValue *virJSONValueObjectGetByType(virJSONValue *object, - const char *key, virJSONType t= ype); - -bool virJSONValueIsObject(virJSONValue *object); - -bool virJSONValueIsArray(virJSONValue *array); -size_t virJSONValueArraySize(const virJSONValue *array); -virJSONValue *virJSONValueArrayGet(virJSONValue *object, unsigned int elem= ent); -virJSONValue *virJSONValueArraySteal(virJSONValue *object, unsigned int el= ement); typedef int (*virJSONArrayIteratorFunc)(size_t pos, virJSONValue *item, void *opaque); -int virJSONValueArrayForeachSteal(virJSONValue *array, - virJSONArrayIteratorFunc cb, - void *opaque); -int virJSONValueObjectKeysNumber(virJSONValue *object); -const char *virJSONValueObjectGetKey(virJSONValue *object, unsigned int n); -virJSONValue *virJSONValueObjectGetValue(virJSONValue *object, unsigned in= t n); - -const char *virJSONValueGetString(virJSONValue *object); -const char *virJSONValueGetNumberString(virJSONValue *number); -int virJSONValueGetNumberInt(virJSONValue *object, int *value); -int virJSONValueGetNumberUint(virJSONValue *object, unsigned int *value); -int virJSONValueGetNumberLong(virJSONValue *object, long long *value); -int virJSONValueGetNumberUlong(virJSONValue *object, unsigned long long *v= alue); -int virJSONValueGetNumberDouble(virJSONValue *object, double *value); -int virJSONValueGetBoolean(virJSONValue *object, bool *value); -virJSONValue *virJSONValueObjectGetObject(virJSONValue *object, - const char *key); -virJSONValue *virJSONValueObjectGetArray(virJSONValue *object, - const char *key); -virJSONValue *virJSONValueObjectStealArray(virJSONValue *object, - const char *key); -virJSONValue *virJSONValueObjectStealObject(virJSONValue *object, - const char *key); - -const char *virJSONValueObjectGetString(virJSONValue *object, const char *= key); -char **virJSONValueObjectGetStringArray(virJSONValue *object, const char *= key); -const char *virJSONValueObjectGetStringOrNumber(virJSONValue *object, cons= t char *key); -int virJSONValueObjectGetNumberInt(virJSONValue *object, const char *key, = int *value); -int virJSONValueObjectGetNumberUint(virJSONValue *object, const char *key,= unsigned int *value); -int virJSONValueObjectGetNumberLong(virJSONValue *object, const char *key,= long long *value); -int virJSONValueObjectGetNumberUlong(virJSONValue *object, const char *key= , unsigned long long *value); -int virJSONValueObjectGetNumberDouble(virJSONValue *object, const char *ke= y, double *value); -int virJSONValueObjectGetBoolean(virJSONValue *object, const char *key, bo= ol *value); - -int virJSONValueObjectAppendString(virJSONValue *object, const char *key, = const char *value); -int virJSONValueObjectAppendStringPrintf(virJSONValue *object, const char = *key, const char *fmt, ...) +int +virJSONValueArrayForeachSteal(virJSONValue *array, + virJSONArrayIteratorFunc cb, + void *opaque); + +int +virJSONValueObjectKeysNumber(virJSONValue *object); +const char * +virJSONValueObjectGetKey(virJSONValue *object, + unsigned int n); +virJSONValue * +virJSONValueObjectGetValue(virJSONValue *object, + unsigned int n); + +const char * +virJSONValueGetString(virJSONValue *object); +const char * +virJSONValueGetNumberString(virJSONValue *number); +int +virJSONValueGetNumberInt(virJSONValue *object, + int *value); +int +virJSONValueGetNumberUint(virJSONValue *object, + unsigned int *value); +int +virJSONValueGetNumberLong(virJSONValue *object, + long long *value); +int +virJSONValueGetNumberUlong(virJSONValue *object, + unsigned long long *value); +int +virJSONValueGetNumberDouble(virJSONValue *object, + double *value); +int +virJSONValueGetBoolean(virJSONValue *object, + bool *value); + +virJSONValue * +virJSONValueObjectGetObject(virJSONValue *object, + const char *key); +virJSONValue * +virJSONValueObjectGetArray(virJSONValue *object, + const char *key); +virJSONValue * +virJSONValueObjectStealArray(virJSONValue *object, + const char *key); +virJSONValue * +virJSONValueObjectStealObject(virJSONValue *object, + const char *key); +const char * +virJSONValueObjectGetString(virJSONValue *object, + const char *key); +char ** +virJSONValueObjectGetStringArray(virJSONValue *object, + const char *key); +const char * +virJSONValueObjectGetStringOrNumber(virJSONValue *object, + const char *key); +int +virJSONValueObjectGetNumberInt(virJSONValue *object, + const char *key, + int *value); +int +virJSONValueObjectGetNumberUint(virJSONValue *object, + const char *key, + unsigned int *value); +int +virJSONValueObjectGetNumberLong(virJSONValue *object, + const char *key, + long long *value); +int +virJSONValueObjectGetNumberUlong(virJSONValue *object, + const char *key, + unsigned long long *value); +int +virJSONValueObjectGetNumberDouble(virJSONValue *object, + const char *key, + double *value); +int +virJSONValueObjectGetBoolean(virJSONValue *object, + const char *key, + bool *value); + +int +virJSONValueObjectAppendString(virJSONValue *object, + const char *key, + const char *value); +int +virJSONValueObjectAppendStringPrintf(virJSONValue *object, + const char *key, + const char *fmt, + ...) G_GNUC_PRINTF(3, 4); -int virJSONValueObjectPrependString(virJSONValue *object, const char *key,= const char *value); -int virJSONValueObjectAppendNumberInt(virJSONValue *object, const char *ke= y, int number); -int virJSONValueObjectAppendNumberUint(virJSONValue *object, const char *k= ey, unsigned int number); -int virJSONValueObjectAppendNumberLong(virJSONValue *object, const char *k= ey, long long number); -int virJSONValueObjectAppendNumberUlong(virJSONValue *object, const char *= key, unsigned long long number); -int virJSONValueObjectAppendNumberDouble(virJSONValue *object, const char = *key, double number); -int virJSONValueObjectAppendBoolean(virJSONValue *object, const char *key,= int boolean); -int virJSONValueObjectAppendNull(virJSONValue *object, const char *key); - -int virJSONValueObjectRemoveKey(virJSONValue *object, const char *key, - virJSONValue **value) +int +virJSONValueObjectPrependString(virJSONValue *object, + const char *key, + const char *value); +int +virJSONValueObjectAppendNumberInt(virJSONValue *object, + const char *key, + int number); +int +virJSONValueObjectAppendNumberUint(virJSONValue *object, + const char *key, + unsigned int number); +int +virJSONValueObjectAppendNumberLong(virJSONValue *object, + const char *key, + long long number); +int +virJSONValueObjectAppendNumberUlong(virJSONValue *object, + const char *key, + unsigned long long number); +int +virJSONValueObjectAppendNumberDouble(virJSONValue *object, + const char *key, + double number); +int +virJSONValueObjectAppendBoolean(virJSONValue *object, + const char *key, + int boolean); +int +virJSONValueObjectAppendNull(virJSONValue *object, + const char *key); + +int +virJSONValueObjectRemoveKey(virJSONValue *object, + const char *key, + virJSONValue **value) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int virJSONValueArrayAppendString(virJSONValue *object, const char *value); +int +virJSONValueArrayAppendString(virJSONValue *object, + const char *value); -virJSONValue *virJSONValueFromString(const char *jsonstring); -char *virJSONValueToString(virJSONValue *object, - bool pretty); -int virJSONValueToBuffer(virJSONValue *object, - virBuffer *buf, - bool pretty) +virJSONValue * +virJSONValueFromString(const char *jsonstring); +char * +virJSONValueToString(virJSONValue *object, + bool pretty); +int +virJSONValueToBuffer(virJSONValue *object, + virBuffer *buf, + bool pretty) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; typedef int (*virJSONValueObjectIteratorFunc)(const char *key, virJSONValue *value, void *opaque); -int virJSONValueObjectForeachKeyValue(virJSONValue *object, - virJSONValueObjectIteratorFunc cb, - void *opaque); +int +virJSONValueObjectForeachKeyValue(virJSONValue *object, + virJSONValueObjectIteratorFunc cb, + void *opaque); -virJSONValue *virJSONValueCopy(const virJSONValue *in); +virJSONValue * +virJSONValueCopy(const virJSONValue *in); -char *virJSONStringReformat(const char *jsonstr, bool pretty); +char * +virJSONStringReformat(const char *jsonstr, + bool pretty); -virJSONValue *virJSONValueObjectDeflatten(virJSONValue *json); +virJSONValue * +virJSONValueObjectDeflatten(virJSONValue *json); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virJSONValue, virJSONValueFree); --=20 2.31.1