Browse Source

fix warnings on MACOS

jamesge 4 years ago
parent
commit
9f510165bc

+ 2 - 1
CMakeLists.txt

@@ -101,9 +101,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     if(NOT HAVE_CLOCK_GETTIME)
         set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
     endif()
+    set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wno-deprecated-declarations -Wno-inconsistent-missing-override")
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
+set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
 if(WITH_MESALINK)
     set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DUSE_MESALINK")
 endif()

+ 1 - 1
config_brpc.sh

@@ -319,7 +319,7 @@ if [ ! -z "$DEBUGSYMBOLS" ]; then
     CPPFLAGS="${CPPFLAGS} $DEBUGSYMBOLS"
 fi
 if [ "$SYSTEM" = "Darwin" ]; then
-    CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations"
+    CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations -Wno-inconsistent-missing-override"
     version=`sw_vers -productVersion | awk -F '.' '{print $1 "." $2}'`
     if [[ `echo "$version<10.12" | bc -l` == 1 ]]; then
         CPPFLAGS="${CPPFLAGS} -DNO_CLOCK_GETTIME_IN_MAC"

+ 1 - 1
src/brpc/builtin/hotspots_service.cpp

@@ -103,7 +103,7 @@ static std::string GeneratePerlScriptPath(const std::string& filename) {
     path += FLAGS_rpc_profiling_dir;
     path.push_back('/');
     path += filename;
-    return std::move(path);
+    return path;
 }
 
 extern bool cpu_profiler_enabled;

+ 1 - 1
src/brpc/policy/http_rpc_protocol.cpp

@@ -583,7 +583,7 @@ void SerializeHttpRequest(butil::IOBuf* /*not used*/,
             hreq.SetHeader(common->TE, common->TRAILERS);
             if (cntl->timeout_ms() >= 0) {
                 hreq.SetHeader(common->GRPC_TIMEOUT,
-                        butil::string_printf("%ldm", cntl->timeout_ms()));
+                        butil::string_printf("%" PRId64, cntl->timeout_ms()));
             }
             // Append compressed and length before body
             AddGrpcPrefix(&cntl->request_attachment(), grpc_compressed);

+ 1 - 1
src/brpc/redis.h

@@ -240,7 +240,7 @@ enum RedisCommandHandlerResult {
 // The Command handler for a redis request. User should impletement Run().
 class RedisCommandHandler {
 public:
-    ~RedisCommandHandler() {}
+    virtual ~RedisCommandHandler() {}
 
     // Once Server receives commands, it will first find the corresponding handlers and
     // call them sequentially(one by one) according to the order that requests arrive,

+ 2 - 1
src/brpc/rpc_dump.h

@@ -47,7 +47,8 @@ DECLARE_bool(rpc_dump);
 // In practice, sampled requests are just small fraction of all requests.
 // The overhead of sampling should be negligible for overall performance.
 
-struct SampledRequest : public bvar::Collected {
+class SampledRequest : public bvar::Collected {
+public:
     butil::IOBuf request;
     RpcDumpMeta meta;
 

+ 1 - 1
src/bthread/fd.cpp

@@ -434,7 +434,7 @@ short epoll_to_poll_events(uint32_t epoll_events) {
     return poll_events;
 }
 #elif defined(OS_MACOSX)
-short kqueue_to_poll_events(uint32_t kqueue_events) {
+static short kqueue_to_poll_events(int kqueue_events) {
     //TODO: add more values?
     short poll_events = 0;
     if (kqueue_events == EVFILT_READ) {

+ 2 - 2
src/butil/binary_printer.cpp

@@ -106,7 +106,7 @@ static void PrintIOBuf(Appender* appender, const IOBuf& b, size_t max_length) {
                 printer.Flush();
                 char buf[48];
                 int len = snprintf(buf, sizeof(buf), "...<skipping %" PRIu64 " bytes>",
-                         b.size() - nw);
+                        (uint64_t)(b.size() - nw));
                 appender->Append(buf, len);
                 return;
             }
@@ -124,7 +124,7 @@ static void PrintString(Appender* appender, const StringPiece& s, size_t max_len
             printer.Flush();
             char buf[48];
             int len = snprintf(buf, sizeof(buf), "...<skipping %" PRIu64 " bytes>",
-                               s.size() - i);
+                               (uint64_t)(s.size() - i));
             appender->Append(buf, len);
             return;
         }

+ 0 - 1
src/bvar/detail/sampler.cpp

@@ -111,7 +111,6 @@ private:
 private:
     bool _created;
     bool _stop;
-    pid_t _created_pid;
     int64_t _cumulated_time_us;
     pthread_t _tid;
 };

+ 0 - 3
tools/CMakeLists.txt

@@ -15,9 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -D__STRICT_ANSI__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
-use_cxx11()
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin)
 
 add_subdirectory(parallel_http)