From nobody Sun Feb 8 18:30:45 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=1636043546; cv=none; d=zohomail.com; s=zohoarc; b=k6sA7l9JfpYSwk8fRSzEpN+mA5gkjqwly5WBAduOR7SJjiHPLy3cikYSjDd46eSiuRmG2mjHHVMYRhq3Y1d8dYgEcntZOBp6/wUMy99CobWO7CmeYo9EAjojesY4pmX9Ff9pEIonKdkwFHVL5VVKwqxEqhtUtXhPgz3xbk2kXHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043546; h=Content-Type:Content-Transfer-Encoding:Cc: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=Kv87WaFOI8dk2WDvNVR9dZZqlrOPe+n5WkqEUq/uMJo=; b=EyZUVnnOq7Rc8x9OfsYXYH5WTsRxJTWMnSgjDpUOWmCgKOBkWesKvcvMZ1rIpES9JYuV4vx0E04lZyxuhFmaxn0Opn7eGYLAgINWXvhG2hNqFwimenw5SvBYPDThrQcy1BGWblhTZ7LJDlBM5MiSYzLZ4iILwsN2Az32I6SRd9E= 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 1636043546977833.4725844336695; Thu, 4 Nov 2021 09:32:26 -0700 (PDT) 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-518-u6Aj_RB3MUqg7lVI0rYdpg-1; Thu, 04 Nov 2021 12:32:23 -0400 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 DF9808799EC; Thu, 4 Nov 2021 16:32:18 +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 9527A5D9DE; Thu, 4 Nov 2021 16:32:18 +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 5B6084EA30; Thu, 4 Nov 2021 16:32:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRNQ4026340 for ; Thu, 4 Nov 2021 12:27:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC16219724; Thu, 4 Nov 2021 16:27:23 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 124B819C79; Thu, 4 Nov 2021 16:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043545; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=Kv87WaFOI8dk2WDvNVR9dZZqlrOPe+n5WkqEUq/uMJo=; b=fagoMQVMudLFGht5pHgW+rCgVCFabz4D2mMDOLt6vfudrOW6CHKT6sAZtgQezhie30Qj4b T8qyZeBIk/lgxB6041tpHC7M35NVGcS3Lz/6iWEmpLCysIQ15GlLQjMGFCTRPE2/YjEghl asTL6Gem9j5vlbnCki5+g1xdKFpwMyI= X-MC-Unique: u6Aj_RB3MUqg7lVI0rYdpg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/20] cpu_x86: Simplify x86ParseMSR Date: Thu, 4 Nov 2021 17:27:02 +0100 Message-Id: <20211104162720.108973-3-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1636043548422100001 Content-Type: text/plain; charset="utf-8" ... by using virXMLProp*() helpers. These only require a xmlNodePtr and do not need a xmlXPathContextPtr. Reflect that in the function signature. Signed-off-by: Tim Wiederhake --- src/cpu/cpu_x86.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index b0f6fa8f34..006221215a 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1048,26 +1048,22 @@ x86ParseCPUID(xmlNodePtr node, =20 =20 static int -x86ParseMSR(xmlXPathContextPtr ctxt, +x86ParseMSR(xmlNodePtr node, virCPUx86DataItem *item) { - virCPUx86MSR *msr; - unsigned long index; - unsigned long eax; - unsigned long edx; + virCPUx86MSR msr; =20 - memset(item, 0, sizeof(*item)); + memset(&msr, 0, sizeof(msr)); =20 - if (virXPathULongHex("string(@index)", ctxt, &index) < 0 || - virXPathULongHex("string(@eax)", ctxt, &eax) < 0 || - virXPathULongHex("string(@edx)", ctxt, &edx) < 0) + if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index= ) < 0) + return -1; + if (virXMLPropUInt(node, "eax", 0, VIR_XML_PROP_REQUIRED, &msr.eax) < = 0) + return -1; + if (virXMLPropUInt(node, "edx", 0, VIR_XML_PROP_REQUIRED, &msr.edx) < = 0) return -1; =20 item->type =3D VIR_CPU_X86_DATA_MSR; - msr =3D &item->data.msr; - msr->index =3D index; - msr->eax =3D eax; - msr->edx =3D edx; + item->data.msr =3D msr; return 0; } =20 @@ -1120,7 +1116,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, return -1; } } else { - if (x86ParseMSR(ctxt, &item) < 0) { + if (x86ParseMSR(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid msr[%zu] in %s feature"), i, feature->name); @@ -1809,7 +1805,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) return NULL; } } else { - if (x86ParseMSR(ctxt, &item) < 0) { + if (x86ParseMSR(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse msr[%zu]"), i); return NULL; --=20 2.31.1