From nobody Tue Feb 10 00:00:03 2026 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=1654155927; cv=none; d=zohomail.com; s=zohoarc; b=ctcqR68XiNnKhTM12+sYB76O1D6ayTDoHltJ/0JgTk+q6iBAUo99V1DFY2e4e0pohMLJ5CLR7HIDm6BZbitVHYF/WBlMEjL6E2lwmCT2v5d955H/0KK0U2ITwyk05U6NABsFnaWAQtIOxq0WaO/HlmilSoblDEOJIH75BpNfpPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654155927; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Qs6oEKJoEWRMeBxXByVAhflJiNZtd3NG8KXXbF0jYZU=; b=eVVOtY1jYx52ttf+wnnZr0ONv8Fj/eIrHqoWHycwkxX93zX9DAyPDA44r5RZdg8BP498BNGgokSZc7Q9LWuf+OeEoVGi1D9q6UYk9oHKq9kuTXX0VT+8/sD1NF6avovQUU9z3vc0WHe9NynH7t1x2yrlAjtG3U5453zgcklrmQ4= 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 1654155927215749.9309665707087; Thu, 2 Jun 2022 00:45:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-WHKdM67UPZezBzM7Q9ESHg-1; Thu, 02 Jun 2022 03:45:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E5D62949BCE; Thu, 2 Jun 2022 07:45:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AD7DC27E97; Thu, 2 Jun 2022 07:45:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F21861947B84; Thu, 2 Jun 2022 07:45:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 636AC1947B83 for ; Thu, 2 Jun 2022 07:45:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 542E02166B26; Thu, 2 Jun 2022 07:45:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB33D2166B2C for ; Thu, 2 Jun 2022 07:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654155926; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Qs6oEKJoEWRMeBxXByVAhflJiNZtd3NG8KXXbF0jYZU=; b=iExvivJN6gG7qIw2tp6GZ4F/X0tP97+EWw1s7tN9wIElhVc9VYRuOqpCA6vHgEOW6nuimY tK8xbnQpHjyaNp+856It8jFnGSBsWjlolpgLgR89lKlznbfPssOdsJX8ro8XCngO+aMnIw ydYg0Edu2s9xBoFT/UAI3KbJcxqHZEc= X-MC-Unique: WHKdM67UPZezBzM7Q9ESHg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] util: json: Add modifier for adding non-negative long values to JSON objects Date: Thu, 2 Jun 2022 09:45:16 +0200 Message-Id: <965aee5fe46f1b854973df07343bc4c724f7d2de.1654155916.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: 1654155927621100001 Content-Type: text/plain; charset="utf-8" Similarly to the 'k' modifier for integers introduce 'K' for long integers. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/util/virjson.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virjson.c b/src/util/virjson.c index 6e13e97e15..ae970c7653 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -121,6 +121,7 @@ virJSONValueGetType(const virJSONValue *value) * * I: signed long integer value * J: signed long integer value, error if negative + * K: signed long integer value, omitted if negative * Z: signed long integer value, omitted if zero * Y: signed long integer value, omitted if zero, error if negative * @@ -228,6 +229,7 @@ virJSONValueObjectAddVArgs(virJSONValue **objptr, case 'Z': case 'Y': + case 'K': case 'J': case 'I': { long long val =3D va_arg(args, long long); @@ -242,6 +244,9 @@ virJSONValueObjectAddVArgs(virJSONValue **objptr, if (!val && (type =3D=3D 'Z' || type =3D=3D 'Y')) continue; + if (val < 0 && type =3D=3D 'K') + continue; + rc =3D virJSONValueObjectAppendNumberLong(obj, key, val); } break; --=20 2.35.3