Skip to content

Commit e45e957

Browse files
authored
Fix some compilation warning issues (#2876)
1 parent 47c1228 commit e45e957

11 files changed

Lines changed: 63 additions & 48 deletions

File tree

.github/workflows/ci-linux.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: ./.github/actions/install-essential-dependences
2222
- uses: ./.github/actions/init-make-config
2323
with:
24-
options: --cc=gcc --cxx=g++
24+
options: --cc=gcc --cxx=g++ --werror
2525
- name: compile
2626
run: |
2727
make -j ${{env.proc_num}}
@@ -61,7 +61,7 @@ jobs:
6161
- uses: ./.github/actions/install-all-dependences
6262
- uses: ./.github/actions/init-make-config
6363
with:
64-
options: --cc=gcc --cxx=g++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer
64+
options: --cc=gcc --cxx=g++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer --werror
6565
- name: compile
6666
run: |
6767
make -j ${{env.proc_num}}
@@ -95,7 +95,7 @@ jobs:
9595
- uses: ./.github/actions/install-essential-dependences
9696
- uses: ./.github/actions/init-make-config
9797
with:
98-
options: --cc=clang --cxx=clang++
98+
options: --cc=clang --cxx=clang++ --werror
9999
- name: compile
100100
run: |
101101
make -j ${{env.proc_num}}
@@ -135,7 +135,7 @@ jobs:
135135
- uses: ./.github/actions/install-all-dependences
136136
- uses: ./.github/actions/init-make-config
137137
with:
138-
options: --cc=clang --cxx=clang++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer
138+
options: --cc=clang --cxx=clang++ --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety --with-debug-lock --with-bthread-tracer --werror
139139
- name: compile
140140
run: |
141141
make -j ${{env.proc_num}}

config_brpc.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ else
3838
LDD=ldd
3939
fi
4040

41-
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,nodebugsymbols -n 'config_brpc' -- "$@"`
41+
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,nodebugsymbols,werror -n 'config_brpc' -- "$@"`
4242
WITH_GLOG=0
4343
WITH_THRIFT=0
4444
WITH_RDMA=0
4545
WITH_MESALINK=0
4646
WITH_BTHREAD_TRACER=0
4747
BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0
4848
DEBUGSYMBOLS=-g
49+
WERROR=
4950
BRPC_DEBUG_LOCK=0
5051

5152
if [ $? != 0 ] ; then >&2 $ECHO "Terminating..."; exit 1 ; fi
@@ -74,6 +75,7 @@ while true; do
7475
--with-debug-bthread-sche-safety ) BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1; shift 1 ;;
7576
--with-debug-lock ) BRPC_DEBUG_LOCK=1; shift 1 ;;
7677
--nodebugsymbols ) DEBUGSYMBOLS=; shift 1 ;;
78+
--werror ) WERROR=-Werror; shift 1 ;;
7779
-- ) shift; break ;;
7880
* ) break ;;
7981
esac
@@ -441,6 +443,9 @@ CPPFLAGS="${CPPFLAGS} -D__const__=__unused__"
441443
if [ ! -z "$DEBUGSYMBOLS" ]; then
442444
CPPFLAGS="${CPPFLAGS} $DEBUGSYMBOLS"
443445
fi
446+
if [ ! -z "$WERROR" ]; then
447+
CPPFLAGS="${CPPFLAGS} $WERROR"
448+
fi
444449
if [ "$SYSTEM" = "Darwin" ]; then
445450
CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations -Wno-inconsistent-missing-override"
446451
version=`sw_vers -productVersion | awk -F '.' '{print $1 "." $2}'`

src/brpc/memcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class MemcacheResponse : public NonreflectableMessage<MemcacheResponse> {
196196
void Clear() override;
197197
bool IsInitialized() const PB_527_OVERRIDE;
198198

199-
size_t ByteSizeLong() const;
199+
size_t ByteSizeLong() const override;
200200
bool MergePartialFromCodedStream(
201201
::google::protobuf::io::CodedInputStream* input) PB_310_OVERRIDE;
202202
void SerializeWithCachedSizes(

src/brpc/policy/http2_rpc_protocol.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,13 @@ H2ParseResult H2StreamContext::OnData(
740740
}
741741
}
742742

743-
const int64_t acc = _deferred_window_update.fetch_add(frag_size, butil::memory_order_relaxed) + frag_size;
743+
int64_t acc = frag_size +
744+
_deferred_window_update.fetch_add(frag_size, butil::memory_order_relaxed);
745+
int64_t quota = static_cast<int64_t>(
746+
_conn_ctx->local_settings().stream_window_size /
747+
(_conn_ctx->VolatilePendingStreamSize() + 1));
744748
// Allocate the quota of the window to each stream.
745-
if (acc >= static_cast<int64_t>(_conn_ctx->local_settings().stream_window_size) / (_conn_ctx->VolatilePendingStreamSize() + 1)) {
749+
if (acc >= quota) {
746750
if (acc > _conn_ctx->local_settings().stream_window_size) {
747751
LOG(ERROR) << "Fail to satisfy the stream-level flow control policy";
748752
return MakeH2Error(H2_FLOW_CONTROL_ERROR, frame_head.stream_id);

src/brpc/policy/http_rpc_protocol.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,9 @@ void ProcessHttpRequest(InputMessageBase *msg) {
14571457
return svc->CallMethod(md, cntl, NULL, NULL, done);
14581458
}
14591459

1460-
const Server::MethodProperty* const sp =
1460+
const Server::MethodProperty* const mp =
14611461
FindMethodPropertyByURI(path, server, &req_header._unresolved_path);
1462-
if (NULL == sp) {
1462+
if (NULL == mp) {
14631463
if (security_mode) {
14641464
std::string escape_path;
14651465
WebEscape(path, &escape_path);
@@ -1468,36 +1468,36 @@ void ProcessHttpRequest(InputMessageBase *msg) {
14681468
cntl->SetFailed(ENOMETHOD, "Fail to find method on `%s'", path.c_str());
14691469
}
14701470
return;
1471-
} else if (sp->service->GetDescriptor() == BadMethodService::descriptor()) {
1471+
} else if (mp->service->GetDescriptor() == BadMethodService::descriptor()) {
14721472
BadMethodRequest breq;
14731473
BadMethodResponse bres;
14741474
butil::StringSplitter split(path.c_str(), '/');
14751475
breq.set_service_name(std::string(split.field(), split.length()));
1476-
sp->service->CallMethod(sp->method, cntl, &breq, &bres, NULL);
1476+
mp->service->CallMethod(mp->method, cntl, &breq, &bres, NULL);
14771477
return;
14781478
}
14791479
// Switch to service-specific error.
14801480
non_service_error.release();
1481-
MethodStatus* method_status = sp->status;
1481+
MethodStatus* method_status = mp->status;
14821482
resp_sender.set_method_status(method_status);
14831483
if (method_status) {
14841484
int rejected_cc = 0;
14851485
if (!method_status->OnRequested(&rejected_cc)) {
14861486
cntl->SetFailed(ELIMIT, "Rejected by %s's ConcurrencyLimiter, concurrency=%d",
1487-
sp->method->full_name().c_str(), rejected_cc);
1487+
mp->method->full_name().c_str(), rejected_cc);
14881488
return;
14891489
}
14901490
}
14911491

14921492
if (span) {
1493-
span->ResetServerSpanName(sp->method->full_name());
1493+
span->ResetServerSpanName(mp->method->full_name());
14941494
}
14951495
// NOTE: accesses to builtin services are not counted as part of
14961496
// concurrency, therefore are not limited by ServerOptions.max_concurrency.
1497-
if (!sp->is_builtin_service && !sp->params.is_tabbed) {
1497+
if (!mp->is_builtin_service && !mp->params.is_tabbed) {
14981498
if (socket->is_overcrowded() &&
14991499
!server->options().ignore_eovercrowded &&
1500-
!sp->ignore_eovercrowded) {
1500+
!mp->ignore_eovercrowded) {
15011501
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
15021502
butil::endpoint2str(socket->remote_side()).c_str());
15031503
return;
@@ -1522,8 +1522,8 @@ void ProcessHttpRequest(InputMessageBase *msg) {
15221522
return;
15231523
}
15241524

1525-
google::protobuf::Service* svc = sp->service;
1526-
const google::protobuf::MethodDescriptor* method = sp->method;
1525+
google::protobuf::Service* svc = mp->service;
1526+
const google::protobuf::MethodDescriptor* method = mp->method;
15271527
accessor.set_method(method);
15281528
RpcPBMessages* messages = server->options().rpc_pb_message_factory->Get(*svc, *method);;
15291529
resp_sender.set_messages(messages);
@@ -1535,7 +1535,7 @@ void ProcessHttpRequest(InputMessageBase *msg) {
15351535
cntl->SetFailed("Fail to new req or res");
15361536
return;
15371537
}
1538-
if (sp->params.allow_http_body_to_pb &&
1538+
if (mp->params.allow_http_body_to_pb &&
15391539
method->input_type()->field_count() > 0) {
15401540
// A protobuf service. No matter if Content-type is set to
15411541
// applcation/json or body is empty, we have to treat body as a json
@@ -1604,10 +1604,10 @@ void ProcessHttpRequest(InputMessageBase *msg) {
16041604
butil::IOBufAsZeroCopyInputStream wrapper(req_body);
16051605
std::string err;
16061606
json2pb::Json2PbOptions options;
1607-
options.base64_to_bytes = sp->params.pb_bytes_to_base64;
1608-
options.array_to_single_repeated = sp->params.pb_single_repeated_to_array;
1609-
cntl->set_pb_bytes_to_base64(sp->params.pb_bytes_to_base64);
1610-
cntl->set_pb_single_repeated_to_array(sp->params.pb_single_repeated_to_array);
1607+
options.base64_to_bytes = mp->params.pb_bytes_to_base64;
1608+
options.array_to_single_repeated = mp->params.pb_single_repeated_to_array;
1609+
cntl->set_pb_bytes_to_base64(mp->params.pb_bytes_to_base64);
1610+
cntl->set_pb_single_repeated_to_array(mp->params.pb_single_repeated_to_array);
16111611
if (!json2pb::JsonToProtoMessage(&wrapper, req, options, &err)) {
16121612
cntl->SetFailed(EREQUEST, "Fail to parse http body as %s, %s",
16131613
req->GetDescriptor()->full_name().c_str(), err.c_str());

src/brpc/rdma/block_pool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static RegisterCallback g_cb = NULL;
4646
static const size_t BYTES_IN_MB = 1048576;
4747

4848
static const int BLOCK_DEFAULT = 0; // 8KB
49-
static const int BLOCK_LARGE = 1; // 64KB
50-
static const int BLOCK_HUGE = 2; // 2MB
49+
// static const int BLOCK_LARGE = 1; // 64KB
50+
// static const int BLOCK_HUGE = 2; // 2MB
5151
static const int BLOCK_SIZE_COUNT = 3;
5252
static size_t g_block_size[BLOCK_SIZE_COUNT] = { 8192, 65536, 2 * BYTES_IN_MB };
5353

src/brpc/rdma/rdma_endpoint.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ DEFINE_bool(rdma_trace_verbose, false, "Print log message verbosely");
6060
BRPC_VALIDATE_GFLAG(rdma_trace_verbose, brpc::PassValidate);
6161

6262
static const size_t IOBUF_BLOCK_HEADER_LEN = 32; // implementation-dependent
63-
static const size_t IOBUF_BLOCK_DEFAULT_PAYLOAD =
64-
butil::IOBuf::DEFAULT_BLOCK_SIZE - IOBUF_BLOCK_HEADER_LEN;
6563

6664
// DO NOT change this value unless you know the safe value!!!
6765
// This is the number of reserved WRs in SQ/RQ for pure ACK.
@@ -79,14 +77,14 @@ static const size_t RESERVED_WR_NUM = 3;
7977
static const char* MAGIC_STR = "RDMA";
8078
static const size_t MAGIC_STR_LEN = 4;
8179
static const size_t HELLO_MSG_LEN_MIN = 40;
82-
static const size_t HELLO_MSG_LEN_MAX = 4096;
80+
// static const size_t HELLO_MSG_LEN_MAX = 4096;
8381
static const size_t ACK_MSG_LEN = 4;
8482
static uint16_t g_rdma_hello_msg_len = 40; // In Byte
8583
static uint16_t g_rdma_hello_version = 2;
8684
static uint16_t g_rdma_impl_version = 1;
8785
static uint32_t g_rdma_recv_block_size = 0;
8886

89-
static const uint32_t MAX_INLINE_DATA = 64;
87+
// static const uint32_t MAX_INLINE_DATA = 64;
9088
static const uint8_t MAX_HOP_LIMIT = 16;
9189
static const uint8_t TIMEOUT = 14;
9290
static const uint8_t RETRY_CNT = 7;
@@ -1021,7 +1019,7 @@ int RdmaEndpoint::PostRecv(uint32_t num, bool zerocopy) {
10211019
PLOG(WARNING) << "Fail to allocate rbuf";
10221020
return -1;
10231021
} else {
1024-
CHECK(size == g_rdma_recv_block_size) << size;
1022+
CHECK(static_cast<uint32_t>(size) == g_rdma_recv_block_size) << size;
10251023
}
10261024
}
10271025
if (DoPostRecv(_rbuf_data[_rq_received], g_rdma_recv_block_size) < 0) {

src/brpc/rdma/rdma_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ DEFINE_string(rdma_device, "", "The name of the HCA device used "
9494
DEFINE_int32(rdma_port, 1, "The port number to use. For RoCE, it is always 1.");
9595
DEFINE_int32(rdma_gid_index, -1, "The GID index to use. -1 means using the last one.");
9696

97-
static const size_t SYSFS_SIZE = 4096;
97+
// static const size_t SYSFS_SIZE = 4096;
9898
static ibv_device** g_devices = NULL;
9999
static ibv_context* g_context = NULL;
100100
static SocketId g_async_socket;

src/brpc/thrift_message.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ friend class ThriftStub;
8181
void Swap(ThriftFramedMessage* other);
8282

8383
// implements Message ----------------------------------------------
84-
void MergeFrom(const ThriftFramedMessage& from);
84+
void MergeFrom(const ThriftFramedMessage& from) override;
8585
void Clear() override;
8686

8787
size_t ByteSizeLong() const override;

src/bthread/task_group.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ void print_task(std::ostream& os, bthread_t tid) {
999999
bthread_attr_t attr = BTHREAD_ATTR_NORMAL;
10001000
bool has_tls = false;
10011001
int64_t cpuwide_start_ns = 0;
1002-
TaskStatistics stat = {0, 0};
1002+
TaskStatistics stat = {0, 0, 0};
10031003
TaskStatus status = TASK_STATUS_UNKNOWN;
10041004
bool traced = false;
10051005
pid_t worker_tid = 0;

0 commit comments

Comments
 (0)