Skip to content

Commit c449ba6

Browse files
committed
change int into size_t for memsize-type loop counter (PVS)
1 parent d452d19 commit c449ba6

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

include/json/reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ class JSONCPP_DEPRECATED(
217217
void skipUntilSpace();
218218
Value& currentValue();
219219
Char getNextChar();
220-
void getLocationLineAndColumn(Location location, int& line,
221-
int& column) const;
220+
void getLocationLineAndColumn(Location location, size_t& line,
221+
size_t& column) const;
222222
String getLocationLineAndColumn(Location location) const;
223223
void addComment(Location begin, Location end, CommentPlacement placement);
224224
void skipCommentTokens(Token& token);

src/lib_json/json_reader.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,8 @@ Reader::Char Reader::getNextChar() {
761761
return *current_++;
762762
}
763763

764-
void Reader::getLocationLineAndColumn(Location location, int& line,
765-
int& column) const {
764+
void Reader::getLocationLineAndColumn(Location location, size_t& line,
765+
size_t& column) const {
766766
Location current = begin_;
767767
Location lastLineStart = current;
768768
line = 0;
@@ -784,10 +784,11 @@ void Reader::getLocationLineAndColumn(Location location, int& line,
784784
}
785785

786786
String Reader::getLocationLineAndColumn(Location location) const {
787-
int line, column;
787+
size_t line, column;
788788
getLocationLineAndColumn(location, line, column);
789789
char buffer[18 + 16 + 16 + 1];
790-
jsoncpp_snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
790+
jsoncpp_snprintf(buffer, sizeof(buffer), "Line %zu, Column %zu", line,
791+
column);
791792
return buffer;
792793
}
793794

@@ -965,8 +966,8 @@ class OurReader {
965966
void skipUntilSpace();
966967
Value& currentValue();
967968
Char getNextChar();
968-
void getLocationLineAndColumn(Location location, int& line,
969-
int& column) const;
969+
void getLocationLineAndColumn(Location location, size_t& line,
970+
size_t& column) const;
970971
String getLocationLineAndColumn(Location location) const;
971972
void addComment(Location begin, Location end, CommentPlacement placement);
972973
void skipCommentTokens(Token& token);
@@ -1783,8 +1784,8 @@ OurReader::Char OurReader::getNextChar() {
17831784
return *current_++;
17841785
}
17851786

1786-
void OurReader::getLocationLineAndColumn(Location location, int& line,
1787-
int& column) const {
1787+
void OurReader::getLocationLineAndColumn(Location location, size_t& line,
1788+
size_t& column) const {
17881789
Location current = begin_;
17891790
Location lastLineStart = current;
17901791
line = 0;
@@ -1806,10 +1807,11 @@ void OurReader::getLocationLineAndColumn(Location location, int& line,
18061807
}
18071808

18081809
String OurReader::getLocationLineAndColumn(Location location) const {
1809-
int line, column;
1810+
size_t line, column;
18101811
getLocationLineAndColumn(location, line, column);
18111812
char buffer[18 + 16 + 16 + 1];
1812-
jsoncpp_snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
1813+
jsoncpp_snprintf(buffer, sizeof(buffer), "Line %zu, Column %zu", line,
1814+
column);
18131815
return buffer;
18141816
}
18151817

0 commit comments

Comments
 (0)