Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af873ba0 authored by Sonny Sasaka's avatar Sonny Sasaka Committed by Abhishek Pandit-Subedi
Browse files

Avoid const value_type of vector

This change is required to build fluoride against libstdc++.
libstdc++ asserts that: std::vector must have a non-const, non-volatile
value_type.

Bug: 176846220
Tag: #floss
Test: atest --host bluetooth_test_gd
Change-Id: Iabf796dc356826782b480fd01887c04a86e9708a
parent 706ec3b0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ bool LoadBinarySchema(const char* filename, std::string* binary_schema) {
 *
 * @return: True if operation successful, false otherwise.
 */
bool VerifyBinarySchema(const std::vector<const uint8_t>& raw_schema) {
bool VerifyBinarySchema(const std::vector<uint8_t>& raw_schema) {
  flatbuffers::Verifier verifier(raw_schema.data(), raw_schema.size());
  if (!reflection::VerifySchemaBuffer(verifier)) {
    return false;
@@ -89,7 +89,7 @@ bool CreateBinarySchemaBundle(
      fprintf(stderr, "Unable to load binary schema from filename:%s\n", filename.c_str());
      return false;
    }
    std::vector<const uint8_t> raw_schema(string_schema.begin(), string_schema.end());
    std::vector<uint8_t> raw_schema(string_schema.begin(), string_schema.end());
    if (!VerifyBinarySchema(raw_schema)) {
      fprintf(stderr, "Failed verification on binary schema filename:%s\n", filename.c_str());
      return false;
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "flatbuffers/flatbuffers.h"

bool LoadBinarySchema(const char* filename, std::string* binary_schema);
bool VerifyBinarySchema(const std::vector<const uint8_t>& raw_schema);
bool VerifyBinarySchema(const std::vector<uint8_t>& raw_schema);
bool CreateBinarySchemaBundle(
    flatbuffers::FlatBufferBuilder* builder,
    const std::vector<std::string>& filenames,
@@ -48,10 +48,10 @@ TEST_F(BundlerTest, LoadBinarySchema) {
TEST_F(BundlerTest, VerifyBinarySchema) {
  std::string string_schema;
  ASSERT_TRUE(LoadBinarySchema("test.bfbs", &string_schema));
  std::vector<const uint8_t> raw_schema(string_schema.begin(), string_schema.end());
  std::vector<uint8_t> raw_schema(string_schema.begin(), string_schema.end());
  ASSERT_TRUE(VerifyBinarySchema(raw_schema));

  std::vector<const uint8_t> bogus_raw_schema(string_schema.begin() + 1, string_schema.end());
  std::vector<uint8_t> bogus_raw_schema(string_schema.begin() + 1, string_schema.end());
  ASSERT_FALSE(VerifyBinarySchema(bogus_raw_schema));
}