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/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"));