Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@paulovap
Copy link
Contributor

Alongside --binary and --json, an additional switch (--flexbuffers) can be passed to convert data using FlexBuffers.

Copy link
Collaborator

@aardappel aardappel left a comment

Choose a reason for hiding this comment

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

Thanks for adding this, that was definitely missing!

Alongside --binary and --json, an additional
switch (--flexbuffers) can be passed to convert
data using FlexBuffers
@aardappel
Copy link
Collaborator

Thanks!

@aardappel aardappel merged commit cfb4ecf into google:master Sep 26, 2019
@vglavnyy
Copy link
Contributor

vglavnyy commented Nov 2, 2019

@paulovap
Perhaps, this code has a typo.
A predicate !opts.use_flexbuffers at line 438 is always true.

flatbuffers/src/flatc.cpp

Lines 427 to 446 in 32254b7

if (opts.use_flexbuffers) {
if (opts.lang_to_generate == IDLOptions::kJson) {
parser->flex_root_ = flexbuffers::GetRoot(
reinterpret_cast<const uint8_t *>(contents.c_str()),
contents.size());
} else {
parser->flex_builder_.Clear();
ParseFile(*parser.get(), filename, contents, include_directories);
}
} else {
ParseFile(*parser.get(), filename, contents, include_directories);
if (!opts.use_flexbuffers && !is_schema &&
!parser->builder_.GetSize()) {
// If a file doesn't end in .fbs, it must be json/binary. Ensure we
// didn't just parse a schema with a different extension.
Error("input file is neither json nor a .fbs (schema) file: " +
filename,
true);
}
}

PVS-Studio
V560 [CWE-571] A part of conditional expression is always true: !opts.use_flexbuffers. flatc.cpp 438

Could you fix it?

@paulovap
Copy link
Contributor Author

paulovap commented Nov 2, 2019

PVS-Studio
V560 [CWE-571] A part of conditional expression is always true: !opts.use_flexbuffers. flatc.cpp 438

Sure.
#5604

@vglavnyy
Copy link
Contributor

vglavnyy commented Nov 2, 2019

Thanks

LuckyRu pushed a commit to LuckyRu/flatbuffers that referenced this pull request Oct 2, 2020
Alongside --binary and --json, an additional
switch (--flexbuffers) can be passed to convert
data using FlexBuffers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants