Fix high certainty warnings from PVS-studio (#5115)

* Fix high certainty warnings from PVS-studio

- Introduced FLATBUFFERS_ATTRIBUTE macro to use [[attribute]] if modern C++ compiler used

* Update the note about __cplusplus usage in the MSVC
This commit is contained in:
Vladimir Glavnyy
2019-01-18 00:49:27 +07:00
committed by Wouter van Oortmerssen
parent bbfd12eb11
commit d44931656a
8 changed files with 49 additions and 25 deletions

View File

@@ -411,8 +411,10 @@ CheckedError Parser::Next() {
}
cursor_ += 2;
break;
} else {
// fall thru
}
// fall thru
FLATBUFFERS_ATTRIBUTE(fallthrough);
default:
const auto has_sign = (c == '+') || (c == '-');
// '-'/'+' and following identifier - can be a predefined constant like:
@@ -2752,7 +2754,7 @@ bool StructDef::Deserialize(Parser &parser, const reflection::Object *object) {
minalign = object->minalign();
predecl = false;
sortbysize = attributes.Lookup("original_order") == nullptr && !fixed;
std::vector<uoffset_t> indexes =
std::vector<uoffset_t> indexes =
std::vector<uoffset_t>(object->fields()->Length());
for (uoffset_t i = 0; i < object->fields()->Length(); i++)
indexes[object->fields()->Get(i)->id()] = i;
@@ -2768,7 +2770,7 @@ bool StructDef::Deserialize(Parser &parser, const reflection::Object *object) {
// Recompute padding since that's currently not serialized.
auto size = InlineSize(field_def->value.type);
auto next_field =
i + 1 < indexes.size()
i + 1 < indexes.size()
? object->fields()->Get(indexes[i+1])
: nullptr;
bytesize += size;
@@ -3036,7 +3038,7 @@ bool Parser::Deserialize(const uint8_t *buf, const size_t size) {
return false;
else
size_prefixed = true;
}
}
auto verify_fn = size_prefixed ? &reflection::VerifySizePrefixedSchemaBuffer
: &reflection::VerifySchemaBuffer;
if (!verify_fn(verifier)) {