Merge pull request #1001 from libexpat/clang-tidy-misc-no-recursion
Some checks failed
Run Linux CI tasks / Perform checks (push) Has been cancelled
Run macOS CI tasks / Perform checks (push) Has been cancelled
Enforce Clang Static Analyzer (scan-build) clean code / Enforce Clang Static Analyzer (scan-build) clean code (push) Has been cancelled
Enforce clang-tidy clean code / Enforce clang-tidy clean code (push) Has been cancelled
Build Windows binaries / Build win32 binaries (push) Has been cancelled
Collect test coverage / Collect test coverage (push) Has been cancelled
Upload build to Coverity Scan / Upload build to Coverity Scan (push) Has been cancelled
Build Windows binaries / Build win64 binaries (push) Has been cancelled
Run Cppcheck (from macOS Homebrew) / Run Cppcheck (push) Has been cancelled
Build with Emscripten / Build with Emscripten (push) Has been cancelled
Build on Windows / Build on Windows (windows-2019, Win32, char) (push) Has been cancelled
Build on Windows / Build on Windows (windows-2022, x64, wchar_t) (push) Has been cancelled
Ensure that GNU Autotools and CMake build systems agree / Ensure that GNU Autotools and CMake build systems agree (push) Has been cancelled
Enforce clang-format clean code / Enforce clang-format clean code (push) Has been cancelled
Check expat_config.h.{in,cmake} for regressions / Check expat_config.h.{in,cmake} for regressions (push) Has been cancelled
Run fuzzing regression tests / Run fuzzing regression tests (push) Has been cancelled
Build with musl / Build with musl (push) Has been cancelled
Run Perl XML::Parser integration tests / Run Perl XML::Parser integration tests (push) Has been cancelled
Ensure well-formed and valid XML / Ensure well-formed and valid XML (push) Has been cancelled
Ensure realistic minimum CMake version requirement / Ensure realistic minimum CMake version requirement (push) Has been cancelled
Enforce codespell-clean spelling / Enforce codespell-clean spelling (push) Has been cancelled

Address clang-tidy warning `misc-no-recursion`
This commit is contained in:
Sebastian Pipping 2025-03-31 01:03:21 +02:00 committed by GitHub
commit 69d6c054c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

View file

@ -41,7 +41,7 @@ Release 2.7.2 ??? ????? ?? ????
Other changes:
#994 docs: Drop AppVeyor badge
#1000 tests: Fix portable_strndup
#999 Address more clang-tidy warnings
#999 #1001 Address more clang-tidy warnings
Special thanks to:
Alexander Bluhm

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

@ -627,10 +627,10 @@ static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity,
int sourceLine);
static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
int sourceLine);
#endif /* XML_GE == 1 */
static XML_Parser getRootParserOf(XML_Parser parser,
unsigned int *outLevelDiff);
#endif /* XML_GE == 1 */
static unsigned long getDebugLevel(const char *variableName,
unsigned long defaultDebugLevel);
@ -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;
}
@ -8288,6 +8291,8 @@ entityTrackingOnClose(XML_Parser originParser, ENTITY *entity, int sourceLine) {
rootParser->m_entity_stats.currentDepth--;
}
#endif /* XML_GE == 1 */
static XML_Parser
getRootParserOf(XML_Parser parser, unsigned int *outLevelDiff) {
XML_Parser rootParser = parser;
@ -8303,6 +8308,8 @@ getRootParserOf(XML_Parser parser, unsigned int *outLevelDiff) {
return rootParser;
}
#if XML_GE == 1
const char *
unsignedCharToPrintable(unsigned char c) {
switch (c) {