diff options
author | babenko <babenko@yandex-team.com> | 2024-11-17 01:15:03 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-11-17 01:25:12 +0300 |
commit | 9044a0812901c578f1349a9dca314d714caae96c (patch) | |
tree | 8b54628b8d7f86c8c0fceab184199b135c61b8a1 | |
parent | 4b61178f9dabd9b41ceccc021ee0aab9e0e54c3e (diff) | |
download | ydb-9044a0812901c578f1349a9dca314d714caae96c.tar.gz |
YT-22885: FromProto -> CheckedEnumCast for enums
commit_hash:6cd1ed86ea24329ed43cda7c28b2c42c55e868c7
-rw-r--r-- | yt/yt/core/misc/protobuf_helpers-inl.h | 6 | ||||
-rw-r--r-- | yt/yt/core/rpc/response_keeper.cpp | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/yt/yt/core/misc/protobuf_helpers-inl.h b/yt/yt/core/misc/protobuf_helpers-inl.h index d603aa3fce..39cf53d165 100644 --- a/yt/yt/core/misc/protobuf_helpers-inl.h +++ b/yt/yt/core/misc/protobuf_helpers-inl.h @@ -10,6 +10,8 @@ #include <library/cpp/yt/assert/assert.h> +#include <library/cpp/yt/misc/cast.h> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -203,7 +205,7 @@ template <class T> requires TEnumTraits<T>::IsEnum && (!TEnumTraits<T>::IsBitEnum) void FromProto(T* original, int serialized) { - *original = static_cast<T>(serialized); + *original = CheckedEnumCast<T>(serialized); } template <class T> @@ -217,7 +219,7 @@ template <class T> requires TEnumTraits<T>::IsBitEnum void FromProto(T* original, ui64 serialized) { - *original = static_cast<T>(serialized); + *original = CheckedEnumCast<T>(serialized); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/rpc/response_keeper.cpp b/yt/yt/core/rpc/response_keeper.cpp index 2e1891bea4..f354c67590 100644 --- a/yt/yt/core/rpc/response_keeper.cpp +++ b/yt/yt/core/rpc/response_keeper.cpp @@ -380,7 +380,7 @@ bool ValidateHeaderAndParseRememberOption(const TSharedRefArray& responseMessage { NProto::TResponseHeader header; YT_VERIFY(TryParseResponseHeader(responseMessage, &header)); - return FromProto<EErrorCode>(header.error().code()) != EErrorCode::Unavailable; + return header.error().code() != ToUnderlying(EErrorCode::Unavailable); } void ValidateRetry(TMutationId mutationId, bool isRetry) |