From b8db20e5f66ba6c5301bb7f9415b01b49ba39923 Mon Sep 17 00:00:00 2001 From: "shamprasad.ps" Date: Fri, 22 Dec 2017 09:39:10 -0700 Subject: [PATCH 1/3] Handle all enum cases in switch --- src/json.hpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index 1f7e8dca2..9634cf502 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3251,6 +3251,20 @@ class parser break; // LCOV_EXCL_LINE } + case token_type::uninitialized: + + case token_type::end_array: + + case token_type::end_object: + + case token_type::name_separator: + + case token_type::value_separator: + + case token_type::end_of_input: + + case token_type::literal_or_value: + default: { // the last token was unexpected; we expected a value @@ -6564,7 +6578,7 @@ class serializer // check that the additional bytes are present assert(i + bytes < s.size()); - // to use \uxxxx escaping, we first need to calculate + // to use \uxxxx escaping, we first need to caluclate // the codepoint from the UTF-8 bytes int codepoint = 0; @@ -8114,6 +8128,8 @@ class basic_json break; } + case value_t::discarded: + default: { object = nullptr; // silence warning, see #821 @@ -8190,6 +8206,18 @@ class basic_json break; } + case value_t::null: + + case value_t::boolean: + + case value_t::number_integer: + + case value_t::number_unsigned: + + case value_t::number_float: + + case value_t::discarded: + default: { break; From a9e1cbb9a574276dca487ccfcf7047adda5db56e Mon Sep 17 00:00:00 2001 From: "shamprasad.ps" Date: Fri, 22 Dec 2017 10:23:39 -0700 Subject: [PATCH 2/3] Changing to typo introduced --- src/json.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index 9634cf502..cae1cecce 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6578,7 +6578,7 @@ class serializer // check that the additional bytes are present assert(i + bytes < s.size()); - // to use \uxxxx escaping, we first need to caluclate + // to use \uxxxx escaping, we first need to calculate // the codepoint from the UTF-8 bytes int codepoint = 0; From faa24a8f592a88e5e536abbe584f7d9310996e03 Mon Sep 17 00:00:00 2001 From: "shamprasad.ps" Date: Fri, 22 Dec 2017 12:03:59 -0700 Subject: [PATCH 3/3] adding a default case for switch --- src/json.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/json.hpp b/src/json.hpp index cae1cecce..c9104f1cf 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6313,6 +6313,11 @@ class serializer o->write_characters("null", 4); return; } + + default: + { + return; + } } }