From nobody Mon Feb 9 19:55:15 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=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 --- 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