lib/xmlparse.c: Address clang-tidy warning misc-no-recursion

This commit is contained in:
Sebastian Pipping 2025-03-30 19:26:55 +02:00
parent 004e55a7e1
commit fe04a7f0ff
2 changed files with 11 additions and 7 deletions

View file

@ -35,6 +35,7 @@ cd "$(dirname "$(type -P "$0")")"
checks_to_enable=(
bugprone-narrowing-conversions
bugprone-suspicious-string-compare
misc-no-recursion
readability-avoid-const-params-in-decls
readability-named-parameter
)

View file

@ -1015,9 +1015,10 @@ generate_hash_secret_salt(XML_Parser parser) {
static unsigned long
get_hash_secret_salt(XML_Parser parser) {
if (parser->m_parentParser != NULL)
return get_hash_secret_salt(parser->m_parentParser);
return parser->m_hash_secret_salt;
const XML_Parser rootParser = getRootParserOf(parser, NULL);
assert(! rootParser->m_parentParser);
return rootParser->m_hash_secret_salt;
}
static enum XML_Error
@ -2017,12 +2018,14 @@ int XMLCALL
XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) {
if (parser == NULL)
return 0;
if (parser->m_parentParser)
return XML_SetHashSalt(parser->m_parentParser, hash_salt);
const XML_Parser rootParser = getRootParserOf(parser, NULL);
assert(! rootParser->m_parentParser);
/* block after XML_Parse()/XML_ParseBuffer() has been called */
if (parserBusy(parser))
if (parserBusy(rootParser))
return 0;
parser->m_hash_secret_salt = hash_salt;
rootParser->m_hash_secret_salt = hash_salt;
return 1;
}