debugLevel fields should be unsigned longs, not integers

This is a variation of https://github.com/libexpat/libexpat/pull/714 that makes more sense.
This commit is contained in:
Rose 2023-05-23 16:26:32 -04:00
parent 8e5b9a9310
commit 0685e01da2

View file

@ -415,7 +415,7 @@ typedef unsigned long long XmlBigCount;
typedef struct accounting {
XmlBigCount countBytesDirect;
XmlBigCount countBytesIndirect;
int debugLevel;
unsigned long debugLevel;
float maximumAmplificationFactor; // >=1.0
unsigned long long activationThresholdBytes;
} ACCOUNTING;
@ -424,7 +424,7 @@ typedef struct entity_stats {
unsigned int countEverOpened;
unsigned int currentDepth;
unsigned int maximumDepthSeen;
int debugLevel;
unsigned long debugLevel;
} ENTITY_STATS;
#endif /* XML_DTD */
@ -7674,7 +7674,7 @@ accountingReportStats(XML_Parser originParser, const char *epilog) {
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
assert(! rootParser->m_parentParser);
if (rootParser->m_accounting.debugLevel < 1) {
if (rootParser->m_accounting.debugLevel == 0u) {
return;
}
@ -7711,7 +7711,7 @@ accountingReportDiff(XML_Parser rootParser,
/* Note: Performance is of no concern here */
const char *walker = before;
if ((rootParser->m_accounting.debugLevel >= 3)
if ((rootParser->m_accounting.debugLevel >= 3u)
|| (after - before)
<= (ptrdiff_t)(contextLength + ellipsisLength + contextLength)) {
for (; walker < after; walker++) {
@ -7776,7 +7776,7 @@ accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
|| (amplificationFactor
<= rootParser->m_accounting.maximumAmplificationFactor);
if (rootParser->m_accounting.debugLevel >= 2) {
if (rootParser->m_accounting.debugLevel >= 2u) {
accountingReportStats(rootParser, "");
accountingReportDiff(rootParser, levelsAwayFromRootParser, before, after,
bytesMore, source_line, account);
@ -7803,7 +7803,7 @@ static void
entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
const char *action, int sourceLine) {
assert(! rootParser->m_parentParser);
if (rootParser->m_entity_stats.debugLevel < 1)
if (rootParser->m_entity_stats.debugLevel == 0u)
return;
# if defined(XML_UNICODE)