From d957c9f667e89bf4c3220a66b6befaa7f4f1df1a Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Wed, 1 Feb 2017 23:41:09 +0100 Subject: [PATCH] compiler-warnings: use size_t as explicit type for comparisons with size_t --- src/json-validator.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 24e721c..e903e89 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -134,13 +134,12 @@ void validate_type(const json &schema, const std::string &expected_type, const s // any of the types in this array if (type_instance.type() == json::value_t::array) { if ((std::find(type_instance.begin(), - type_instance.end(), - expected_type) != type_instance.end()) - || - (expected_type == "integer" && - std::find(type_instance.begin(), - type_instance.end(), - "number") != type_instance.end())) + type_instance.end(), + expected_type) != type_instance.end()) || + (expected_type == "integer" && + std::find(type_instance.begin(), + type_instance.end(), + "number") != type_instance.end())) return; std::ostringstream s; @@ -445,13 +444,13 @@ void json_validator::validate_array(const json &instance, const json &schema, co // maxItems const auto &maxItems = schema.find("maxItems"); if (maxItems != schema.end()) - if (instance.size() > maxItems.value().get()) + if (instance.size() > maxItems.value().get()) throw std::out_of_range(name + " has too many items."); // minItems const auto &minItems = schema.find("minItems"); if (minItems != schema.end()) - if (instance.size() < minItems.value().get()) + if (instance.size() < minItems.value().get()) throw std::out_of_range(name + " has too many items."); // uniqueItems @@ -554,13 +553,13 @@ void json_validator::validate_object(const json &instance, const json &schema, c // maxProperties const auto &maxProperties = schema.find("maxProperties"); if (maxProperties != schema.end()) - if (instance.size() > maxProperties.value().get()) + if (instance.size() > maxProperties.value().get()) throw std::out_of_range(name + " has too many properties."); // minProperties const auto &minProperties = schema.find("minProperties"); if (minProperties != schema.end()) - if (instance.size() < minProperties.value().get()) + if (instance.size() < minProperties.value().get()) throw std::out_of_range(name + " has too few properties."); // additionalProperties @@ -681,7 +680,7 @@ void json_validator::validate_string(const json &instance, const json &schema, c // minLength auto attr = schema.find("minLength"); if (attr != schema.end()) - if (utf8_length( instance ) < attr.value().get()) { + if (utf8_length(instance) < attr.value().get()) { std::ostringstream s; s << "'" << name << "' of value '" << instance << "' is too short as per minLength (" << attr.value() << ")"; @@ -691,7 +690,7 @@ void json_validator::validate_string(const json &instance, const json &schema, c // maxLength attr = schema.find("maxLength"); if (attr != schema.end()) - if (utf8_length(instance) > attr.value().get()) { + if (utf8_length(instance) > attr.value().get()) { std::ostringstream s; s << "'" << name << "' of value '" << instance << "' is too long as per maxLength (" << attr.value() << ")";