From 590e158cf36b6e6fca07f54837db084fe8a163c6 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 6 Dec 2022 16:30:35 -0500 Subject: SL-18330: Adapt LLSDSerialize and tests to llssize max_bytes params. --- indra/llcommon/llsdserialize.cpp | 2 +- indra/llcommon/tests/llsdserialize_test.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 97bf51eeaa..c1b24d8138 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -128,7 +128,7 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, S32 max_bytes) * specified buffer. In the usual case when max_bytes exceeds * sizeof(hdr_buf), get() will read no more than sizeof(hdr_buf)-2. */ - str.get(hdr_buf, std::min(max_bytes+1, sizeof(hdr_buf)-1), '\n'); + str.get(hdr_buf, llmin(max_bytes+1, sizeof(hdr_buf)-1), '\n'); auto inbuf = str.gcount(); // https://en.cppreference.com/w/cpp/io/basic_istream/get // When the get() above sees the specified delimiter '\n', it stops there diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 6e5d8a26e1..29e3007aff 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -63,7 +63,7 @@ using namespace boost::phoenix; #include typedef std::function FormatterFunction; -typedef std::function ParserFunction; +typedef std::function ParserFunction; std::vector string_to_vector(const std::string& str) { @@ -263,7 +263,7 @@ namespace tut }; // this lambda must be mutable since otherwise the bound 'parser' // is assumed to point to a const LLSDParser - mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes) mutable + mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes) mutable { // reset() call is needed since test code re-uses parser object parser->reset(); @@ -271,10 +271,10 @@ namespace tut }; } - void setParser(bool (*parser)(LLSD&, std::istream&, size_t)) + void setParser(bool (*parser)(LLSD&, std::istream&, llssize)) { // why does LLSDSerialize::deserialize() reverse the parse() params?? - mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes) + mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes) { return (parser(data, istr, max_bytes) > 0); }; @@ -2059,7 +2059,7 @@ namespace tut // helper for test<8> - test<12> void fromPythonUsing(const std::string& pyformatter, const ParserFunction& parse= - [](std::istream& istr, LLSD& data, size_t max_bytes) + [](std::istream& istr, LLSD& data, llssize max_bytes) { return LLSDSerialize::deserialize(data, istr, max_bytes); }) { // Create an empty data file. This is just a placeholder for our @@ -2140,7 +2140,7 @@ namespace tut set_test_name("from Python XML using fromXML()"); // fromXML()'s optional 3rd param isn't max_bytes, it's emit_errors fromPythonUsing("format_xml", - [](std::istream& istr, LLSD& data, size_t) + [](std::istream& istr, LLSD& data, llssize) { return LLSDSerialize::fromXML(data, istr) > 0; }); } @@ -2149,7 +2149,7 @@ namespace tut { set_test_name("from Python notation using fromNotation()"); fromPythonUsing("format_notation", - [](std::istream& istr, LLSD& data, size_t max_bytes) + [](std::istream& istr, LLSD& data, llssize max_bytes) { return LLSDSerialize::fromNotation(data, istr, max_bytes) > 0; }); } @@ -2161,7 +2161,7 @@ namespace tut // We don't expect this to work because format_binary() emits a // header, but fromBinary() won't recognize a header. fromPythonUsing("format_binary", - [](std::istream& istr, LLSD& data, size_t max_bytes) + [](std::istream& istr, LLSD& data, llssize max_bytes) { return LLSDSerialize::fromBinary(data, istr, max_bytes) > 0; }); } |*==========================================================================*/ -- cgit v1.2.3