Skip to content

* PVS Studio fix #1217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,9 +1174,7 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const {
const bool emitUTF8 = settings_["emitUTF8"].asBool();
unsigned int pre = settings_["precision"].asUInt();
CommentStyle::Enum cs = CommentStyle::All;
if (cs_str == "All") {
cs = CommentStyle::All;
} else if (cs_str == "None") {
if (cs_str == "None") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. Am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CommentStyle::Enum cs = CommentStyle::All;

cs = CommentStyle::None;
} else {
throwRuntimeError("commentStyle must be 'All' or 'None'");
Expand Down
6 changes: 3 additions & 3 deletions src/test_lib_json/jsontest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void Runner::runTestAt(size_t index, TestResult& result) const {

bool Runner::runAllTest(bool printSummary) const {
size_t const count = testCount();
std::deque<TestResult> failures;
std::vector<TestResult> failures;
for (size_t index = 0; index < count; ++index) {
TestResult result;
runTestAt(index, result);
Expand Down Expand Up @@ -408,10 +408,10 @@ Json::String ToJsonString(const char* toConvert) {
return Json::String(toConvert);
}

Json::String ToJsonString(Json::String in) { return in; }
Json::String ToJsonString(const Json::String& in) { return in; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to modify the header:

  jsoncpp_static.vcxproj -> C:\projects\jsoncpp\lib\Release\jsoncpp_static.lib
main.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl JsonTest::ToJsonString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ToJsonString@JsonTest@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z) referenced in function "public: virtual void __thiscall TestCharReaderAllowSingleQuotesTestissue182::runTestCase(void)" (?runTestCase@TestCharReaderAllowSingleQuotesTestissue182@@UAEXXZ) [C:\projects\jsoncpp\src\test_lib_json\jsoncpp_test.vcxproj]


#if JSONCPP_USING_SECURE_MEMORY
Json::String ToJsonString(std::string in) {
Json::String ToJsonString(const std::string& in) {
return Json::String(in.data(), in.data() + in.length());
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/test_lib_json/jsontest.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ TestResult& checkEqual(TestResult& result, T expected, U actual,
}

Json::String ToJsonString(const char* toConvert);
Json::String ToJsonString(Json::String in);
Json::String ToJsonString(const Json::String& in);
#if JSONCPP_USING_SECURE_MEMORY
Json::String ToJsonString(std::string in);
Json::String ToJsonString(const std::string& in);
#endif

TestResult& checkStringEqual(TestResult& result, const Json::String& expected,
Expand Down
Loading