From nobody Fri May 17 10:44:24 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=1618560445; cv=none; d=zohomail.com; s=zohoarc; b=WsDmwb6OYtxp3L7XSVxsuBLLI3efRn0QGEdMB6OGfOcfYyyMeo/NoOIkZihJ38+P4ZfmKXmUE4VqGuvotDjXF/x9iSPZAKGQmkIKWGruVzf0COvqpu9rFF4aD3NqVdeAYGKM8fjrJjotbWLzrZcW0+h8ntDkEVWPZfmm+rFz3cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560445; 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=w2L/fKLZztWqAr2HUTJcBRNZkNk0HmDNyAPjQMkEFbw=; b=Eu14xT4LGoDcbJy5xFk2Aiod+M/2Mtvuy2rVN4QzbR0MPhGfhmWGIxo/NvYJ4whdb+a8/GMSjNfVMx3dgb3NZl0EJeV5HD/18ibLdGN863X8gRG5DJk3TXGbXPPby4I/BBN6QqvW96lmFSxAt5EzXs6Rs1k1/QXKkML2pdfoXzM= 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) header.from= 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 1618560445323835.5065272342516; Fri, 16 Apr 2021 01:07:25 -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-530-s2hDiWa6M8a0io3I5gPV8Q-1; Fri, 16 Apr 2021 04:07:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBE14195D565; Fri, 16 Apr 2021 08:07:16 +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 ECD9410429F0; Fri, 16 Apr 2021 08:07:15 +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 1D69844A5E; Fri, 16 Apr 2021 08:07:15 +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 13G87CS2026063 for ; Fri, 16 Apr 2021 04:07:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC6B77092B; Fri, 16 Apr 2021 08:07:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AE566E512 for ; Fri, 16 Apr 2021 08:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560444; 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=w2L/fKLZztWqAr2HUTJcBRNZkNk0HmDNyAPjQMkEFbw=; b=ApQw0pLmkqRflIb2fsDnuhRjTRLI5K81lTXi6Y3jgMQFl6MXTmYHG9Hb94NEAnS5ubewNq IMC5zx5Z1FeKnzfBn8t5d0bKNtQzPyW2MCXxVtS7VVdx6gsELDjJMFdSlvrQKahWhUxwax Qh6c4ZeLZmoIsUBmEvFNv8V/b0ooV3o= X-MC-Unique: s2hDiWa6M8a0io3I5gPV8Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/5] util: virxml: Fix formatting of virxml.h Date: Fri, 16 Apr 2021 10:07:01 +0200 Message-Id: <1f6f525bb3e4e61ca3502bcf61ad05077c937472.1618560390.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.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" Remove the "block" formatting of function declarations and use uniform spacing. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virxml.h | 192 +++++++++++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 80 deletions(-) diff --git a/src/util/virxml.h b/src/util/virxml.h index de171dce12..84fa4f4baf 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -32,60 +32,80 @@ xmlXPathContextPtr virXMLXPathContextNew(xmlDocPtr xml) G_GNUC_WARN_UNUSED_RESULT; -int virXPathBoolean(const char *xpath, - xmlXPathContextPtr ctxt); -char * virXPathString(const char *xpath, - xmlXPathContextPtr ctxt); -char * virXPathStringLimit(const char *xpath, - size_t maxlen, - xmlXPathContextPtr ctxt); -int virXPathNumber(const char *xpath, - xmlXPathContextPtr ctxt, - double *value); -int virXPathInt(const char *xpath, - xmlXPathContextPtr ctxt, - int *value); -int virXPathUInt(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value); -int virXPathLong(const char *xpath, - xmlXPathContextPtr ctxt, - long *value); -int virXPathULong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value); -int virXPathULongLong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long long *value); -int virXPathLongLong(const char *xpath, - xmlXPathContextPtr ctxt, - long long *value); -int virXPathLongHex(const char *xpath, - xmlXPathContextPtr ctxt, - long *value); -int virXPathULongHex(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value); -xmlNodePtr virXPathNode(const char *xpath, - xmlXPathContextPtr ctxt); -int virXPathNodeSet(const char *xpath, - xmlXPathContextPtr ctxt, - xmlNodePtr **list); -char * virXMLPropString(xmlNodePtr node, - const char *name); -char * virXMLPropStringLimit(xmlNodePtr node, - const char *name, - size_t maxlen); -char * virXMLNodeContentString(xmlNodePtr node); +int +virXPathBoolean(const char *xpath, + xmlXPathContextPtr ctxt); +char * +virXPathString(const char *xpath, + xmlXPathContextPtr ctxt); +char * +virXPathStringLimit(const char *xpath, + size_t maxlen, + xmlXPathContextPtr ctxt); +int +virXPathNumber(const char *xpath, + xmlXPathContextPtr ctxt, + double *value); +int +virXPathInt(const char *xpath, + xmlXPathContextPtr ctxt, + int *value); +int +virXPathUInt(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int *value); +int +virXPathLong(const char *xpath, + xmlXPathContextPtr ctxt, + long *value); +int +virXPathULong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long *value); +int +virXPathULongLong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long long *value); +int +virXPathLongLong(const char *xpath, + xmlXPathContextPtr ctxt, + long long *value); +int +virXPathLongHex(const char *xpath, + xmlXPathContextPtr ctxt, + long *value); +int +virXPathULongHex(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long *value); +xmlNodePtr +virXPathNode(const char *xpath, + xmlXPathContextPtr ctxt); +int +virXPathNodeSet(const char *xpath, + xmlXPathContextPtr ctxt, + xmlNodePtr **list); +char * +virXMLPropString(xmlNodePtr node, + const char *name); +char * +virXMLPropStringLimit(xmlNodePtr node, + const char *name, + size_t maxlen); +char * +virXMLNodeContentString(xmlNodePtr node); /* Internal function; prefer the macros below. */ -xmlDocPtr virXMLParseHelper(int domcode, - const char *filename, - const char *xmlStr, - const char *url, - xmlXPathContextPtr *pctxt); - -const char *virXMLPickShellSafeComment(const char *str1, const char *str2); +xmlDocPtr +virXMLParseHelper(int domcode, + const char *filename, + const char *xmlStr, + const char *url, + xmlXPathContextPtr *pctxt); + +const char * +virXMLPickShellSafeComment(const char *str1, + const char *str2); /** * virXMLParse: * @filename: file to parse, or NULL for string parsing @@ -164,32 +184,41 @@ const char *virXMLPickShellSafeComment(const char *st= r1, const char *str2); #define virXMLParseFileCtxt(filename, pctxt) \ virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, pctxt) -int virXMLSaveFile(const char *path, - const char *warnName, - const char *warnCommand, - const char *xml); - -char *virXMLNodeToString(xmlDocPtr doc, xmlNodePtr node); +int +virXMLSaveFile(const char *path, + const char *warnName, + const char *warnCommand, + const char *xml); -bool virXMLNodeNameEqual(xmlNodePtr node, - const char *name); +char * +virXMLNodeToString(xmlDocPtr doc, + xmlNodePtr node); -xmlNodePtr virXMLFindChildNodeByNs(xmlNodePtr root, - const char *uri); +bool +virXMLNodeNameEqual(xmlNodePtr node, + const char *name); -int virXMLExtractNamespaceXML(xmlNodePtr root, - const char *uri, - char **doc); +xmlNodePtr +virXMLFindChildNodeByNs(xmlNodePtr root, + const char *uri); -int virXMLInjectNamespace(xmlNodePtr node, +int +virXMLExtractNamespaceXML(xmlNodePtr root, const char *uri, - const char *key); + char **doc); -void virXMLNodeSanitizeNamespaces(xmlNodePtr node); +int +virXMLInjectNamespace(xmlNodePtr node, + const char *uri, + const char *key); -int virXMLCheckIllegalChars(const char *nodeName, - const char *str, - const char *illegal); +void +virXMLNodeSanitizeNamespaces(xmlNodePtr node); + +int +virXMLCheckIllegalChars(const char *nodeName, + const char *str, + const char *illegal); struct _virXMLValidator { xmlRelaxNGParserCtxtPtr rngParser; @@ -255,9 +284,11 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPat= hFreeContext); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlBuffer, xmlBufferFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlNode, xmlFreeNode); -typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr ctxt, void **nsdata= ); +typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr ctxt, + void **nsdata); typedef void (*virXMLNamespaceFree)(void *nsdata); -typedef int (*virXMLNamespaceFormat)(virBuffer *buf, void *nsdata); +typedef int (*virXMLNamespaceFormat)(virBuffer *buf, + void *nsdata); typedef const char *(*virXMLNamespaceHref)(void); struct _virXMLNamespace { @@ -276,13 +307,14 @@ int virXMLNamespaceRegister(xmlXPathContextPtr ctxt, virXMLNamespace const *ns); -int virParseScaledValue(const char *xpath, - const char *units_xpath, - xmlXPathContextPtr ctxt, - unsigned long long *val, - unsigned long long scale, - unsigned long long max, - bool required); +int +virParseScaledValue(const char *xpath, + const char *units_xpath, + xmlXPathContextPtr ctxt, + unsigned long long *val, + unsigned long long scale, + unsigned long long max, + bool required); xmlBufferPtr virXMLBufferCreate(void); --=20 2.30.2 From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618560455; cv=none; d=zohomail.com; s=zohoarc; b=JwzwoNcsUZc1F3MOSHQhLfEiha9drdXyICIBJcUbQrupcPhpb0s2bB0sXCA2twwOCkKo9ie1Dktv6MC02lSBUYAI3Bhm0lIi8XOLR0e99oQzhzQ95LnX+Ea5nYsZAg1Km4vOjWQ+9xkxtJuKnFO1Hp3jQ4KBUumlmWLVlDCiRb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560455; 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=IXUzGrvbbC8N++un7dFEOfIKreuuAPqxQeutuSTo7L0=; b=PluOYwKBptB2cy46ZHKK1ufBEEa+jGB90NsvnQAR21FszH+nZT/s/uwcSyM78XkgjGiWjow3n9SX5fbhLeZyhfzX+CkacSBU1pQQ7rmgVfTjlmiJzQ8gH+6Wf+GDQWHaA0llnvMv1M4t7F6OaYG4aJeqKU0dg/ccKMSsHCiifr8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618560455673893.6159762900742; Fri, 16 Apr 2021 01:07:35 -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-295-Orf0N9RKOOiIlSdhmDlNhw-1; Fri, 16 Apr 2021 04:07:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D336195D568; Fri, 16 Apr 2021 08:07:26 +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 4589810429A1; Fri, 16 Apr 2021 08:07:26 +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 CAE721806D16; Fri, 16 Apr 2021 08:07:25 +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 13G87FsL026073 for ; Fri, 16 Apr 2021 04:07:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2EA66A046; Fri, 16 Apr 2021 08:07:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5655D6E505 for ; Fri, 16 Apr 2021 08:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560454; 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=IXUzGrvbbC8N++un7dFEOfIKreuuAPqxQeutuSTo7L0=; b=Qd5AJR4pITz1jKOpSrcFsVZb4AmFykUjB4RqnYMFqqAPvDy3z6pM+UUMMMgh40ISf0YJtB CY5tkyVq3upmmPntHy06VvOj0zc+22XBGgkqhB8MZ9z3zBaciZisGCmaWiy7ygqoCOWEtv sduHm67BERIsZQjPrHesMTrdKqHyMns= X-MC-Unique: Orf0N9RKOOiIlSdhmDlNhw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/5] virXMLParseHelper: Sync argument names between declaration and definition Date: Fri, 16 Apr 2021 10:07:02 +0200 Message-Id: <8a87836d57b635dbc182a079512928b0ac845ec4.1618560390.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.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virxml.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virxml.h b/src/util/virxml.h index 84fa4f4baf..fce1c28e89 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -101,7 +101,7 @@ virXMLParseHelper(int domcode, const char *filename, const char *xmlStr, const char *url, - xmlXPathContextPtr *pctxt); + xmlXPathContextPtr *ctxt); const char * virXMLPickShellSafeComment(const char *str1, --=20 2.30.2 From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618560486; cv=none; d=zohomail.com; s=zohoarc; b=h/xgWWPQTVoGbe1RMhaJS8pjiIMM0JC5AgDrl7XtolxzJH7svN/K/5YNWjCCAER+4JvWcYEnx7hk8ObjmTdyvN9ftORep5Zf5yc9xCNMVXuBRON2PrYR2STdA2anYhz0j1NHL/hZeDPVPwHgNUq1Amu2GK017MvEJxkjHJaEqiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560486; 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=lkN9pZK45B0uz76pv0d3Md3YFhac+NZXojuZK6x96fU=; b=b2VR2tqh2R6kN1fgXjg01BaDyi8AoyxOekPbC66TG9EkcsJuQ/GZQ5HjeKb/tU5cutZhfcs+ksPWaUoCW79ggBsSToOdvDLkF3nQ4X9LroQPpv3gbUmQKwCzV66i3bwmJkqmNODGfLoGrejjGmc1tTAqe5wHgDd9au5grY+bDYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618560486427313.89681656424807; Fri, 16 Apr 2021 01:08:06 -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-324-llxCWwEMNtKC1rRGdIB36w-1; Fri, 16 Apr 2021 04:07:50 -0400 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 58783107ACCD; Fri, 16 Apr 2021 08:07:43 +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 360C56F99C; Fri, 16 Apr 2021 08:07:43 +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 F322344A64; Fri, 16 Apr 2021 08:07:42 +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 13G87G71026083 for ; Fri, 16 Apr 2021 04:07:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F1AA6A04C; Fri, 16 Apr 2021 08:07:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BAAF6A046 for ; Fri, 16 Apr 2021 08:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560485; 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=lkN9pZK45B0uz76pv0d3Md3YFhac+NZXojuZK6x96fU=; b=CQYGgz9T20s31diMNkEBThP65nXUoNFgpNP4A4qEBsn22qkok6Z3YwPCJ2taMgJsHarh2v EwtWfNaJ4PAyzaUQXFnbJ2JtO4UghLbk/6AKwPLOmf3T96VFaHKGLOiik96IRBjNiuEQZx IaA3Uaf4DJnyIi03NHu2HN867HCvmic= X-MC-Unique: llxCWwEMNtKC1rRGdIB36w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/5] util: xml: Register autoptr cleanup function for 'xmlParserCtxt' Date: Fri, 16 Apr 2021 10:07:03 +0200 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.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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virxml.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virxml.h b/src/util/virxml.h index fce1c28e89..b1feeeb164 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -283,6 +283,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlBuffer, xmlBufferFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlNode, xmlFreeNode); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlParserCtxt, xmlFreeParserCtxt); typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr ctxt, void **nsdata); --=20 2.30.2 From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618560495; cv=none; d=zohomail.com; s=zohoarc; b=gdI6Nbvj55AgpIWrgIv50NW9/bAOcNnn4he/oUL+22q4P+lduH3oDXfRpYP238x68y7OtxSAerOPCnJUmMTcpWP6ypNWdxaPBHg2TwbrRkd76Hb16a8OW+YGtR8FxwgVp32jIdOptSJPbcB2VthJ7jHDMfTn7eAt1ie/ygwjw2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560495; 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=DMtVMKkrnnwY82QrZ4jLRlWFyJLTiV7lQglvHWzRTDo=; b=k+T5icCENrHaH9tHYyWuecoZXW/s+YjLrQdCUCQTPAOICZMMSrTIYDeyXyB88K2kVoZubTd2xAktNkZynYUU7HZolXvxUEb7QJNMngMbG0TIvRQ/1RCs6Jn8vxksHvhRFX7UsnVscQXLqYOmtR4isvLezKK875uo767GghWr5HU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618560495506943.5369127925486; Fri, 16 Apr 2021 01:08:15 -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-452-GEnb4CLqOGiVc2-EBNb8Iw-1; Fri, 16 Apr 2021 04:07:35 -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 BD11D50203; Fri, 16 Apr 2021 08:07:30 +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 95DFE5D9E3; Fri, 16 Apr 2021 08:07:30 +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 5A35A1806D19; Fri, 16 Apr 2021 08:07:30 +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 13G87H4i026101 for ; Fri, 16 Apr 2021 04:07:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 28D1A6E505; Fri, 16 Apr 2021 08:07:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B5E56A04C for ; Fri, 16 Apr 2021 08:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560494; 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=DMtVMKkrnnwY82QrZ4jLRlWFyJLTiV7lQglvHWzRTDo=; b=FZuIcBpY3HAezH+4j1tmMy/D/Pfp+FQNbwl1Ho0p8ue26gWu5lpvp4sAl9lANnZnXpiNWS I9wzjUZNt9WQGFE/4SNf+/pdhO/yT5g92EeTf7k568nz9w4GMpqpcX3ERCO0kqSJY5nki+ cjBZrOVtHdVlEXcFcaJ7VG7nJPNn6MM= X-MC-Unique: GEnb4CLqOGiVc2-EBNb8Iw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] virXMLParseHelper: Rework error reporting Date: Fri, 16 Apr 2021 10:07:04 +0200 Message-Id: <6f720c0f68113df4f2a810bdc7325a7a4f5ac239.1618560390.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) Content-Type: text/plain; charset="utf-8" Move the reporting of parsing error on the error path of the parser as other code paths report their own errors already. Additionally prefer printing the 'url' as document name if provided instead of "[inline data]" as that usually gives a better hint at least which kind of XML is being parsed. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virxml.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 117f50f2bf..029b3d646e 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -788,6 +788,14 @@ virXMLParseHelper(int domcode, struct virParserData private; xmlParserCtxtPtr pctxt; xmlDocPtr xml =3D NULL; + const char *docname; + + if (filename) + docname =3D filename; + else if (url) + docname =3D url; + else + docname =3D "[inline data]"; /* Set up a parser context so we can catch the details of XML errors. = */ pctxt =3D xmlNewParserCtxt(); @@ -807,8 +815,16 @@ virXMLParseHelper(int domcode, XML_PARSE_NONET | XML_PARSE_NOWARNING); } - if (!xml) + + if (!xml) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { + virGenericReportError(domcode, VIR_ERR_XML_ERROR, + _("failed to parse xml document '%s'"), + docname); + } + goto error; + } if (xmlDocGetRootElement(xml) =3D=3D NULL) { virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, @@ -832,11 +848,6 @@ virXMLParseHelper(int domcode, xmlFreeDoc(xml); xml =3D NULL; - if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { - virGenericReportError(domcode, VIR_ERR_XML_ERROR, - _("failed to parse xml document '%s'"), - filename ? filename : "[inline data]"); - } goto cleanup; } --=20 2.30.2 From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618560476; cv=none; d=zohomail.com; s=zohoarc; b=Oje8Qv++oGRw8eiQ7eguRSlpfpPb7jgqRpSWQ5EgjGOmCwQmQCLlfCzD1Ht3cPBxLxUHiLz/qQiOcrDHWp7z3z5DSXrgX+xWYD3BTSQrzGLHrF5VbJB1auqVqQz2ezh+b5Wj89GwOuUamB9t2rYisVhnGdppBFAXV1qHPmKLtHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618560476; 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=pb/dHtkeJzwraxCzigP2aFUu54Pt0OgPfKWHUz+K2GM=; b=K7s2RnrfNrwGNyBO1bWeWqKyDK4Hl0cVcd/g8tn9I3xGDA3Wmk2HUDxe8z2oxbzlFiKiyYiXqUBXIrUDLQt8kJI3XN8l10aqjk8C62r2WBwtYECBm+M2E5yfOe6Wb8gXEBtI4EStTswbNkXvPCW2B/EWgBLMUB0sXg6UGAG89W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618560476944444.3212613622836; Fri, 16 Apr 2021 01:07:56 -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-550-drDm-SVoO2eGNJ2JVRQW7Q-1; Fri, 16 Apr 2021 04:07:52 -0400 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 5F8EB81747A; Fri, 16 Apr 2021 08:07:46 +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 0FE10610AF; Fri, 16 Apr 2021 08:07:46 +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 CC0881806D19; Fri, 16 Apr 2021 08:07:45 +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 13G87JkN026111 for ; Fri, 16 Apr 2021 04:07:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 529D56A046; Fri, 16 Apr 2021 08:07:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92F3F6A04C for ; Fri, 16 Apr 2021 08:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618560474; 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=pb/dHtkeJzwraxCzigP2aFUu54Pt0OgPfKWHUz+K2GM=; b=R+wF4ZCPXq0Ke6EcHgsvb3JXcEIvN4EP4CkaxbD+mTof7/oA/mA+x5uM84YmrJvGoyy0YI FCtVljiiVwhZdWl6lOVB1H5QP7CCZXYzsgxqqQpksjDVmwkDBPamW8sqU3kY2eJ7dgQYjG /V4NjNpML2Z7n8JZpxD+5YkN5uUaeOU= X-MC-Unique: drDm-SVoO2eGNJ2JVRQW7Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] virXMLParseHelper: Refactor cleanup Date: Fri, 16 Apr 2021 10:07:05 +0200 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) Content-Type: text/plain; charset="utf-8" Switch @xml and @pctxt to g_autofree and get rid of the "error" and "cleanup" labels. Signed-off-by: Peter Krempa Reviewed-by: Tim Wiederhake --- src/util/virxml.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 029b3d646e..58d640546f 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -786,8 +786,8 @@ virXMLParseHelper(int domcode, xmlXPathContextPtr *ctxt) { struct virParserData private; - xmlParserCtxtPtr pctxt; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlParserCtxt) pctxt =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; const char *docname; if (filename) @@ -823,32 +823,24 @@ virXMLParseHelper(int domcode, docname); } - goto error; + return NULL; } if (xmlDocGetRootElement(xml) =3D=3D NULL) { virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, "%s", _("missing root element")); - goto error; + + return NULL; } if (ctxt) { if (!(*ctxt =3D virXMLXPathContextNew(xml))) - goto error; + return NULL; (*ctxt)->node =3D xmlDocGetRootElement(xml); } - cleanup: - xmlFreeParserCtxt(pctxt); - - return xml; - - error: - xmlFreeDoc(xml); - xml =3D NULL; - - goto cleanup; + return g_steal_pointer(&xml); } const char *virXMLPickShellSafeComment(const char *str1, const char *str2) --=20 2.30.2