Skip to content

Commit

Permalink
fix several warnings under MAC
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesge committed Feb 10, 2020
1 parent 7431024 commit f8c188a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions test/brpc_http_rpc_protocol_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ TEST_F(HttpTest, http2_header_after_data) {
}
{
brpc::HPacker::Header header("content-length",
butil::string_printf("%" PRIu64, data_buf.size()));
butil::string_printf("%llu", (unsigned long long)data_buf.size()));
hpacker.Encode(&header1_appender, header, options);
}
{
Expand Down Expand Up @@ -1436,7 +1436,7 @@ TEST_F(HttpTest, http2_handle_goaway_streams) {
SerializeFrameHead(goawaybuf, 8, brpc::policy::H2_FRAME_GOAWAY, 0, 0);
SaveUint32(goawaybuf + brpc::policy::FRAME_HEAD_SIZE, 0);
SaveUint32(goawaybuf + brpc::policy::FRAME_HEAD_SIZE + 4, 0);
ASSERT_EQ(brpc::policy::FRAME_HEAD_SIZE + 8, ::write(servfd, goawaybuf, brpc::policy::FRAME_HEAD_SIZE + 8));
ASSERT_EQ((ssize_t)brpc::policy::FRAME_HEAD_SIZE + 8, ::write(servfd, goawaybuf, brpc::policy::FRAME_HEAD_SIZE + 8));

// After receving GOAWAY, the callbacks in client should be run correctly.
for (int i = 0; i < req_size; i++) {
Expand Down
6 changes: 3 additions & 3 deletions test/brpc_uri_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(URITest, only_host) {
ASSERT_EQ("", uri.path());
ASSERT_EQ("", uri.user_info());
ASSERT_EQ("", uri.fragment());
ASSERT_EQ(2, uri.QueryCount());
ASSERT_EQ(2u, uri.QueryCount());
ASSERT_TRUE(uri.GetQuery("wd"));
ASSERT_EQ(*uri.GetQuery("wd"), "uri2");
ASSERT_TRUE(uri.GetQuery("nonkey"));
Expand All @@ -77,7 +77,7 @@ TEST(URITest, only_host) {
ASSERT_EQ("", uri.path());
ASSERT_EQ("", uri.user_info());
ASSERT_EQ("", uri.fragment());
ASSERT_EQ(0, uri.QueryCount());
ASSERT_EQ(0u, uri.QueryCount());

ASSERT_EQ(0, uri.SetHttpURL(" www.baidu4.com "));
ASSERT_EQ("", uri.scheme());
Expand All @@ -86,7 +86,7 @@ TEST(URITest, only_host) {
ASSERT_EQ("", uri.path());
ASSERT_EQ("", uri.user_info());
ASSERT_EQ("", uri.fragment());
ASSERT_EQ(0, uri.QueryCount());
ASSERT_EQ(0u, uri.QueryCount());
}

TEST(URITest, no_scheme) {
Expand Down
2 changes: 1 addition & 1 deletion test/endpoint_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST(EndPointTest, flat_map) {
butil::BucketInfo info = m.bucket_info();
LOG(INFO) << "bucket info max long=" << info.longest_length
<< " avg=" << info.average_length << std::endl;
ASSERT_LT(info.longest_length, 32) << "detect hash collision and it's too large.";
ASSERT_LT(info.longest_length, 32ul) << "detect hash collision and it's too large.";
}

} // end of namespace
10 changes: 5 additions & 5 deletions test/iobuf_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ TEST_F(IOBufTest, cut_into_fd_with_offset_multithreaded) {
for (int i = 0; i < number_per_thread * (int)ARRAY_SIZE(threads); ++i) {
off_t offset = i * sizeof(int);
butil::IOPortal in;
ASSERT_EQ(sizeof(int), in.pappend_from_file_descriptor(fd, offset, sizeof(int)));
ASSERT_EQ((ssize_t)sizeof(int), in.pappend_from_file_descriptor(fd, offset, sizeof(int)));
int j;
ASSERT_EQ(sizeof(j), in.cutn(&j, sizeof(j)));
ASSERT_EQ(i, j);
Expand Down Expand Up @@ -1586,7 +1586,7 @@ static void my_free(void* m) {
TEST_F(IOBufTest, append_user_data_and_consume) {
butil::IOBuf b0;
const int REP = 16;
const int len = REP * 256;
const size_t len = REP * 256;
char* data = (char*)malloc(len);
for (int i = 0; i < 256; ++i) {
for (int j = 0; j < REP; ++j) {
Expand Down Expand Up @@ -1616,7 +1616,7 @@ TEST_F(IOBufTest, append_user_data_and_consume) {
TEST_F(IOBufTest, append_user_data_and_share) {
butil::IOBuf b0;
const int REP = 16;
const int len = REP * 256;
const size_t len = REP * 256;
char* data = (char*)malloc(len);
for (int i = 0; i < 256; ++i) {
for (int j = 0; j < REP; ++j) {
Expand All @@ -1633,7 +1633,7 @@ TEST_F(IOBufTest, append_user_data_and_share) {
{
butil::IOBuf bufs[256];
for (int i = 0; i < 256; ++i) {
ASSERT_EQ(REP, b0.cutn(&bufs[i], REP));
ASSERT_EQ((size_t)REP, b0.cutn(&bufs[i], REP));
ASSERT_EQ(len - (i+1) * REP, b0.size());
if (i != 255) {
ASSERT_EQ(1UL, b0._ref_num());
Expand All @@ -1647,7 +1647,7 @@ TEST_F(IOBufTest, append_user_data_and_share) {
ASSERT_EQ(NULL, my_free_params);
for (int i = 0; i < 256; ++i) {
std::string out = bufs[i].to_string();
ASSERT_EQ(REP, out.size());
ASSERT_EQ((size_t)REP, out.size());
for (int j = 0; j < REP; ++j) {
ASSERT_EQ((char)i, out[j]);
}
Expand Down
12 changes: 6 additions & 6 deletions test/object_pool_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ TEST_F(ObjectPoolTest, get_int) {
*(new int) = i;
}
tm.stop();
printf("new a int takes %luns\n", tm.n_elapsed()/N);
printf("new a int takes %" PRId64 "ns\n", tm.n_elapsed()/N);

std::cout << describe_objects<int>() << std::endl;
clear_objects<int>();
Expand Down Expand Up @@ -220,15 +220,15 @@ TEST_F(ObjectPoolTest, get_perf) {
get_object<SilentObj>();
}
tm1.stop();
printf("get a SilentObj takes %luns\n", tm1.n_elapsed()/N);
printf("get a SilentObj takes %" PRId64 "ns\n", tm1.n_elapsed()/N);
//clear_objects<SilentObj>(); // free all blocks

tm2.start();
for (size_t i = 0; i < N; ++i) {
new_list.push_back(new SilentObj);
}
tm2.stop();
printf("new a SilentObj takes %luns\n", tm2.n_elapsed()/N);
printf("new a SilentObj takes %" PRId64 "ns\n", tm2.n_elapsed()/N);
for (size_t i = 0; i < new_list.size(); ++i) {
delete new_list[i];
}
Expand All @@ -254,7 +254,7 @@ void* get_and_return_int(void*) {
return_object(get_object<D>());
tm0.stop();

printf("[%lu] warmup=%lu\n", pthread_self(), tm0.n_elapsed());
printf("[%lu] warmup=%" PRId64 "\n", (size_t)pthread_self(), tm0.n_elapsed());

for (int j = 0; j < 5; ++j) {
v.clear();
Expand All @@ -281,7 +281,7 @@ void* get_and_return_int(void*) {
}

printf("[%lu:%d] get<D>=%.1f return<D>=%.1f\n",
pthread_self(), j, tm1.n_elapsed()/(double)N,
(size_t)pthread_self(), j, tm1.n_elapsed()/(double)N,
tm2.n_elapsed()/(double)N);
}
return NULL;
Expand Down Expand Up @@ -317,7 +317,7 @@ void* new_and_delete_int(void*) {
tm2.stop();

printf("[%lu:%d] new<D>=%.1f delete<D>=%.1f\n",
pthread_self(), j, tm1.n_elapsed()/(double)N,
(size_t)pthread_self(), j, tm1.n_elapsed()/(double)N,
tm2.n_elapsed()/(double)N);
}

Expand Down
2 changes: 1 addition & 1 deletion test/recordio_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ TEST(RecordIOTest, write_read_random) {
}
ASSERT_EQ((int)butil::RecordReader::END_OF_READER, rr.last_error());
ASSERT_EQ(j, name_value_list.size());
ASSERT_LE(str.size() - rr.offset(), 3);
ASSERT_LE(str.size() - rr.offset(), 3u);
}

} // namespace

0 comments on commit f8c188a

Please sign in to comment.