Skip to content

Commit 85a263e

Browse files
committed
Fix improper format specifier in printf
%d in format string requires 'int' but the argument type is 'unsigned int'.
1 parent cfab607 commit 85a263e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/jsontestrunner/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ static void printValueTree(FILE* fout,
106106
for (Json::ArrayIndex index = 0; index < size; ++index) {
107107
static char buffer[16];
108108
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
109-
sprintf_s(buffer, sizeof(buffer), "[%d]", index);
109+
sprintf_s(buffer, sizeof(buffer), "[%u]", index);
110110
#else
111-
snprintf(buffer, sizeof(buffer), "[%d]", index);
111+
snprintf(buffer, sizeof(buffer), "[%u]", index);
112112
#endif
113113
printValueTree(fout, value[index], path + buffer);
114114
}

src/test_lib_json/jsontest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void TestResult::printFailure(bool printTestName) const {
165165
const Failure& failure = *it;
166166
JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' ');
167167
if (failure.file_) {
168-
printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_);
168+
printf("%s%s(%u): ", indent.c_str(), failure.file_, failure.line_);
169169
}
170170
if (!failure.expr_.empty()) {
171171
printf("%s\n", failure.expr_.c_str());
@@ -281,7 +281,7 @@ bool Runner::runAllTest(bool printSummary) const {
281281

282282
if (failures.empty()) {
283283
if (printSummary) {
284-
printf("All %d tests passed\n", count);
284+
printf("All %u tests passed\n", count);
285285
}
286286
return true;
287287
} else {
@@ -293,7 +293,7 @@ bool Runner::runAllTest(bool printSummary) const {
293293
if (printSummary) {
294294
unsigned int failedCount = static_cast<unsigned int>(failures.size());
295295
unsigned int passedCount = count - failedCount;
296-
printf("%d/%d tests passed (%d failure(s))\n", passedCount, count,
296+
printf("%u/%u tests passed (%u failure(s))\n", passedCount, count,
297297
failedCount);
298298
}
299299
return false;

0 commit comments

Comments
 (0)