From 36657c80ed47bdad1039ceb60f84336a592adc5c Mon Sep 17 00:00:00 2001 From: yefeng Date: Mon, 15 Nov 2021 19:06:38 +0800 Subject: [PATCH] bugfix --- 0002-typo-fixes-in-comments.patch | 57 +++++++++++++++++++ ...rt-binary-schema-file-loading-and-pa.patch | 37 ++++++++++++ 0004-output-errors-instead-of-stdout.patch | 35 ++++++++++++ flatbuffers.spec | 14 +++-- 4 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 0002-typo-fixes-in-comments.patch create mode 100644 0003-Changes-to-support-binary-schema-file-loading-and-pa.patch create mode 100644 0004-output-errors-instead-of-stdout.patch diff --git a/0002-typo-fixes-in-comments.patch b/0002-typo-fixes-in-comments.patch new file mode 100644 index 0000000..89701eb --- /dev/null +++ b/0002-typo-fixes-in-comments.patch @@ -0,0 +1,57 @@ +From 0a50504c58d61a260a36e5bd63e3afe42a7a6a91 Mon Sep 17 00:00:00 2001 +From: yefeng +Date: Mon, 15 Nov 2021 18:55:21 +0800 +Subject: [PATCH 1/3] typo fixes in comments + +--- + include/flatbuffers/flatbuffers.h | 6 +++--- + include/flatbuffers/flexbuffers.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h +index ee34d54..e652e40 100644 +--- a/include/flatbuffers/flatbuffers.h ++++ b/include/flatbuffers/flatbuffers.h +@@ -536,7 +536,7 @@ template class Array { + + void CopyFromSpanImpl(flatbuffers::integral_constant, + flatbuffers::span src) { +- // Use std::memcpy() instead of std::copy() to avoid preformance degradation ++ // Use std::memcpy() instead of std::copy() to avoid performance degradation + // due to aliasing if T is char or unsigned char. + // The size is known at compile time, so memcpy would be inlined. + std::memcpy(data(), src.data(), length * sizeof(T)); +@@ -2204,7 +2204,7 @@ class FlatBufferBuilder { + return reinterpret_cast(buf_.make_space(vector_size * sizeof(T))); + } + +- // End the vector of structues in the flatbuffers. ++ // End the vector of structures in the flatbuffers. + // Vector should have previously be started with StartVectorOfStructs(). + template + Offset> EndVectorOfStructs(size_t vector_size) { +@@ -2821,7 +2821,7 @@ inline int LookupEnum(const char **names, const char *name) { + + // Minimal reflection via code generation. + // Besides full-fat reflection (see reflection.h) and parsing/printing by +-// loading schemas (see idl.h), we can also have code generation for mimimal ++// loading schemas (see idl.h), we can also have code generation for minimal + // reflection data which allows pretty-printing and other uses without needing + // a schema or a parser. + // Generate code with --reflect-types (types only) or --reflect-names (names +diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h +index c71928e..3e7ab3e 100644 +--- a/include/flatbuffers/flexbuffers.h ++++ b/include/flatbuffers/flexbuffers.h +@@ -1086,7 +1086,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { + return stack_.size(); + } + +- // TODO(wvo): allow this to specify an aligment greater than the natural ++ // TODO(wvo): allow this to specify an alignment greater than the natural + // alignment. + size_t EndVector(size_t start, bool typed, bool fixed) { + auto vec = CreateVector(start, stack_.size() - start, 1, typed, fixed); +-- +2.17.1 + diff --git a/0003-Changes-to-support-binary-schema-file-loading-and-pa.patch b/0003-Changes-to-support-binary-schema-file-loading-and-pa.patch new file mode 100644 index 0000000..fc35250 --- /dev/null +++ b/0003-Changes-to-support-binary-schema-file-loading-and-pa.patch @@ -0,0 +1,37 @@ +From fa1930955cb95a445f0a8547a9ef555e1b090860 Mon Sep 17 00:00:00 2001 +From: yefeng +Date: Mon, 15 Nov 2021 18:58:22 +0800 +Subject: [PATCH 2/3] Changes to support binary schema file loading and parsing + +--- + src/flatc.cpp | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/flatc.cpp b/src/flatc.cpp +index 221b886..a3043cc 100644 +--- a/src/flatc.cpp ++++ b/src/flatc.cpp +@@ -453,16 +453,17 @@ int FlatCompiler::Compile(int argc, const char **argv) { + contents.length() != strlen(contents.c_str())) { + Error("input file appears to be binary: " + filename, true); + } +- if (is_schema) { ++ if (is_schema || is_binary_schema) { + // If we're processing multiple schemas, make sure to start each + // one from scratch. If it depends on previous schemas it must do + // so explicitly using an include. + parser.reset(new flatbuffers::Parser(opts)); + } ++ // Try to parse the file contents (binary schema/flexbuffer/textual ++ // schema) + if (is_binary_schema) { + LoadBinarySchema(*parser.get(), filename, contents); +- } +- if (opts.use_flexbuffers) { ++ } else if (opts.use_flexbuffers) { + if (opts.lang_to_generate == IDLOptions::kJson) { + parser->flex_root_ = flexbuffers::GetRoot( + reinterpret_cast(contents.c_str()), +-- +2.17.1 + diff --git a/0004-output-errors-instead-of-stdout.patch b/0004-output-errors-instead-of-stdout.patch new file mode 100644 index 0000000..3f7b60a --- /dev/null +++ b/0004-output-errors-instead-of-stdout.patch @@ -0,0 +1,35 @@ +From 766c1984b6e5e3e8ac1c153238e05b7f0624f7b5 Mon Sep 17 00:00:00 2001 +From: yefeng +Date: Mon, 15 Nov 2021 18:59:03 +0800 +Subject: [PATCH 3/3] output errors instead of stdout + +--- + src/flatc_main.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/flatc_main.cpp b/src/flatc_main.cpp +index b196666..30d0b47 100644 +--- a/src/flatc_main.cpp ++++ b/src/flatc_main.cpp +@@ -23,15 +23,15 @@ static void Warn(const flatbuffers::FlatCompiler *flatc, + const std::string &warn, bool show_exe_name) { + (void)flatc; + if (show_exe_name) { printf("%s: ", g_program_name); } +- printf("warning: %s\n", warn.c_str()); ++ fprintf(stderr, "warning: %s\n", warn.c_str()); + } + + static void Error(const flatbuffers::FlatCompiler *flatc, + const std::string &err, bool usage, bool show_exe_name) { + if (show_exe_name) { printf("%s: ", g_program_name); } +- printf("error: %s\n", err.c_str()); ++ fprintf(stderr, "error: %s\n", err.c_str()); + if (usage && flatc) { +- printf("%s", flatc->GetUsageString(g_program_name).c_str()); ++ fprintf(stderr, "%s", flatc->GetUsageString(g_program_name).c_str()); + } + exit(1); + } +-- +2.17.1 + diff --git a/flatbuffers.spec b/flatbuffers.spec index 49ae4b7..c544eb7 100644 --- a/flatbuffers.spec +++ b/flatbuffers.spec @@ -5,7 +5,7 @@ %endif Name: flatbuffers Version: 2.0.0 -Release: 2 +Release: 3 Summary: Memory efficient serialization library License: Apache-2.0 URL: https://github.com/google/flatbuffers @@ -14,6 +14,9 @@ Source1: flatc.1 Source2: flatbuffers.7 Patch0: 0001-Fix-compiler-warning-Wredundant-parens.patch +Patch1: 0002-typo-fixes-in-comments.patch +Patch2: 0003-Changes-to-support-binary-schema-file-loading-and-pa.patch +Patch3: 0004-output-errors-instead-of-stdout.patch BuildRequires: gcc-c++ cmake >= 2.8.9 Provides: bundled(grpc) @@ -72,6 +75,12 @@ make test %{_libdir}/cmake/flatbuffers/*.cmake %changelog +* Wed Nov 15 2021 yefeng - 2.0.0-3 +- output errors instead of stdout, Typo fixes in comments and Changes to support binary schema file + +* Wed Nov 11 2021 yefeng - 2.0.0-2 +- Fix compiler warning + * Tue Aug 17 2021 yaoxin - 2.0.0-1 - Upgrade 2.0.0 to fix CVE-2020-35864 @@ -79,7 +88,4 @@ make test - Fix complication failed due to gcc upgrade * Mon Jan 11 2021 yanan li - 1.10.0-1 -- Package init - -* Wed Nov 11 2021 yefeng - 2.0.0-2 - Package init \ No newline at end of file -- Gitee