From 94dab5c6281fdf42718e937b3c6d447e8e3e4541 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 17 Sep 2024 10:56:52 +0200 Subject: [PATCH] qxmlstreamparser_p.h: fix -Wshadow in parse() The name `prefix` is also used for a data member, and the very next rule actually assigns to it, so using the same name in this huge switch is actually impairing readability. Fix by abbreviating the local variable. This code predates the start of the public history. Pick-to: 6.7 6.5 6.2 5.15 Task-number: QTBUG-126219 Change-Id: Iece828a9303b5449397ac93e51f540bf890f7d08 Reviewed-by: Ahmad Samir Reviewed-by: Edward Welbourne Reviewed-by: Matthias Rauter Reviewed-by: Lena Biliaieva (cherry picked from commit 2fda30053dcf13356d72f9a8116413d26bcb14a1) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/serialization/qxmlstream.g | 6 +++--- src/corelib/serialization/qxmlstreamparser_p.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g index 994136c4b17..d1e3e182e26 100644 --- a/src/corelib/serialization/qxmlstream.g +++ b/src/corelib/serialization/qxmlstream.g @@ -1115,8 +1115,8 @@ attribute_value_content ::= literal_content | char_ref | entity_ref_in_attribute attribute ::= qname space_opt EQ space_opt attribute_value; /. case $rule_number: { - XmlStringRef prefix = symPrefix(1); - if (prefix.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) { + const XmlStringRef prfx = symPrefix(1); + if (prfx.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); namespaceDeclaration.prefix.clear(); @@ -1165,7 +1165,7 @@ attribute ::= qname space_opt EQ space_opt attribute_value; attribute.value.pos = pos; attribute.value.len = n; } - if (prefix == "xmlns"_L1 && namespaceProcessing) { + if (prfx == "xmlns"_L1 && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); XmlStringRef namespacePrefix = symString(attribute.key); XmlStringRef namespaceUri = symString(attribute.value); diff --git a/src/corelib/serialization/qxmlstreamparser_p.h b/src/corelib/serialization/qxmlstreamparser_p.h index 44fa3a69b2d..4bdcd77f3e1 100644 --- a/src/corelib/serialization/qxmlstreamparser_p.h +++ b/src/corelib/serialization/qxmlstreamparser_p.h @@ -714,8 +714,8 @@ bool QXmlStreamReaderPrivate::parse() break; case 229: { - XmlStringRef prefix = symPrefix(1); - if (prefix.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) { + const XmlStringRef prfx = symPrefix(1); + if (prfx.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); namespaceDeclaration.prefix.clear(); @@ -764,7 +764,7 @@ bool QXmlStreamReaderPrivate::parse() attribute.value.pos = pos; attribute.value.len = n; } - if (prefix == "xmlns"_L1 && namespaceProcessing) { + if (prfx == "xmlns"_L1 && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); XmlStringRef namespacePrefix = symString(attribute.key); XmlStringRef namespaceUri = symString(attribute.value);