Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build warning, ByteSize() is deprecated, use ByteSizeLong() instead #1723

Merged
merged 4 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/brpc/policy/baidu_rpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ DEFINE_bool(baidu_protocol_use_fullname, true,
// 5. Not supported: chunk_info

// Pack header into `buf'
inline void PackRpcHeader(char* rpc_header, int meta_size, int payload_size) {
inline void PackRpcHeader(char* rpc_header, uint32_t meta_size, int payload_size) {
uint32_t* dummy = (uint32_t*)rpc_header; // suppress strict-alias warning
*dummy = *(uint32_t*)"PRPC";
butil::RawPacker(rpc_header + 4)
Expand All @@ -69,7 +69,11 @@ inline void PackRpcHeader(char* rpc_header, int meta_size, int payload_size) {

static void SerializeRpcHeaderAndMeta(
butil::IOBuf* out, const RpcMeta& meta, int payload_size) {
#if GOOGLE_PROTOBUF_VERSION >= 3010000
const uint32_t meta_size = meta.ByteSizeLong();
#else
const int meta_size = meta.ByteSize();
#endif
if (meta_size <= 244) { // most common cases
char header_and_meta[12 + meta_size];
PackRpcHeader(header_and_meta, meta_size, payload_size);
Expand Down
6 changes: 5 additions & 1 deletion src/brpc/policy/hulu_pbrpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class HuluRawUnpacker {
const char* _stream;
};

inline void PackHuluHeader(char* hulu_header, int meta_size, int body_size) {
inline void PackHuluHeader(char* hulu_header, uint32_t meta_size, int body_size) {
uint32_t* dummy = reinterpret_cast<uint32_t*>(hulu_header); // suppress strict-alias warning
*dummy = *reinterpret_cast<const uint32_t*>("HULU");
HuluRawPacker rp(hulu_header + 4);
Expand All @@ -152,7 +152,11 @@ inline void PackHuluHeader(char* hulu_header, int meta_size, int body_size) {
template <typename Meta>
static void SerializeHuluHeaderAndMeta(
butil::IOBuf* out, const Meta& meta, int payload_size) {
#if GOOGLE_PROTOBUF_VERSION >= 3010000
yangzhg marked this conversation as resolved.
Show resolved Hide resolved
const uint32_t meta_size = meta.ByteSizeLong();
#else
const int meta_size = meta.ByteSize();
#endif
if (meta_size <= 244) { // most common cases
char header_and_meta[12 + meta_size];
PackHuluHeader(header_and_meta, meta_size, payload_size);
Expand Down
4 changes: 4 additions & 0 deletions src/brpc/policy/public_pbrpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ void PackPublicPbrpcRequest(butil::IOBuf* buf,
nshead.magic_num = NSHEAD_MAGICNUM;
snprintf(nshead.provider, sizeof(nshead.provider), "%s", PROVIDER);
nshead.version = NSHEAD_VERSION;
#if GOOGLE_PROTOBUF_VERSION >= 3010000
nshead.body_len = pbreq.ByteSizeLong();
#else
nshead.body_len = pbreq.ByteSize();
#endif
buf->append(&nshead, sizeof(nshead));

Span* span = ControllerPrivateAccessor(controller).span();
Expand Down
6 changes: 5 additions & 1 deletion src/brpc/policy/sofa_pbrpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class SofaRawUnpacker {
const char* _stream;
};

inline void PackSofaHeader(char* sofa_header, int meta_size, int body_size) {
inline void PackSofaHeader(char* sofa_header, uint32_t meta_size, int body_size) {
uint32_t* dummy = reinterpret_cast<uint32_t*>(sofa_header); // suppress strict-alias warning
*dummy = *reinterpret_cast<const uint32_t*>("SOFA");

Expand All @@ -139,7 +139,11 @@ inline void PackSofaHeader(char* sofa_header, int meta_size, int body_size) {

static void SerializeSofaHeaderAndMeta(
butil::IOBuf* out, const SofaRpcMeta& meta, int payload_size) {
#if GOOGLE_PROTOBUF_VERSION >= 3010000
const uint32_t meta_size = meta.ByteSizeLong();
#else
const int meta_size = meta.ByteSize();
#endif
if (meta_size <= 232) { // most common cases
char header_and_meta[24 + meta_size];
PackSofaHeader(header_and_meta, meta_size, payload_size);
Expand Down
4 changes: 4 additions & 0 deletions src/brpc/policy/streaming_rpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ void PackStreamMessage(butil::IOBuf* out,
const StreamFrameMeta &fm,
const butil::IOBuf *data) {
const uint32_t data_length = data ? data->length() : 0;
#if GOOGLE_PROTOBUF_VERSION >= 3010000
const uint32_t meta_length = fm.ByteSizeLong();
#else
const uint32_t meta_length = fm.ByteSize();
#endif
char head[12];
uint32_t* dummy = (uint32_t*)head; // suppresses strict-alias warning
*(uint32_t*)dummy = *(const uint32_t*)"STRM";
Expand Down