diff --git a/CMakeLists.txt b/CMakeLists.txt index 97fac89f..178999cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) - SET(GCC_FLAGS -Wunused -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement) + SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement) FOREACH(GCC_FLAG ${GCC_FLAGS}) CHECK_C_COMPILER_FLAG("${GCC_FLAG}" HAS_${GCC_FLAG}_FLAG) IF(${HAS_${GCC_FLAG}_FLAG}) diff --git a/include/ma_config.h.in b/include/ma_config.h.in index 60fb77b7..c25662fa 100644 --- a/include/ma_config.h.in +++ b/include/ma_config.h.in @@ -163,103 +163,103 @@ */ /* Types we may use */ #cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@ -#if SIZEOF_CHAR +#if defined(SIZEOF_CHAR) # define HAVE_CHAR 1 #endif #cmakedefine SIZEOF_CHARP @SIZEOF_CHARP@ -#if SIZEOF_CHARP +#if defined(SIZEOF_CHARP) # define HAVE_CHARP 1 #endif #cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@ -#if SIZEOF_SHORT +#if defined(SIZEOF_SHORT) # define HAVE_SHORT 1 #endif #cmakedefine SIZEOF_INT @SIZEOF_INT@ -#if SIZEOF_INT +#if defined(SIZEOF_INT) # define HAVE_INT 1 #endif #cmakedefine SIZEOF_LONG @SIZEOF_LONG@ -#if SIZEOF_LONG +#if defined(SIZEOF_LONG) # define HAVE_LONG 1 #endif #cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@ -#if SIZEOF_LONG_LONG +#if defined(SIZEOF_LONG_LONG) # define HAVE_LONG_LONG 1 #endif #cmakedefine SIZEOF_SIGSET_T @SIZEOF_SIGSET_T@ -#if SIZEOF_SIGSET_T +#if defined(SIZEOF_SIGSET_T) # define HAVE_SIGSET_T 1 #endif #cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@ -#if SIZEOF_SIZE_T +#if defined(SIZEOF_SIZE_T) # define HAVE_SIZE_T 1 #endif #cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@ -#if SIZEOF_UCHAR +#if defined(SIZEOF_UCHAR) # define HAVE_UCHAR 1 #endif #cmakedefine SIZEOF_UINT @SIZEOF_UINT@ -#if SIZEOF_UINT +#if defined(SIZEOF_UINT) # define HAVE_UINT 1 #endif #cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@ -#if SIZEOF_ULONG +#if defined(SIZEOF_ULONG) # define HAVE_ULONG 1 #endif #cmakedefine SIZEOF_INT8 @SIZEOF_INT8@ -#if SIZEOF_INT8 +#if defined(SIZEOF_INT8) # define HAVE_INT8 1 #endif #cmakedefine SIZEOF_UINT8 @SIZEOF_UINT8@ -#if SIZEOF_UINT8 +#if defined(SIZEOF_UINT8) # define HAVE_UINT8 1 #endif #cmakedefine SIZEOF_INT16 @SIZEOF_INT16@ -#if SIZEOF_INT16 +#if defined(SIZEOF_INT16) # define HAVE_INT16 1 #endif #cmakedefine SIZEOF_UINT16 @SIZEOF_UINT16@ -#if SIZEOF_UINT16 +#if defined(SIZEOF_UINT16) # define HAVE_UINT16 1 #endif #cmakedefine SIZEOF_INT32 @SIZEOF_INT32@ -#if SIZEOF_INT32 +#if defined(SIZEOF_INT32) # define HAVE_INT32 1 #endif #cmakedefine SIZEOF_UINT32 @SIZEOF_UINT32@ -#if SIZEOF_UINT32 +#if defined(SIZEOF_UINT32) # define HAVE_UINT32 1 #endif #cmakedefine SIZEOF_U_INT32_T @SIZEOF_U_INT32_T@ -#if SIZEOF_U_INT32_T +#if defined(SIZEOF_U_INT32_T) # define HAVE_U_INT32_T 1 #endif #cmakedefine SIZEOF_INT64 @SIZEOF_INT64@ -#if SIZEOF_INT64 +#if defined(SIZEOF_INT64) # define HAVE_INT64 1 #endif #cmakedefine SIZEOF_UINT64 @SIZEOF_UINT64@ -#if SIZEOF_UINT64 +#if defined(SIZEOF_UINT64) # define HAVE_UINT64 1 #endif #cmakedefine SIZEOF_SOCKLEN_T @SIZEOF_SOCKLEN_T@ -#if SIZEOF_SOCKLEN_T +#if defined(SIZEOF_SOCKLEN_T) # define HAVE_SOCKLEN_T 1 #endif diff --git a/include/ma_global.h b/include/ma_global.h index ce96b002..819a8273 100644 --- a/include/ma_global.h +++ b/include/ma_global.h @@ -185,11 +185,11 @@ double my_ulonglong2double(unsigned long long A); #ifdef HAVE_FCNTL_H #include #endif -#if TIME_WITH_SYS_TIME +#if defined(TIME_WITH_SYS_TIME) # include # include #else -# if HAVE_SYS_TIME_H +# if defined(HAVE_SYS_TIME_H) # include # else # include @@ -671,7 +671,7 @@ typedef ulonglong uint64; The following is done with a if to not get problems with pre-processors with late define evaluation */ -#if SIZEOF_OFF_T == 4 +#if defined(SIZEOF_OFF_T) && SIZEOF_OFF_T == 4 #define SYSTEM_SIZEOF_OFF_T 4 #else #define SYSTEM_SIZEOF_OFF_T 8 @@ -682,7 +682,7 @@ typedef ulonglong uint64; #define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T #endif /* USE_RAID */ -#if SIZEOF_OFF_T > 4 +#if defined(SIZEOF_OFF_T) && SIZEOF_OFF_T > 4 typedef ulonglong my_off_t; #else typedef unsigned long my_off_t; diff --git a/libmariadb/ma_charset.c b/libmariadb/ma_charset.c index 81c6a554..a3e09430 100644 --- a/libmariadb/ma_charset.c +++ b/libmariadb/ma_charset.c @@ -259,7 +259,7 @@ static unsigned int mysql_mbcharlen_utf8(unsigned int utf8) static unsigned int check_mb_big5(const char *start, const char *end) { - return (valid_big5head(*(start)) && (end - start) > 1 && valid_big5tail(*(start + 1)) ? 2 : 0); + return (valid_big5head(*((const uchar*) start)) && (end - start) > 1 && valid_big5tail(*((const uchar*) start + 1)) ? 2 : 0); } diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 8b79747c..35474371 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -507,7 +507,7 @@ void read_user_name(char *name) str="UNKNOWN_USER"; } ma_strmake(name,str,USERNAME_LENGTH); -#elif HAVE_CUSERID +#elif defined(HAVE_CUSERID) (void) cuserid(name); #else ma_strmake(name,"UNKNOWN_USER", USERNAME_LENGTH); diff --git a/libmariadb/secure/openssl.c b/libmariadb/secure/openssl.c index 56e6bb38..04cbeebf 100644 --- a/libmariadb/secure/openssl.c +++ b/libmariadb/secure/openssl.c @@ -42,7 +42,7 @@ #ifdef HAVE_TLS_SESSION_CACHE #undef HAVE_TLS_SESSION_CACHE #endif -#if OPENSSL_USE_BIOMETHOD +#if defined(OPENSSL_USE_BIOMETHOD) #undef OPENSSL_USE_BIOMETHOD #endif #ifndef HAVE_OPENSSL_DEFAULT @@ -69,7 +69,7 @@ static pthread_mutex_t LOCK_openssl_config; #ifndef HAVE_OPENSSL_1_1_API static pthread_mutex_t *LOCK_crypto= NULL; #endif -#if OPENSSL_USE_BIOMETHOD +#if defined(OPENSSL_USE_BIOMETHOD) static int ma_bio_read(BIO *h, char *buf, int size); static int ma_bio_write(BIO *h, const char *buf, int size); static BIO_METHOD ma_BIO_method; @@ -350,7 +350,7 @@ int ma_tls_start(char *errmsg __attribute__((unused)), size_t errmsg_len __attri OpenSSL_add_all_algorithms(); #endif disable_sigpipe(); -#if OPENSSL_USE_BIOMETHOD +#ifdef OPENSSL_USE_BIOMETHOD memcpy(&ma_BIO_method, BIO_s_socket(), sizeof(BIO_METHOD)); ma_BIO_method.bread= ma_bio_read; ma_BIO_method.bwrite= ma_bio_write; @@ -582,7 +582,7 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls) MYSQL *mysql; MARIADB_PVIO *pvio; int rc; -#if OPENSSL_USE_BIOMETHOD +#ifdef OPENSSL_USE_BIOMETHOD BIO_METHOD *bio_method= NULL; BIO *bio; #endif @@ -596,7 +596,7 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls) SSL_clear(ssl); -#if OPENSSL_USE_BIOMETHOD +#ifdef OPENSSL_USE_BIOMETHOD bio= BIO_new(&ma_BIO_method); bio->ptr= pvio; SSL_set_bio(ssl, bio, bio);