Remove usage of CHECK_NOTNULL

We want to switch to absl logging instead of glog.  gtest and ceres are
going there, and we already have absl as a dependency.  ABSL doesn't
have CHECK_NOTNULL, and we can move things over in an easier to review
fashion.

Change-Id: Ifd9a11ec34a2357cec43f88dba015db9c28ed2cf
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/flatbuffers/base.cc b/aos/flatbuffers/base.cc
index afd48a2..f0e7a8b 100644
--- a/aos/flatbuffers/base.cc
+++ b/aos/flatbuffers/base.cc
@@ -51,10 +51,9 @@
   if (parent_ != nullptr) {
     return parent_->InsertBytes(insertion_point, aligned_bytes, set_zero);
   } else {
-    std::optional<std::span<uint8_t>> new_buffer =
-        CHECK_NOTNULL(allocator_)
-            ->InsertBytes(insertion_point, aligned_bytes, Alignment(),
-                          set_zero);
+    CHECK(allocator_ != nullptr);
+    std::optional<std::span<uint8_t>> new_buffer = allocator_->InsertBytes(
+        insertion_point, aligned_bytes, Alignment(), set_zero);
     if (!new_buffer.has_value()) {
       return std::nullopt;
     }
@@ -94,6 +93,7 @@
     if (absolute_offset >= modification_point &&
         object.inline_entry < modification_point) {
       if (*object.inline_entry != 0) {
+        CHECK(object.object != nullptr);
         CHECK_EQ(static_cast<const void *>(
                      static_cast<const uint8_t *>(absolute_offset)),
                  DereferenceOffset(object.inline_entry));
diff --git a/aos/flatbuffers/static_flatbuffers.cc b/aos/flatbuffers/static_flatbuffers.cc
index 4c013a2..449bcbc 100644
--- a/aos/flatbuffers/static_flatbuffers.cc
+++ b/aos/flatbuffers/static_flatbuffers.cc
@@ -558,25 +558,35 @@
       // Unconditionally copy strings/vectors, even if it will just end up
       // being 0-length (this maintains consistency with the flatbuffer Pack()
       // behavior).
-      if (!CHECK_NOTNULL(add_%s())->FromFlatbuffer(other.%s)) {
-        // Fail if we were unable to copy (e.g., if we tried to copy in a long
-        // vector and do not have the space for it).
-        return false;
-      }
-      )code",
-                                           field.name, field.name));
-    } else {
-      // Tables are stored as unique_ptr<FooTable>
-      copiers.emplace_back(absl::StrFormat(R"code(
-      if (other.%s) {
-        if (!CHECK_NOTNULL(add_%s())->FromFlatbuffer(*other.%s)) {
+      {
+        %s* added_%s = add_%s();
+        CHECK(added_%s != nullptr);
+        if (!added_%s->FromFlatbuffer(other.%s)) {
           // Fail if we were unable to copy (e.g., if we tried to copy in a long
           // vector and do not have the space for it).
           return false;
         }
       }
       )code",
-                                           field.name, field.name, field.name));
+                                           field.full_type, field.name,
+                                           field.name, field.name, field.name,
+                                           field.name));
+    } else {
+      // Tables are stored as unique_ptr<FooTable>
+      copiers.emplace_back(absl::StrFormat(R"code(
+      if (other.%s) {
+        %s* added_%s = add_%s();
+        CHECK(added_%s != nullptr);
+        if (!added_%s->FromFlatbuffer(*other.%s)) {
+          // Fail if we were unable to copy (e.g., if we tried to copy in a long
+          // vector and do not have the space for it).
+          return false;
+        }
+      }
+      )code",
+                                           field.name, field.full_type,
+                                           field.name, field.name, field.name,
+                                           field.name, field.name));
     }
   }
   return absl::StrFormat(
@@ -622,14 +632,18 @@
     } else {
       copiers.emplace_back(absl::StrFormat(R"code(
       if (other.has_%s()) {
-        if (!CHECK_NOTNULL(add_%s())->FromFlatbuffer(other.%s())) {
+        %s* added_%s = add_%s();
+        CHECK(added_%s != nullptr);
+        if (!added_%s->FromFlatbuffer(other.%s())) {
           // Fail if we were unable to copy (e.g., if we tried to copy in a long
           // vector and do not have the space for it).
           return false;
         }
       }
       )code",
-                                           field.name, field.name, field.name));
+                                           field.name, field.full_type,
+                                           field.name, field.name, field.name,
+                                           field.name, field.name));
     }
   }
   return absl::StrFormat(
@@ -646,7 +660,8 @@
   // Equivalent to FromFlatbuffer(const Flatbuffer&); this overload is provided
   // to ease implementation of the aos::fbs::Vector internals.
   [[nodiscard]] bool FromFlatbuffer(const Flatbuffer *other) {
-    return FromFlatbuffer(*CHECK_NOTNULL(other));
+    CHECK(other != nullptr);
+    return FromFlatbuffer(*other);
   }
 )code",
       absl::StrJoin(copiers, "\n"));
diff --git a/aos/flatbuffers/static_flatbuffers_test.cc b/aos/flatbuffers/static_flatbuffers_test.cc
index 4a8b9e9..187c72a 100644
--- a/aos/flatbuffers/static_flatbuffers_test.cc
+++ b/aos/flatbuffers/static_flatbuffers_test.cc
@@ -123,7 +123,8 @@
   }
   {
     auto vector_of_strings = object->add_vector_of_strings();
-    auto sub_string = CHECK_NOTNULL(vector_of_strings->emplace_back());
+    auto sub_string = vector_of_strings->emplace_back();
+    CHECK(sub_string != nullptr);
     CHECK(sub_string->emplace_back('D'));
   }
   { object->set_substruct({971, 254}); }
@@ -163,8 +164,13 @@
   builder.add_foo(1234);
   return builder.Finish();
 }
-void PopulateStatic(SubTableStatic *subtable) { subtable->set_foo(1234); }
+void PopulateStatic(SubTableStatic *subtable) {
+  CHECK(subtable != nullptr);
+  subtable->set_foo(1234);
+}
+
 }  // namespace
+
 TEST_F(StaticFlatbuffersTest, PopulateMethodConversionExample) {
   // Using a FlatBufferBuilder:
   flatbuffers::FlatBufferBuilder fbb;
@@ -178,7 +184,7 @@
   // Using the static flatbuffer API.
   aos::fbs::AlignedVectorAllocator allocator;
   Builder<TestTableStatic> static_builder(&allocator);
-  PopulateStatic(CHECK_NOTNULL(static_builder.get()->add_subtable()));
+  PopulateStatic(static_builder.get()->add_subtable());
 
   // And confirm that they both contain the expected flatbuffer:
   const std::string expected = R"json({ "subtable": { "foo": 1234 } })json";
@@ -292,7 +298,8 @@
       EXPECT_FALSE(object->has_vector_of_strings());
       auto vector_of_strings = object->add_vector_of_strings();
       EXPECT_TRUE(object->has_vector_of_strings());
-      auto sub_string = CHECK_NOTNULL(vector_of_strings->emplace_back());
+      auto sub_string = vector_of_strings->emplace_back();
+      CHECK(sub_string != nullptr);
       ASSERT_TRUE(sub_string->emplace_back('D'));
       EXPECT_TRUE(fbs.has_vector_of_strings());
       ASSERT_EQ(1u, fbs.vector_of_strings()->size());
@@ -729,7 +736,8 @@
     ASSERT_TRUE(builder.Verify());
     ASSERT_FALSE(object->has_vector_of_scalars())
         << aos::FlatbufferToJson(builder.AsFlatbufferSpan());
-    vector = CHECK_NOTNULL(object->add_vector_of_scalars());
+    vector = object->add_vector_of_scalars();
+    ASSERT_TRUE(vector != nullptr);
     ASSERT_TRUE(builder.Verify());
     EXPECT_EQ(0u, object->AsFlatbuffer().vector_of_scalars()->size());
     ASSERT_TRUE(vector->emplace_back(9));
@@ -783,7 +791,8 @@
     object->clear_subtable();
     ASSERT_TRUE(builder.Verify());
     EXPECT_FALSE(object->has_subtable());
-    auto subtable = CHECK_NOTNULL(object->add_subtable());
+    auto subtable = object->add_subtable();
+    ASSERT_TRUE(subtable != nullptr);
     subtable->set_baz(9.71);
     EXPECT_EQ(
         R"json({
@@ -806,7 +815,8 @@
     object->clear_subtable();
     ASSERT_TRUE(builder.Verify());
     EXPECT_FALSE(object->has_subtable());
-    subtable = CHECK_NOTNULL(object->add_subtable());
+    subtable = object->add_subtable();
+    ASSERT_TRUE(subtable != nullptr);
     subtable->set_baz(16.78);
     EXPECT_EQ(
         R"json({
@@ -883,7 +893,8 @@
   }
   {
     auto vector_of_strings = object->add_vector_of_strings();
-    auto sub_string = CHECK_NOTNULL(vector_of_strings->emplace_back());
+    auto sub_string = vector_of_strings->emplace_back();
+    ASSERT_TRUE(sub_string != nullptr);
     ASSERT_TRUE(sub_string->emplace_back('D'));
   }
   { object->set_substruct({971, 254}); }
@@ -1048,7 +1059,8 @@
   }
   {
     auto vector_of_strings = object->add_vector_of_strings();
-    auto sub_string = CHECK_NOTNULL(vector_of_strings->emplace_back());
+    auto sub_string = vector_of_strings->emplace_back();
+    ASSERT_TRUE(sub_string != nullptr);
     ASSERT_TRUE(sub_string->emplace_back('D'));
   }
   { object->set_substruct({971, 254}); }
@@ -1153,7 +1165,8 @@
   }
   {
     auto vector_of_strings = object->add_vector_of_strings();
-    auto sub_string = CHECK_NOTNULL(vector_of_strings->emplace_back());
+    auto sub_string = vector_of_strings->emplace_back();
+    ASSERT_TRUE(sub_string != nullptr);
     ASSERT_TRUE(sub_string->emplace_back('D'));
   }
   { object->set_substruct({971, 254}); }
diff --git a/aos/flatbuffers/static_vector.h b/aos/flatbuffers/static_vector.h
index da250e2..f0c48cd 100644
--- a/aos/flatbuffers/static_vector.h
+++ b/aos/flatbuffers/static_vector.h
@@ -409,7 +409,8 @@
   // This is a deep copy, and will call FromFlatbuffer on any constituent
   // objects.
   [[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer *vector) {
-    return FromFlatbuffer(*CHECK_NOTNULL(vector));
+    CHECK(vector != nullptr);
+    return FromFlatbuffer(*vector);
   }
   [[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer &vector);
   // The remaining FromFlatbuffer() overloads are for when using the flatbuffer
@@ -449,8 +450,8 @@
     resize_inline(input_size, SetZero::kNo);
 
     if (input_size > 0) {
-      memcpy(inline_data(), CHECK_NOTNULL(input_data),
-             size() * sizeof(InlineType));
+      CHECK(input_data != nullptr);
+      memcpy(inline_data(), input_data, size() * sizeof(InlineType));
     }
     return true;
   }
@@ -584,7 +585,7 @@
       return;
     } else {
       while (length_ < size) {
-        CHECK_NOTNULL(emplace_back());
+        CHECK(emplace_back() != nullptr);
       }
     }
   }
@@ -725,7 +726,9 @@
     resize_not_inline(0);
 
     for (const auto &entry : vector) {
-      if (!CHECK_NOTNULL(emplace_back())->FromFlatbuffer(entry)) {
+      T *emplaced_entry = emplace_back();
+      CHECK(emplaced_entry != nullptr);
+      if (!emplaced_entry->FromFlatbuffer(entry)) {
         return false;
       }
     }
diff --git a/aos/flatbuffers/test_dir/sample_test_static.h b/aos/flatbuffers/test_dir/sample_test_static.h
index de88c92..1aaf3f6 100644
--- a/aos/flatbuffers/test_dir/sample_test_static.h
+++ b/aos/flatbuffers/test_dir/sample_test_static.h
@@ -137,7 +137,8 @@
   // Equivalent to FromFlatbuffer(const Flatbuffer&); this overload is provided
   // to ease implementation of the aos::fbs::Vector internals.
   [[nodiscard]] bool FromFlatbuffer(const Flatbuffer *other) {
-    return FromFlatbuffer(*CHECK_NOTNULL(other));
+    CHECK(other != nullptr);
+    return FromFlatbuffer(*other);
   }
 
   // Copies the contents of the provided flatbuffer into this flatbuffer,
@@ -348,7 +349,8 @@
   // Equivalent to FromFlatbuffer(const Flatbuffer&); this overload is provided
   // to ease implementation of the aos::fbs::Vector internals.
   [[nodiscard]] bool FromFlatbuffer(const Flatbuffer *other) {
-    return FromFlatbuffer(*CHECK_NOTNULL(other));
+    CHECK(other != nullptr);
+    return FromFlatbuffer(*other);
   }
 
   // Copies the contents of the provided flatbuffer into this flatbuffer,
@@ -1460,8 +1462,10 @@
     }
 
     if (other.has_vector_of_structs()) {
-      if (!CHECK_NOTNULL(add_vector_of_structs())
-               ->FromFlatbuffer(other.vector_of_structs())) {
+      ::aos::fbs::Vector<aos::fbs::testing::SubStruct, 3, true, 0>
+          *added_vector_of_structs = add_vector_of_structs();
+      CHECK(added_vector_of_structs != nullptr);
+      if (!added_vector_of_structs->FromFlatbuffer(other.vector_of_structs())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1469,8 +1473,12 @@
     }
 
     if (other.has_unspecified_length_vector_of_strings()) {
-      if (!CHECK_NOTNULL(add_unspecified_length_vector_of_strings())
-               ->FromFlatbuffer(other.unspecified_length_vector_of_strings())) {
+      ::aos::fbs::Vector<::aos::fbs::String<0>, 0, false, 0>
+          *added_unspecified_length_vector_of_strings =
+              add_unspecified_length_vector_of_strings();
+      CHECK(added_unspecified_length_vector_of_strings != nullptr);
+      if (!added_unspecified_length_vector_of_strings->FromFlatbuffer(
+              other.unspecified_length_vector_of_strings())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1478,8 +1486,10 @@
     }
 
     if (other.has_vector_of_tables()) {
-      if (!CHECK_NOTNULL(add_vector_of_tables())
-               ->FromFlatbuffer(other.vector_of_tables())) {
+      ::aos::fbs::Vector<aos::fbs::testing::SubTableStatic, 3, false, 0>
+          *added_vector_of_tables = add_vector_of_tables();
+      CHECK(added_vector_of_tables != nullptr);
+      if (!added_vector_of_tables->FromFlatbuffer(other.vector_of_tables())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1487,8 +1497,10 @@
     }
 
     if (other.has_vector_aligned()) {
-      if (!CHECK_NOTNULL(add_vector_aligned())
-               ->FromFlatbuffer(other.vector_aligned())) {
+      ::aos::fbs::Vector<int32_t, 3, true, 64> *added_vector_aligned =
+          add_vector_aligned();
+      CHECK(added_vector_aligned != nullptr);
+      if (!added_vector_aligned->FromFlatbuffer(other.vector_aligned())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1496,8 +1508,10 @@
     }
 
     if (other.has_vector_of_strings()) {
-      if (!CHECK_NOTNULL(add_vector_of_strings())
-               ->FromFlatbuffer(other.vector_of_strings())) {
+      ::aos::fbs::Vector<::aos::fbs::String<10>, 3, false, 0>
+          *added_vector_of_strings = add_vector_of_strings();
+      CHECK(added_vector_of_strings != nullptr);
+      if (!added_vector_of_strings->FromFlatbuffer(other.vector_of_strings())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1505,8 +1519,10 @@
     }
 
     if (other.has_vector_of_scalars()) {
-      if (!CHECK_NOTNULL(add_vector_of_scalars())
-               ->FromFlatbuffer(other.vector_of_scalars())) {
+      ::aos::fbs::Vector<int32_t, 3, true, 0> *added_vector_of_scalars =
+          add_vector_of_scalars();
+      CHECK(added_vector_of_scalars != nullptr);
+      if (!added_vector_of_scalars->FromFlatbuffer(other.vector_of_scalars())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1514,8 +1530,11 @@
     }
 
     if (other.has_unspecified_length_string()) {
-      if (!CHECK_NOTNULL(add_unspecified_length_string())
-               ->FromFlatbuffer(other.unspecified_length_string())) {
+      ::aos::fbs::String<0> *added_unspecified_length_string =
+          add_unspecified_length_string();
+      CHECK(added_unspecified_length_string != nullptr);
+      if (!added_unspecified_length_string->FromFlatbuffer(
+              other.unspecified_length_string())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1523,8 +1542,11 @@
     }
 
     if (other.has_unspecified_length_vector()) {
-      if (!CHECK_NOTNULL(add_unspecified_length_vector())
-               ->FromFlatbuffer(other.unspecified_length_vector())) {
+      ::aos::fbs::Vector<uint8_t, 0, true, 0> *added_unspecified_length_vector =
+          add_unspecified_length_vector();
+      CHECK(added_unspecified_length_vector != nullptr);
+      if (!added_unspecified_length_vector->FromFlatbuffer(
+              other.unspecified_length_vector())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1532,8 +1554,10 @@
     }
 
     if (other.has_included_table()) {
-      if (!CHECK_NOTNULL(add_included_table())
-               ->FromFlatbuffer(other.included_table())) {
+      aos::fbs::testing::included::IncludedTableStatic *added_included_table =
+          add_included_table();
+      CHECK(added_included_table != nullptr);
+      if (!added_included_table->FromFlatbuffer(other.included_table())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1541,7 +1565,9 @@
     }
 
     if (other.has_subtable()) {
-      if (!CHECK_NOTNULL(add_subtable())->FromFlatbuffer(other.subtable())) {
+      aos::fbs::testing::SubTableStatic *added_subtable = add_subtable();
+      CHECK(added_subtable != nullptr);
+      if (!added_subtable->FromFlatbuffer(other.subtable())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1549,7 +1575,9 @@
     }
 
     if (other.has_string()) {
-      if (!CHECK_NOTNULL(add_string())->FromFlatbuffer(other.string())) {
+      ::aos::fbs::String<20> *added_string = add_string();
+      CHECK(added_string != nullptr);
+      if (!added_string->FromFlatbuffer(other.string())) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1565,7 +1593,8 @@
   // Equivalent to FromFlatbuffer(const Flatbuffer&); this overload is provided
   // to ease implementation of the aos::fbs::Vector internals.
   [[nodiscard]] bool FromFlatbuffer(const Flatbuffer *other) {
-    return FromFlatbuffer(*CHECK_NOTNULL(other));
+    CHECK(other != nullptr);
+    return FromFlatbuffer(*other);
   }
 
   // Copies the contents of the provided flatbuffer into this flatbuffer,
@@ -1585,86 +1614,124 @@
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_vector_of_structs())
-             ->FromFlatbuffer(other.vector_of_structs)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<aos::fbs::testing::SubStruct, 3, true, 0>
+          *added_vector_of_structs = add_vector_of_structs();
+      CHECK(added_vector_of_structs != nullptr);
+      if (!added_vector_of_structs->FromFlatbuffer(other.vector_of_structs)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_unspecified_length_vector_of_strings())
-             ->FromFlatbuffer(other.unspecified_length_vector_of_strings)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<::aos::fbs::String<0>, 0, false, 0>
+          *added_unspecified_length_vector_of_strings =
+              add_unspecified_length_vector_of_strings();
+      CHECK(added_unspecified_length_vector_of_strings != nullptr);
+      if (!added_unspecified_length_vector_of_strings->FromFlatbuffer(
+              other.unspecified_length_vector_of_strings)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_vector_of_tables())
-             ->FromFlatbuffer(other.vector_of_tables)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<aos::fbs::testing::SubTableStatic, 3, false, 0>
+          *added_vector_of_tables = add_vector_of_tables();
+      CHECK(added_vector_of_tables != nullptr);
+      if (!added_vector_of_tables->FromFlatbuffer(other.vector_of_tables)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_vector_aligned())
-             ->FromFlatbuffer(other.vector_aligned)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<int32_t, 3, true, 64> *added_vector_aligned =
+          add_vector_aligned();
+      CHECK(added_vector_aligned != nullptr);
+      if (!added_vector_aligned->FromFlatbuffer(other.vector_aligned)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_vector_of_strings())
-             ->FromFlatbuffer(other.vector_of_strings)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<::aos::fbs::String<10>, 3, false, 0>
+          *added_vector_of_strings = add_vector_of_strings();
+      CHECK(added_vector_of_strings != nullptr);
+      if (!added_vector_of_strings->FromFlatbuffer(other.vector_of_strings)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_vector_of_scalars())
-             ->FromFlatbuffer(other.vector_of_scalars)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<int32_t, 3, true, 0> *added_vector_of_scalars =
+          add_vector_of_scalars();
+      CHECK(added_vector_of_scalars != nullptr);
+      if (!added_vector_of_scalars->FromFlatbuffer(other.vector_of_scalars)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_unspecified_length_string())
-             ->FromFlatbuffer(other.unspecified_length_string)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::String<0> *added_unspecified_length_string =
+          add_unspecified_length_string();
+      CHECK(added_unspecified_length_string != nullptr);
+      if (!added_unspecified_length_string->FromFlatbuffer(
+              other.unspecified_length_string)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_unspecified_length_vector())
-             ->FromFlatbuffer(other.unspecified_length_vector)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::Vector<uint8_t, 0, true, 0> *added_unspecified_length_vector =
+          add_unspecified_length_vector();
+      CHECK(added_unspecified_length_vector != nullptr);
+      if (!added_unspecified_length_vector->FromFlatbuffer(
+              other.unspecified_length_vector)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     if (other.included_table) {
-      if (!CHECK_NOTNULL(add_included_table())
-               ->FromFlatbuffer(*other.included_table)) {
+      aos::fbs::testing::included::IncludedTableStatic *added_included_table =
+          add_included_table();
+      CHECK(added_included_table != nullptr);
+      if (!added_included_table->FromFlatbuffer(*other.included_table)) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1672,7 +1739,9 @@
     }
 
     if (other.subtable) {
-      if (!CHECK_NOTNULL(add_subtable())->FromFlatbuffer(*other.subtable)) {
+      aos::fbs::testing::SubTableStatic *added_subtable = add_subtable();
+      CHECK(added_subtable != nullptr);
+      if (!added_subtable->FromFlatbuffer(*other.subtable)) {
         // Fail if we were unable to copy (e.g., if we tried to copy in a long
         // vector and do not have the space for it).
         return false;
@@ -1682,10 +1751,14 @@
     // Unconditionally copy strings/vectors, even if it will just end up
     // being 0-length (this maintains consistency with the flatbuffer Pack()
     // behavior).
-    if (!CHECK_NOTNULL(add_string())->FromFlatbuffer(other.string)) {
-      // Fail if we were unable to copy (e.g., if we tried to copy in a long
-      // vector and do not have the space for it).
-      return false;
+    {
+      ::aos::fbs::String<20> *added_string = add_string();
+      CHECK(added_string != nullptr);
+      if (!added_string->FromFlatbuffer(other.string)) {
+        // Fail if we were unable to copy (e.g., if we tried to copy in a long
+        // vector and do not have the space for it).
+        return false;
+      }
     }
 
     set_scalar(other.scalar);