From a0bdac718950038906267bd65fe85d3f9b92bc18 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 12 Oct 2023 17:21:46 +0800 Subject: [PATCH] fix linux x64 build warning --- unit-test/rpc/test_async_rpc.cpp | 13 +++++++++---- util/include/util/tc_logger.h | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/unit-test/rpc/test_async_rpc.cpp b/unit-test/rpc/test_async_rpc.cpp index 8478a5c3..aacd0367 100755 --- a/unit-test/rpc/test_async_rpc.cpp +++ b/unit-test/rpc/test_async_rpc.cpp @@ -1,15 +1,20 @@  #include "hello_test.h" + TEST_F(HelloTest, rpcASyncGlobalCommunicator) { cout << TC_Thread::CURRENT_THREADID() << endl; - shared_ptr c = getCommunicator(); + { + shared_ptr c = getCommunicator(); - transGlobalCommunicator([&](Communicator *comm){ - checkASync(comm); - }, c.get()); + transGlobalCommunicator([&](Communicator *comm) { + checkASync(comm); + }, c.get()); + } + + cout << getFdCounts() << endl; } diff --git a/util/include/util/tc_logger.h b/util/include/util/tc_logger.h index 5bd6e97f..41c1711d 100644 --- a/util/include/util/tc_logger.h +++ b/util/include/util/tc_logger.h @@ -944,7 +944,11 @@ namespace tars if (hasFlag(TC_Logger::HAS_PID)) { - n += snprintf(c + n, len - n, "%lld%s", TC_Thread::CURRENT_THREADID(), _sSepar.c_str()); +#if __WORDSIZE == 64 + n += snprintf(c + n, len - n, "%ld%s", TC_Thread::CURRENT_THREADID(), _sSepar.c_str()); +#else + n += snprintf(c + n, len - n, "%lld%s", TC_Thread::CURRENT_THREADID(), _sSepar.c_str()); +#endif } if (hasFlag(TC_Logger::HAS_LEVEL))