Fix more OSS warnings and build errors
-Wc++98-compat-extra-semi * in type_map.h -Winconsistent-missing-override * in gl_texture_buffer.h -Wdeprecated-declarations * usage of (absl) Status in * status_util.cc * api2/packet.h * output_stream_shard.cc -Wimplicit-const-int-float-conversion * Adds a static_cast to handle the precision loss when converting from large ints to floating point ANNOTATE_THREAD_NAME * explicitly uses ABSL_ANNOTATE_THREAD_NAME instead. This is useful in Chromium's build where there are multiple ANNOTATE_THREAD_NAME symbols Also ran clang-format over all of each edited file PiperOrigin-RevId: 537351290
This commit is contained in:
parent
9045a74ba3
commit
280bd320b4
|
@ -165,7 +165,7 @@ template <class V, class... U>
|
||||||
struct IsCompatibleType<V, OneOf<U...>>
|
struct IsCompatibleType<V, OneOf<U...>>
|
||||||
: std::integral_constant<bool, (std::is_same_v<V, U> || ...)> {};
|
: std::integral_constant<bool, (std::is_same_v<V, U> || ...)> {};
|
||||||
|
|
||||||
}; // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline Packet<T> PacketBase::As() const {
|
inline Packet<T> PacketBase::As() const {
|
||||||
|
@ -259,19 +259,19 @@ struct First {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct AddStatus {
|
struct AddStatus {
|
||||||
using type = StatusOr<T>;
|
using type = absl::StatusOr<T>;
|
||||||
};
|
};
|
||||||
template <class T>
|
template <class T>
|
||||||
struct AddStatus<StatusOr<T>> {
|
struct AddStatus<absl::StatusOr<T>> {
|
||||||
using type = StatusOr<T>;
|
using type = absl::StatusOr<T>;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AddStatus<Status> {
|
struct AddStatus<absl::Status> {
|
||||||
using type = Status;
|
using type = absl::Status;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AddStatus<void> {
|
struct AddStatus<void> {
|
||||||
using type = Status;
|
using type = absl::Status;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R, class F, class... A>
|
template <class R, class F, class... A>
|
||||||
|
@ -282,7 +282,7 @@ struct CallAndAddStatusImpl {
|
||||||
};
|
};
|
||||||
template <class F, class... A>
|
template <class F, class... A>
|
||||||
struct CallAndAddStatusImpl<void, F, A...> {
|
struct CallAndAddStatusImpl<void, F, A...> {
|
||||||
Status operator()(const F& f, A&&... a) {
|
absl::Status operator()(const F& f, A&&... a) {
|
||||||
f(std::forward<A>(a)...);
|
f(std::forward<A>(a)...);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,10 +88,13 @@ class SafeIntStrongIntValidator {
|
||||||
|
|
||||||
// If the argument is floating point, we can do a simple check to make
|
// If the argument is floating point, we can do a simple check to make
|
||||||
// sure the value is in range. It is undefined behavior to convert to int
|
// sure the value is in range. It is undefined behavior to convert to int
|
||||||
// from a float that is out of range.
|
// from a float that is out of range. Since large integers will loose some
|
||||||
|
// precision when being converted to floating point, the integer max and min
|
||||||
|
// are explicitly converted back to floating point for this comparison, in
|
||||||
|
// order to satisfy compiler warnings.
|
||||||
if (std::is_floating_point<U>::value) {
|
if (std::is_floating_point<U>::value) {
|
||||||
if (arg < std::numeric_limits<T>::min() ||
|
if (arg < static_cast<U>(std::numeric_limits<T>::min()) ||
|
||||||
arg > std::numeric_limits<T>::max()) {
|
arg > static_cast<U>(std::numeric_limits<T>::max())) {
|
||||||
ErrorType::Error("SafeInt: init from out of bounds float", arg, "=");
|
ErrorType::Error("SafeInt: init from out of bounds float", arg, "=");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -284,11 +287,11 @@ class SafeIntStrongIntValidator {
|
||||||
// A SafeIntStrongIntValidator policy class to LOG(FATAL) on errors.
|
// A SafeIntStrongIntValidator policy class to LOG(FATAL) on errors.
|
||||||
struct LogFatalOnError {
|
struct LogFatalOnError {
|
||||||
template <typename Tlhs, typename Trhs>
|
template <typename Tlhs, typename Trhs>
|
||||||
static void Error(const char *error, Tlhs lhs, Trhs rhs, const char *op) {
|
static void Error(const char* error, Tlhs lhs, Trhs rhs, const char* op) {
|
||||||
LOG(FATAL) << error << ": (" << lhs << " " << op << " " << rhs << ")";
|
LOG(FATAL) << error << ": (" << lhs << " " << op << " " << rhs << ")";
|
||||||
}
|
}
|
||||||
template <typename Tval>
|
template <typename Tval>
|
||||||
static void Error(const char *error, Tval val, const char *op) {
|
static void Error(const char* error, Tval val, const char* op) {
|
||||||
LOG(FATAL) << error << ": (" << op << val << ")";
|
LOG(FATAL) << error << ": (" << op << val << ")";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -94,7 +94,7 @@ const Packet& OutputStreamShard::Header() const {
|
||||||
// binary. This function can be defined in the .cc file because only two
|
// binary. This function can be defined in the .cc file because only two
|
||||||
// versions are ever instantiated, and all call sites are within this .cc file.
|
// versions are ever instantiated, and all call sites are within this .cc file.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
absl::Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
if (IsClosed()) {
|
if (IsClosed()) {
|
||||||
return mediapipe::FailedPreconditionErrorBuilder(MEDIAPIPE_LOC)
|
return mediapipe::FailedPreconditionErrorBuilder(MEDIAPIPE_LOC)
|
||||||
<< "Packet sent to closed stream \"" << Name() << "\".";
|
<< "Packet sent to closed stream \"" << Name() << "\".";
|
||||||
|
@ -113,7 +113,7 @@ Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
<< timestamp.DebugString();
|
<< timestamp.DebugString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status result = output_stream_spec_->packet_type->Validate(packet);
|
absl::Status result = output_stream_spec_->packet_type->Validate(packet);
|
||||||
if (!result.ok()) {
|
if (!result.ok()) {
|
||||||
return StatusBuilder(result, MEDIAPIPE_LOC).SetPrepend() << absl::StrCat(
|
return StatusBuilder(result, MEDIAPIPE_LOC).SetPrepend() << absl::StrCat(
|
||||||
"Packet type mismatch on calculator outputting to stream \"",
|
"Packet type mismatch on calculator outputting to stream \"",
|
||||||
|
@ -132,14 +132,14 @@ Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputStreamShard::AddPacket(const Packet& packet) {
|
void OutputStreamShard::AddPacket(const Packet& packet) {
|
||||||
Status status = AddPacketInternal(packet);
|
absl::Status status = AddPacketInternal(packet);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
output_stream_spec_->TriggerErrorCallback(status);
|
output_stream_spec_->TriggerErrorCallback(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputStreamShard::AddPacket(Packet&& packet) {
|
void OutputStreamShard::AddPacket(Packet&& packet) {
|
||||||
Status status = AddPacketInternal(std::move(packet));
|
absl::Status status = AddPacketInternal(std::move(packet));
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
output_stream_spec_->TriggerErrorCallback(status);
|
output_stream_spec_->TriggerErrorCallback(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ absl::Status CombinedStatus(absl::string_view general_comment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error_code == StatusCode::kOk) return OkStatus();
|
if (error_code == absl::StatusCode::kOk) return absl::OkStatus();
|
||||||
Status combined;
|
absl::Status combined;
|
||||||
combined = absl::Status(
|
combined = absl::Status(
|
||||||
error_code,
|
error_code,
|
||||||
absl::StrCat(general_comment, "\n", absl::StrJoin(errors, "\n")));
|
absl::StrCat(general_comment, "\n", absl::StrJoin(errors, "\n")));
|
||||||
|
|
|
@ -241,9 +241,9 @@ class StaticMap {
|
||||||
#define DEFINE_MEDIAPIPE_TYPE_MAP(MapName, KeyType) \
|
#define DEFINE_MEDIAPIPE_TYPE_MAP(MapName, KeyType) \
|
||||||
class MapName : public type_map_internal::StaticMap<MapName, KeyType> {};
|
class MapName : public type_map_internal::StaticMap<MapName, KeyType> {};
|
||||||
// Defines a map from unique typeid number to MediaPipeTypeData.
|
// Defines a map from unique typeid number to MediaPipeTypeData.
|
||||||
DEFINE_MEDIAPIPE_TYPE_MAP(PacketTypeIdToMediaPipeTypeData, size_t);
|
DEFINE_MEDIAPIPE_TYPE_MAP(PacketTypeIdToMediaPipeTypeData, size_t)
|
||||||
// Defines a map from unique type string to MediaPipeTypeData.
|
// Defines a map from unique type string to MediaPipeTypeData.
|
||||||
DEFINE_MEDIAPIPE_TYPE_MAP(PacketTypeStringToMediaPipeTypeData, std::string);
|
DEFINE_MEDIAPIPE_TYPE_MAP(PacketTypeStringToMediaPipeTypeData, std::string)
|
||||||
|
|
||||||
// MEDIAPIPE_REGISTER_TYPE can be used to register a type.
|
// MEDIAPIPE_REGISTER_TYPE can be used to register a type.
|
||||||
// Convention:
|
// Convention:
|
||||||
|
|
|
@ -65,7 +65,7 @@ static void SetThreadName(const char* name) {
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
pthread_setname_np(name);
|
pthread_setname_np(name);
|
||||||
#endif
|
#endif
|
||||||
ANNOTATE_THREAD_NAME(name);
|
ABSL_ANNOTATE_THREAD_NAME(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlContext::DedicatedThread::DedicatedThread() {
|
GlContext::DedicatedThread::DedicatedThread() {
|
||||||
|
|
|
@ -91,9 +91,9 @@ class GlTextureBuffer
|
||||||
// TODO: turn into a single call?
|
// TODO: turn into a single call?
|
||||||
GLuint name() const { return name_; }
|
GLuint name() const { return name_; }
|
||||||
GLenum target() const { return target_; }
|
GLenum target() const { return target_; }
|
||||||
int width() const { return width_; }
|
int width() const override { return width_; }
|
||||||
int height() const { return height_; }
|
int height() const override { return height_; }
|
||||||
GpuBufferFormat format() const { return format_; }
|
GpuBufferFormat format() const override { return format_; }
|
||||||
|
|
||||||
GlTextureView GetReadView(internal::types<GlTextureView>,
|
GlTextureView GetReadView(internal::types<GlTextureView>,
|
||||||
int plane) const override;
|
int plane) const override;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user