From d2c3be8728a4b1baca206f837fadd6a63b84921c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 10 Feb 2017 17:19:46 +0200 Subject: [PATCH] Fix compiler flag usage The compiler flags overwrote the default values that CMake generates instead of appending to them. --- CMakeLists.txt | 28 ++++++------------- include/maxscale/debug.h | 2 +- server/core/log_manager.cc | 3 +- server/modules/routing/avrorouter/avro_file.c | 12 ++------ 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f199135f..c97c221a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,16 +146,6 @@ if(CMAKE_VERSION VERSION_GREATER 2.6) endif() endif() - -IF(DEFINED OLEVEL) - if((OLEVEL GREATER -1) AND (OLEVEL LESS 4) ) - set(FLAGS "${FLAGS} -O${OLEVEL}" CACHE STRING "Compilation flags" FORCE) - message(STATUS "Optimization level at: ${OLEVEL}") - else() - message(WARNING "Optimization level was set to a bad value, ignoring it. (Valid values are 0-3)") - endif() -endif() - if(GCOV) set(FLAGS "${FLAGS} -fprofile-arcs -ftest-coverage" CACHE STRING "Compilation flags" FORCE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") @@ -168,19 +158,19 @@ endif() if(USE_C99) message(STATUS "Using C99 standard") - set(CMAKE_C_FLAGS "-std=c99 -D_GNU_SOURCE=1 ${FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -D_GNU_SOURCE=1 ${FLAGS}") else() - set(CMAKE_C_FLAGS "${FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}") endif() -set(CMAKE_C_FLAGS_DEBUG "${DEBUG_FLAGS} -DSS_DEBUG -DLOG_ASSERT") -set(CMAKE_C_FLAGS_RELEASE "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-ggdb") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS} -DSS_DEBUG -DLOG_ASSERT") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-uninitialized") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb -Wno-uninitialized") -set(CMAKE_CXX_FLAGS "${FLAGS} -Wno-deprecated-declarations") -set(CMAKE_CXX_FLAGS_DEBUG "${DEBUG_FLAGS} -DSS_DEBUG -DLOG_ASSERT -Wno-deprecated-declarations") -set(CMAKE_CXX_FLAGS_RELEASE "-Wno-deprecated-declarations") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-ggdb -Wno-deprecated-declarations") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS} -Wno-deprecated-declarations") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS} -DSS_DEBUG -DLOG_ASSERT -Wno-deprecated-declarations") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-deprecated-declarations -Wno-uninitialized") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ggdb -Wno-deprecated-declarations -Wno-uninitialized") include_directories(include) include_directories(server/inih) diff --git a/include/maxscale/debug.h b/include/maxscale/debug.h index 21cf887d3..31c9dd1ec 100644 --- a/include/maxscale/debug.h +++ b/include/maxscale/debug.h @@ -264,7 +264,7 @@ typedef enum skygw_chk_t (SERVER_IS_SLAVE(s) ? "RUNNING SLAVE" : \ (SERVER_IS_JOINED(s) ? "RUNNING JOINED" : \ (SERVER_IS_NDB(s) ? "RUNNING NDB" : \ - ((SERVER_IS_RUNNING(s) && SERVER_IN_MAINT(s)) ? "RUNNING MAINTENANCE" : \ + ((!SERVER_IS_DOWN(s) && SERVER_IN_MAINT(s)) ? "RUNNING MAINTENANCE" : \ (SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \ (SERVER_IS_RUNNING(s) ? "RUNNING (only)" : \ (SERVER_IS_DOWN(s) ? "DOWN" : "UNKNOWN STATUS")))))))) diff --git a/server/core/log_manager.cc b/server/core/log_manager.cc index 1c6903acf..bb6f85467 100644 --- a/server/core/log_manager.cc +++ b/server/core/log_manager.cc @@ -3020,7 +3020,8 @@ int mxs_log_message(int priority, assert(!true); } - assert(len == augmentation_len); + (void)len; + ss_dassert(len == augmentation_len); } va_start(valist, format); diff --git a/server/modules/routing/avrorouter/avro_file.c b/server/modules/routing/avrorouter/avro_file.c index 324aa2c0d..db542697d 100644 --- a/server/modules/routing/avrorouter/avro_file.c +++ b/server/modules/routing/avrorouter/avro_file.c @@ -630,7 +630,6 @@ avro_binlog_end_t avro_read_all_events(AVRO_INSTANCE *router) { int event_header_length; int event_header_ntypes; - int n_events; /** Extract the event header lengths */ event_header_length = ptr[2 + 50 + 4]; @@ -653,15 +652,10 @@ avro_binlog_end_t avro_read_all_events(AVRO_INSTANCE *router) break; } - n_events = hdr.event_size - event_header_length - (2 + 50 + 4 + 1); - - if (event_header_ntypes < n_events) + uint8_t *checksum = ptr + hdr.event_size - event_header_length - event_header_ntypes; + if (checksum[0] == 1) { - uint8_t *checksum = ptr + hdr.event_size - event_header_length - event_header_ntypes; - if (checksum[0] == 1) - { - found_chksum = true; - } + found_chksum = true; } } /* Decode CLOSE/STOP Event */