Skip to content

Commit 02cfae6

Browse files
committed
Fix open-source-parsers#296: Explicitly cast size_t results to unsigned when needed
1 parent cd63eb5 commit 02cfae6

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib_json/json_value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ inline static void decodePrefixedString(
125125
unsigned* length, char const** value)
126126
{
127127
if (!isPrefixed) {
128-
*length = strlen(prefixed);
128+
*length = static_cast<unsigned>(strlen(prefixed));
129129
*value = prefixed;
130130
} else {
131131
*length = *reinterpret_cast<unsigned const*>(prefixed);

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void FastWriter::writeValue(const Value& value) {
346346
const std::string& name = *it;
347347
if (it != members.begin())
348348
document_ += ',';
349-
document_ += valueToQuotedStringN(name.data(), name.length());
349+
document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
350350
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
351351
writeValue(value[name]);
352352
}
@@ -906,7 +906,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
906906
std::string const& name = *it;
907907
Value const& childValue = value[name];
908908
writeCommentBeforeValue(childValue);
909-
writeWithIndent(valueToQuotedStringN(name.data(), name.length()));
909+
writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
910910
*sout_ << colonSymbol_;
911911
writeValue(childValue);
912912
if (++it == members.end()) {

0 commit comments

Comments
 (0)