Ver código fonte

fix several warnings under MAC

jamesge 4 anos atrás
pai
commit
f8c188a7a5

+ 2 - 2
test/brpc_http_rpc_protocol_unittest.cpp

@@ -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);
         }
         {
@@ -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++) {

+ 3 - 3
test/brpc_uri_unittest.cpp

@@ -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"));
@@ -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());
@@ -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) {

+ 1 - 1
test/endpoint_unittest.cpp

@@ -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

+ 5 - 5
test/iobuf_unittest.cpp

@@ -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);
@@ -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) {
@@ -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) {
@@ -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());
@@ -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]);
             }

+ 6 - 6
test/object_pool_unittest.cpp

@@ -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>();
@@ -220,7 +220,7 @@ 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();
@@ -228,7 +228,7 @@ TEST_F(ObjectPoolTest, get_perf) {
             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];
         }
@@ -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();
@@ -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;
@@ -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);
     }
     

+ 1 - 1
test/recordio_unittest.cpp

@@ -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