From nobody Mon Feb 9 04:03:18 2026 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=1666620989; cv=none; d=zohomail.com; s=zohoarc; b=itlDAbyWNvD7MDGd2/NUoOgbs/GBynmrCCU5GsVEJ5ZVh4ASYXHZL4yksr+MYzSIKmM/crVjZkm1MhKixngUU4HrAUlUtPHFHbncxu6kjeTRbllqm1vS6ckgL8Ja8nLpWWD9GvBoC4p0/YruViITbGvmI8S6+sdH4AF59CfwdIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620989; 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=/XRaDW1jdAqNQPiZBNbH1gYEG5I3ImJ9iTi4NEcMkeY=; b=fxmjlFKTObBNd1aEI35fhoEj9e3SLerJsK/3MzC3ZiI2lqKKUMbC6wRdwQOH18Hr6DV17F9mhsH2rBIknjVsCL7wdTJ9lerL04tCMZwLm/BUrsZU2pqLVCjkYAQxAwhNiWh8e4lbeYbio8AhazWsU3nCVua8/sUmJ9Mf3wK2gOs= 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 1666620989974505.5416859254683; Mon, 24 Oct 2022 07:16:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-150-uh4u4-lbNqWjD07TKcCPAQ-1; Mon, 24 Oct 2022 10:16:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D2A5857ABF; Mon, 24 Oct 2022 14:15:23 +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 1A38B112132C; Mon, 24 Oct 2022 14:15:23 +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 0EF861946594; Mon, 24 Oct 2022 14:15:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 972DE19465B1 for ; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8954B40C2140; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E63A240C2064 for ; Mon, 24 Oct 2022 14:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620988; 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=/XRaDW1jdAqNQPiZBNbH1gYEG5I3ImJ9iTi4NEcMkeY=; b=AnI0DBwxAaGkmTVCyqzGmCaWKHrUrKBMM6hmrI0Bu/oZ3041VOg02gRkyYzxLwIAA4KyqP 2r81vciElDJRrRILwJdJA7e1Wmielc2lJVzMNkm/6KHSpCwn7ZZwXWJoLI249ff/lCqNoA +C5VT0j51b1ji3dsL5UKLKeVPWej5sI= X-MC-Unique: uh4u4-lbNqWjD07TKcCPAQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/43] util: xml: Introduce virXPathU(Int|LongLong)Base Date: Mon, 24 Oct 2022 16:14:24 +0200 Message-Id: <122236d6ac1d220150386edf568a1c39e52e41a0.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 3.1 on 10.11.54.3 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: 1666620990629100001 Content-Type: text/plain; charset="utf-8" In an effort to remove the 'Long' variants of XPath number fetching functions we need a way to replace the hex number parsing capability. The new helpers are created from the originals by adding a 'base' argument and keeping the original function as a wrapper to pass 10. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 2 ++ src/util/virxml.c | 42 ++++++++++++++++++++++++++++++---------- src/util/virxml.h | 10 ++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c6445dedcb..dab3b389c8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3699,9 +3699,11 @@ virXPathNode; virXPathNodeSet; virXPathString; virXPathUInt; +virXPathUIntBase; virXPathULong; virXPathULongHex; virXPathULongLong; +virXPathULongLongBase; # Let emacs know we want case-insensitive sorting diff --git a/src/util/virxml.c b/src/util/virxml.c index d885fc1680..a47a5d49fc 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -228,9 +228,10 @@ virXPathULongBase(const char *xpath, /** - * virXPathUInt: + * virXPathUIntBase: * @xpath: the XPath string to evaluate * @ctxt: an XPath context + * @base: base of the number to fetch @value as * @value: the returned unsigned int value * * Convenience function to evaluate an XPath number. The @xpath expression @@ -242,22 +243,32 @@ virXPathULongBase(const char *xpath, * value doesn't have an unsigned int format. */ int -virXPathUInt(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value) +virXPathUIntBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned int *value) { g_autoptr(xmlXPathObject) obj =3D NULL; if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ui((char *) obj->stringval, NULL, 10, value) < 0) + if (virStrToLong_ui((char *) obj->stringval, NULL, base, value) < 0) return -2; return 0; } +int +virXPathUInt(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int *value) +{ + return virXPathUIntBase(xpath, ctxt, 10, value); +} + + /** * virXPathULong: * @xpath: the XPath string to evaluate @@ -302,9 +313,10 @@ virXPathULongHex(const char *xpath, /** - * virXPathULongLong: + * virXPathULongLongBase: * @xpath: the XPath string to evaluate * @ctxt: an XPath context + * @base: base of the number to fetch @value as * @value: the returned unsigned long long value * * Convenience function to evaluate an XPath number. The @xpath expression @@ -316,22 +328,32 @@ virXPathULongHex(const char *xpath, * value doesn't have a unsigned long long format. */ int -virXPathULongLong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long long *value) +virXPathULongLongBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned long long *value) { g_autoptr(xmlXPathObject) obj =3D NULL; if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ullp((char *) obj->stringval, NULL, 10, value) < 0) + if (virStrToLong_ullp((char *) obj->stringval, NULL, base, value) < 0) return -2; return 0; } +int +virXPathULongLong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long long *value) +{ + return virXPathULongLongBase(xpath, ctxt, 10, value); +} + + /** * virXPathLongLong: * @xpath: the XPath string to evaluate diff --git a/src/util/virxml.h b/src/util/virxml.h index fe07e2d223..bdd2e9145d 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -51,6 +51,11 @@ virXPathInt(const char *xpath, xmlXPathContextPtr ctxt, int *value); int +virXPathUIntBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned int *value); +int virXPathUInt(const char *xpath, xmlXPathContextPtr ctxt, unsigned int *value); @@ -63,6 +68,11 @@ virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); int +virXPathULongLongBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned long long *value); +int virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value); --=20 2.37.3