diff options
75 files changed, 215 insertions, 232 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bbb6caa8267..6d381461c53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,8 @@ OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system librar INCLUDE(check_compiler_flag) OPTION(WITH_ASAN "Enable address sanitizer" OFF) -IF (WITH_ASAN) + +IF (WITH_ASAN AND NOT MSVC) # gcc 4.8.1 and new versions of clang MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -fPIC" DEBUG RELWITHDEBINFO) diff --git a/client/mysql.cc b/client/mysql.cc index dc5dcd3b74a..19c5dd4e6a9 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1709,13 +1709,12 @@ static struct my_option my_long_options[] = static void usage(int version) { +#ifdef HAVE_READLINE #if defined(USE_LIBEDIT_INTERFACE) const char* readline= ""; #else const char* readline= "readline"; #endif - -#ifdef HAVE_READLINE printf("%s Ver %s Distrib %s, for %s (%s) using %s %s\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE, readline, rl_library_version); diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 6993bae3975..4a13edceece 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -13,6 +13,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +IF(MSVC) + RETURN() +ENDIF() + # Common warning flags for GCC, G++, Clang and Clang++ SET(MY_WARNING_FLAGS -Wall diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index aa948a7f5b2..3935894781e 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -59,7 +59,41 @@ IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4) ADD_DEFINITIONS(-march=i486) ENDIF() +FUNCTION(ENABLE_ASAN) + IF(NOT (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang)) + MESSAGE(FATAL_ERROR "clang-cl is necessary to enable asan") + ENDIF() + # currently, asan is broken with static CRT. + IF(NOT(MSVC_CRT_TYPE STREQUAL "/MD")) + MESSAGE(FATAL_ERROR "-DWITH_ASAN cmake parameter also requires -DMSVC_CRT_TYPE=/MD") + ENDIF() + IF(CMAKE_SIZEOF_VOID_P EQUAL 4) + MESSAGE(FATAL_ERROR "-DWITH_ASAN on Windows requires 64bit build") + ENDIF() + # After installation, clang lib directory should be added to PATH + # (e.g C:/Program Files/LLVM/lib/clang/5.0.1/lib/windows) + FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC clang_rt.asan_dynamic-x86_64.lib) + IF(NOT CLANG_RT_ASAN_DYNAMIC) + MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic-x86_64.lib") + ENDIF() + + FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC_THUNK clang_rt.asan_dynamic_runtime_thunk-x86_64.lib) + IF(NOT CLANG_RT_ASAN_DYNAMIC_THUNK) + MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic_runtime_thunk-x86_64.lib") + ENDIF() + + STRING(APPEND CMAKE_C_FLAGS " -fsanitize=address") + STRING(APPEND CMAKE_CXX_FLAGS " -fsanitize=address") + + LINK_LIBRARIES(${CLANG_RT_ASAN_DYNAMIC} ${CLANG_RT_ASAN_DYNAMIC_THUNK}) +ENDFUNCTION() + + IF(MSVC) + IF(WITH_ASAN) + ENABLE_ASAN() + ENDIF() + # Disable mingw based pkg-config found in Strawberry perl SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "") SET(MSVC_CRT_TYPE /MT CACHE STRING @@ -119,8 +153,16 @@ IF(MSVC) STRING(APPEND ${flag} " /Z7") ENDIF() ENDFOREACH() - - + + IF(CMAKE_CXX_COMPILER_ID MATCHES Clang) + SET(CLANG_CL_FLAGS +"-Wno-unused-parameter -Wno-unused-command-line-argument -Wno-pointer-sign -Wno-deprecated-register \ +-Wno-missing-braces -Wno-unused-function -msse4.2 " + ) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_CL_FLAGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CL_FLAGS}") + ENDIF() + # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") @@ -139,7 +181,7 @@ IF(MSVC) ENDIF() # Speed up multiprocessor build - IF (MSVC_VERSION GREATER 1400) + IF (MSVC_VERSION GREATER 1400 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") ENDIF() @@ -147,7 +189,7 @@ IF(MSVC) #TODO: update the code and remove the disabled warnings SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4700 /we4311 /we4477 /we4302 /we4090") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") - IF(MSVC_VERSION GREATER 1910) + IF(MSVC_VERSION GREATER 1910 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") ENDIF() ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) diff --git a/configure.cmake b/configure.cmake index bfc87086a8c..c5d1d084f0f 100644 --- a/configure.cmake +++ b/configure.cmake @@ -52,7 +52,7 @@ IF(NOT SYSTEM_TYPE) ENDIF() ENDIF() -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND (NOT MSVC)) # MySQL "canonical" GCC flags. At least -fno-rtti flag affects # ABI and cannot be simply removed. SET(CMAKE_CXX_FLAGS diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 415e95f9353..0549b0c5e9c 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -800,7 +800,7 @@ wait_for_no_updates(MYSQL *connection, uint timeout, uint threshold) static os_thread_ret_t -kill_query_thread( +DECLARE_THREAD(kill_query_thread)( /*===============*/ void *arg __attribute__((unused))) { diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 823be4da0bb..5c93a47b626 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -255,8 +255,9 @@ it every INNOBASE_WAKE_INTERVAL'th step. */ #define INNOBASE_WAKE_INTERVAL 32 ulong innobase_active_counter = 0; - +#ifndef _WIN32 static char *xtrabackup_debug_sync = NULL; +#endif my_bool xtrabackup_incremental_force_scan = FALSE; @@ -2455,7 +2456,7 @@ xtrabackup_copy_logfile(copy_logfile copy) return(false); } -static os_thread_ret_t log_copying_thread(void*) +static os_thread_ret_t DECLARE_THREAD(log_copying_thread)(void*) { /* Initialize mysys thread-specific memory so we can @@ -2478,7 +2479,7 @@ static os_thread_ret_t log_copying_thread(void*) } /* io throttle watching (rough) */ -static os_thread_ret_t io_watching_thread(void*) +static os_thread_ret_t DECLARE_THREAD(io_watching_thread)(void*) { /* currently, for --backup only */ ut_a(xtrabackup_backup); @@ -2504,7 +2505,7 @@ static os_thread_ret_t io_watching_thread(void*) Datafiles copying thread.*/ static os_thread_ret_t -data_copy_thread_func( +DECLARE_THREAD(data_copy_thread_func)( /*==================*/ void *arg) /* thread context */ { diff --git a/extra/perror.c b/extra/perror.c index e96002cbb7b..3bc5120db48 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -204,7 +204,7 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose) NULL)) { if (verbose) - printf("Win32 error code %d: %s", error, s); + printf("Win32 error code %lu: %s", error, s); else puts(s); LocalFree(s); diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index a539adab1da..de8025a8353 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -42,7 +42,6 @@ #endif #ifdef _WIN32 - const int SOCKET_EINVAL = WSAEINVAL; const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK; const int SOCKET_EAGAIN = WSAEWOULDBLOCK; #else diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 1dc89df9d86..a9e41fb997a 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -921,10 +921,6 @@ static bool setPrefix(opaque* sha_input, int i) return true; } - -const char handshake_order[] = "Out of order HandShake Message!"; - - } // namespcae for locals diff --git a/include/my_attribute.h b/include/my_attribute.h index 14ed35cfe24..9959028bd2e 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -34,9 +34,9 @@ compilation warnings. */ #ifndef __attribute__ -# if !defined(__GNUC__) +# if !defined(__GNUC__) && !defined(__clang__) # define __attribute__(A) -# else +# elif defined(__GNUC__) # ifndef GCC_VERSION # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) # endif diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc index 8cb805b1bbc..68a069ad319 100644 --- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc @@ -77,14 +77,14 @@ void dump_single_process(DWORD pid) process= OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (!process) { - fprintf(stderr, "safe_kill : cannot open process pid=%u to create dump, last error %u\n", + fprintf(stderr, "safe_kill : cannot open process pid=%lu to create dump, last error %lu\n", pid, GetLastError()); goto exit; } if (QueryFullProcessImageName(process, 0, path, &size) == 0) { - fprintf(stderr, "safe_kill : cannot read process path for pid %u, last error %u\n", + fprintf(stderr, "safe_kill : cannot read process path for pid %lu, last error %lu\n", pid, GetLastError()); goto exit; } @@ -116,17 +116,17 @@ void dump_single_process(DWORD pid) { if (!GetTempFileName(".", filename, 0, tmpname)) { - fprintf(stderr, "GetTempFileName failed, last error %u", GetLastError()); + fprintf(stderr, "GetTempFileName failed, last error %lu", GetLastError()); goto exit; } - strncat(tmpname, ".dmp", sizeof(tmpname)); + strncat_s(tmpname, ".dmp", sizeof(tmpname)); filename= tmpname; } if (!GetCurrentDirectory(MAX_PATH, working_dir)) { - fprintf(stderr, "GetCurrentDirectory failed, last error %u", GetLastError()); + fprintf(stderr, "GetCurrentDirectory failed, last error %lu", GetLastError()); goto exit; } @@ -135,14 +135,14 @@ void dump_single_process(DWORD pid) if (file == INVALID_HANDLE_VALUE) { - fprintf(stderr, "safe_kill : CreateFile() failed for file %s, working dir %s, last error = %u\n", + fprintf(stderr, "safe_kill : CreateFile() failed for file %s, working dir %s, last error = %lu\n", filename, working_dir, GetLastError()); goto exit; } if (!MiniDumpWriteDump(process, pid, file, MiniDumpNormal, 0, 0, 0)) { - fprintf(stderr, "Failed to write minidump to %s, working dir %s, last error %u\n", + fprintf(stderr, "Failed to write minidump to %s, working dir %s, last error %lu\n", filename, working_dir, GetLastError()); goto exit; } @@ -214,7 +214,7 @@ int main(int argc, const char** argv ) if (!GetExitCodeProcess(process,&exit_code)) { - fprintf(stderr, "GetExitCodeProcess failed, pid= %d, err= %d\n", + fprintf(stderr, "GetExitCodeProcess failed, pid= %lu, err= %lu\n", pid, GetLastError()); exit(1); } @@ -232,7 +232,7 @@ int main(int argc, const char** argv ) Sleep(100); else { - fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n", + fprintf(stderr, "Failed to open shutdown_event '%s', error: %lu\n", safe_process_name, GetLastError()); exit(3); } @@ -240,7 +240,7 @@ int main(int argc, const char** argv ) if(SetEvent(shutdown_event) == 0) { - fprintf(stderr, "Failed to signal shutdown_event '%s', error: %d\n", + fprintf(stderr, "Failed to signal shutdown_event '%s', error: %lu\n", safe_process_name, GetLastError()); CloseHandle(shutdown_event); exit(4); diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index dca2faded71..e7fb0d69c91 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -75,7 +75,7 @@ static void message(const char* fmt, ...) static void die(const char* fmt, ...) { - DWORD last_err= GetLastError(); + int last_err= GetLastError(); va_list args; fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name); va_start(args, fmt); @@ -106,7 +106,7 @@ static void die(const char* fmt, ...) DWORD get_parent_pid(DWORD pid) { HANDLE snapshot; - DWORD parent_pid= -1; + DWORD parent_pid= 0; PROCESSENTRY32 pe32; pe32.dwSize= sizeof(PROCESSENTRY32); @@ -127,7 +127,7 @@ DWORD get_parent_pid(DWORD pid) } while(Process32Next( snapshot, &pe32)); CloseHandle(snapshot); - if (parent_pid == -1) + if (parent_pid == 0) die("Could not find parent pid"); return parent_pid; @@ -163,7 +163,7 @@ int main(int argc, const char** argv ) PROCESS_INFORMATION process_info= {0}; BOOL nocore= FALSE; - sprintf(safe_process_name, "safe_process[%d]", pid); + sprintf(safe_process_name, "safe_process[%lu]", pid); /* Create an event for the signal handler */ if ((shutdown_event= @@ -298,7 +298,7 @@ int main(int argc, const char** argv ) BOOL process_created= FALSE; BOOL jobobject_assigned= FALSE; - for (int i=0; i < sizeof(create_flags)/sizeof(create_flags[0]); i++) + for (size_t i=0; i < sizeof(create_flags)/sizeof(create_flags[0]); i++) { process_created= CreateProcess(NULL, (LPSTR)child_args, NULL, diff --git a/mysys/get_password.c b/mysys/get_password.c index 8a507d94e9b..2b63a686d07 100644 --- a/mysys/get_password.c +++ b/mysys/get_password.c @@ -64,7 +64,6 @@ char *get_tty_password(const char *opt_message) { char to[80]; char *pos=to,*end=to+sizeof(to)-1; - int i=0; DBUG_ENTER("get_tty_password"); _cputs(opt_message ? opt_message : "Enter password: "); for (;;) diff --git a/mysys/my_access.c b/mysys/my_access.c index 75774240406..0f3263a79c3 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -38,7 +38,7 @@ int my_access(const char *path, int amode) attributes = GetFileAttributes(path); if (attributes == INVALID_FILE_ATTRIBUTES || - (attributes & FILE_ATTRIBUTE_READONLY) && (amode & W_OK)) + ((attributes & FILE_ATTRIBUTE_READONLY) && (amode & W_OK))) { my_errno= errno= EACCES; return -1; diff --git a/mysys/my_conio.c b/mysys/my_conio.c index 0af5706cace..21f30bd9b67 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -47,7 +47,7 @@ static HANDLE my_coninpfh= 0; /* console input */ static int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time) { - int res; + DWORD res; char tname[FN_REFLEN]; sprintf(tname, "%s-%08X", name, id); @@ -203,7 +203,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) if (*plen > 0 && buffer[*plen - 1] == '\r') { char tmp[3]; - int tmplen= sizeof(tmp); + DWORD tmplen= (DWORD)sizeof(tmp); *plen= *plen - 1; /* read /n left in the buffer */ diff --git a/mysys/my_default.c b/mysys/my_default.c index ddcc869fa66..dc8523576c6 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -1184,7 +1184,7 @@ static const char **init_default_directories(MEM_ROOT *alloc) { errors += add_directory(alloc, fname_buffer, dirs); - strncat(fname_buffer, "/data", sizeof(fname_buffer)); + strcat_s(fname_buffer, sizeof(fname_buffer), "/data"); errors += add_directory(alloc, fname_buffer, dirs); } } diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 0faf6079d98..beece473a01 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -83,7 +83,7 @@ static int my_win_unlink(const char *name) { HANDLE handle= INVALID_HANDLE_VALUE; DWORD attributes; - DWORD last_error; + uint last_error; char unique_filename[MAX_PATH + 35]; unsigned long long tsc; /* time stamp counter, for unique filename*/ @@ -148,7 +148,7 @@ static int my_win_unlink(const char *name) name, tsc); if (!MoveFile(name, unique_filename)) { - DBUG_PRINT("warning", ("moving %s to unique filename failed, error %u\n", + DBUG_PRINT("warning", ("moving %s to unique filename failed, error %lu\n", name,GetLastError())); } diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 5ab3facc348..dc6b7cfd292 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -206,12 +206,12 @@ MY_DIR *my_dir(const char *path, myf MyFlags) ushort mode; char tmp_path[FN_REFLEN], *tmp_file,attrib; #ifdef _WIN64 - __int64 handle; + __int64 handle= -1; #else - long handle; + long handle= -1; #endif DBUG_ENTER("my_dir"); - DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags)); + DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,(int)MyFlags)); /* Put LIB-CHAR as last path-character if not there */ tmp_file=tmp_path; diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 082d8e9f5a0..34b1723e13c 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -34,7 +34,6 @@ static int win_lock(File fd, int locktype, my_off_t start, my_off_t length, DWORD dwFlags; OVERLAPPED ov= {0}; HANDLE hFile= (HANDLE)my_get_osfhandle(fd); - DWORD lastError= 0; int i; int timeout_millis= timeout_sec * 1000; diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 20e53a23ab5..0b84ed0cd82 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -21,6 +21,7 @@ #include <signal.h> #include <m_string.h> #include <thr_alarm.h> +#include <my_pthread.h> #if (defined(__BSD__) || defined(_BSDI_VERSION)) #define SCHED_POLICY SCHED_RR diff --git a/mysys/my_sync.c b/mysys/my_sync.c index d1e239692f1..cf8dfb6a8c8 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -133,8 +133,6 @@ int my_sync(File fd, myf my_flags) } /* my_sync */ -static const char cur_dir_name[]= {FN_CURLIB, 0}; - /* Force directory information to disk. @@ -151,6 +149,7 @@ int my_sync_dir(const char *dir_name __attribute__((unused)), myf my_flags __attribute__((unused))) { #ifdef NEED_EXPLICIT_SYNC_DIR + static const char cur_dir_name[]= {FN_CURLIB, 0}; File dir_fd; int res= 0; const char *correct_dir_name; diff --git a/mysys/my_winerr.c b/mysys/my_winerr.c index a3f6229b74e..ccd94d92d80 100644 --- a/mysys/my_winerr.c +++ b/mysys/my_winerr.c @@ -96,7 +96,7 @@ access violations */ static int get_errno_from_oserr(unsigned long oserrno) { - int i; + size_t i; /* check the table for the OS error code */ for (i= 0; i < ERRTABLESIZE; ++i) diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index f3335621c38..080eeb49f63 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -79,10 +79,10 @@ int pthread_create(pthread_t *thread_id, const pthread_attr_t *attr, par->arg= param; stack_size= attr?attr->dwStackSize:0; - handle= _beginthreadex(NULL, stack_size , pthread_start, par, 0, thread_id); + handle= _beginthreadex(NULL, stack_size , pthread_start, par, 0, (uint *)thread_id); if (!handle) goto error_return; - DBUG_PRINT("info", ("thread id=%u",*thread_id)); + DBUG_PRINT("info", ("thread id=%lu",*thread_id)); /* Do not need thread handle, close it */ CloseHandle((HANDLE)handle); diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 892e09148ef..38a75120303 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -146,8 +146,12 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd); return NOAT; #endif +#ifndef _WIN32 #define CREATE_NOSYMLINK_FUNCTION(PROTO,AT,NOAT) \ static int PROTO { NOSYMLINK_FUNCTION_BODY(AT,NOAT) } +#else +#define CREATE_NOSYMLINK_FUNCTION(PROTO,AT,NOAT) +#endif #ifdef _WIN32 #include <sys/stat.h> diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index cc759d38664..619172a5a6a 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -703,7 +703,7 @@ void my_print_stacktrace(uchar* unused1, ulong unused2, my_bool silent) if(have_source) { const char *base_file_name= my_basename(line.FileName); - my_safe_printf_stderr("[%s:%u]", + my_safe_printf_stderr("[%s:%lu]", base_file_name, line.LineNumber); } my_safe_printf_stderr("%s", "\n"); @@ -733,7 +733,7 @@ void my_write_core(int unused) if(GetModuleFileName(NULL, path, sizeof(path))) { _splitpath(path, NULL, NULL,dump_fname,NULL); - strncat(dump_fname, ".dmp", sizeof(dump_fname)); + strcat_s(dump_fname, sizeof(dump_fname), ".dmp"); } hFile= CreateFile(dump_fname, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 97656e6b77f..357923cf388 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -36,13 +36,6 @@ #define ETIME ETIMEDOUT #endif -uint thr_client_alarm; -static int alarm_aborted=1; /* No alarm thread */ -my_bool thr_alarm_inited= 0, my_disable_thr_alarm= 0; -volatile my_bool alarm_thread_running= 0; -time_t next_alarm_expire_time= ~ (time_t) 0; -static sig_handler process_alarm_part2(int sig); - #ifdef DBUG_OFF #define reset_index_in_queue(alarm_data) #else @@ -55,9 +48,16 @@ static sig_handler process_alarm_part2(int sig); #define one_signal_hand_sigmask(A,B,C) #endif +my_bool thr_alarm_inited= 0, my_disable_thr_alarm= 0; #if !defined(__WIN__) +uint thr_client_alarm; +static int alarm_aborted=1; /* No alarm thread */ +volatile my_bool alarm_thread_running= 0; +time_t next_alarm_expire_time= ~ (time_t) 0; +static sig_handler process_alarm_part2(int sig); + static mysql_mutex_t LOCK_alarm; static mysql_cond_t COND_alarm; static sigset_t full_signal_set; diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index 87893924b38..64510161691 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -92,15 +92,19 @@ static int uname(struct utsname *buf) { OSVERSIONINFOEX ver; ver.dwOSVersionInfoSize = (DWORD)sizeof(ver); + /* GetVersionEx got deprecated, we need it anyway, so disable deprecation warnings. */ #ifdef _MSC_VER #pragma warning (disable : 4996) #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif if (!GetVersionEx((OSVERSIONINFO *)&ver)) return -1; buf->nodename[0]= 0; strcpy(buf->sysname, "Windows"); - sprintf(buf->release, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); + sprintf(buf->release, "%d.%d", (int)ver.dwMajorVersion, (int)ver.dwMinorVersion); const char *version_str= get_os_version_name(&ver); if(version_str && version_str[0]) @@ -109,7 +113,7 @@ static int uname(struct utsname *buf) { /* Fallback for unknown versions, e.g "Windows <major_ver>.<minor_ver>" */ sprintf(buf->version, "Windows %d.%d%s", - ver.dwMajorVersion, ver.dwMinorVersion, + (int)ver.dwMajorVersion, (int)ver.dwMinorVersion, (ver.wProductType == VER_NT_WORKSTATION ? "" : " Server")); } diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 35d05f816c3..16e506626e5 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -438,6 +438,7 @@ static const char *syslog_facility_names[]= "LOG_LOCAL4", "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", 0 }; +#ifndef _WIN32 static unsigned int syslog_facility_codes[]= { LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, @@ -452,6 +453,7 @@ static unsigned int syslog_facility_codes[]= LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7, }; +#endif static TYPELIB syslog_facility_typelib= { array_elements(syslog_facility_names) - 1, "syslog_facility_typelib", @@ -469,11 +471,13 @@ static const char *syslog_priority_names[]= 0 }; +#ifndef _WIN32 static unsigned int syslog_priority_codes[]= { LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG, }; +#endif static TYPELIB syslog_priority_typelib= { @@ -2106,6 +2110,7 @@ struct mysql_event_general_v8 static void auditing_v8(MYSQL_THD thd, struct mysql_event_general_v8 *ev_v8) { +#ifdef __linux__ #ifdef DBUG_OFF #ifdef __x86_64__ static const int cmd_off= 4200; @@ -2127,7 +2132,7 @@ static void auditing_v8(MYSQL_THD thd, struct mysql_event_general_v8 *ev_v8) static const int db_len_off= 68; #endif /*x86_64*/ #endif /*DBUG_OFF*/ - +#endif /* __linux__ */ struct mysql_event_general event; if (ev_v8->event_class != MYSQL_AUDIT_GENERAL_CLASS) diff --git a/plugin/win_auth_client/common.cc b/plugin/win_auth_client/common.cc index 1c872c07e14..8e4eb318252 100644 --- a/plugin/win_auth_client/common.cc +++ b/plugin/win_auth_client/common.cc @@ -504,7 +504,7 @@ const char* get_last_error_message(Error_message_buf buf) buf[0]= '\0'; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)buf, sizeof(buf), NULL ); + (LPTSTR)buf, ERRMSG_BUFSIZE , NULL ); return buf; } diff --git a/plugin/win_auth_client/common.h b/plugin/win_auth_client/common.h index 415294b1ed9..cd7dc8c2e66 100644 --- a/plugin/win_auth_client/common.h +++ b/plugin/win_auth_client/common.h @@ -77,8 +77,8 @@ void error_log_print(const char *fmt, ...) error_log_vprint(Level, fmt, args); va_end(args); } - -typedef char Error_message_buf[1024]; +#define ERRMSG_BUFSIZE 1024 +typedef char Error_message_buf[ERRMSG_BUFSIZE]; const char* get_last_error_message(Error_message_buf); diff --git a/sql-common/client.c b/sql-common/client.c index 70edff9b737..94f50eae30b 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -96,6 +96,7 @@ my_bool net_flush(NET *net); #ifndef _WIN32 #include <errno.h> #define SOCKET_ERROR -1 +#define INVALID_SOCKET -1 #endif #ifdef __WIN__ @@ -258,7 +259,6 @@ HANDLE create_named_pipe(MYSQL *mysql, uint connect_timeout, char **arg_host, char pipe_name[1024]; DWORD dwMode; int i; - my_bool testing_named_pipes=0; char *host= *arg_host, *unix_socket= *arg_unix_socket; if ( ! unix_socket || (unix_socket)[0] == 0x00) @@ -369,7 +369,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) char *shared_memory_base_name = mysql->options.shared_memory_base_name; static const char *name_prefixes[] = {"","Global\\"}; const char *prefix; - int i; + uint i; /* If this is NULL, somebody freed the MYSQL* options. mysql_close() @@ -915,13 +915,6 @@ static int cli_report_progress(MYSQL *mysql, char *pkt, uint length) return 0; } -#ifdef __WIN__ -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif /************************************************************************** Shut down connection @@ -3215,7 +3208,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, { my_socket sock= socket(AF_UNIX, SOCK_STREAM, 0); DBUG_PRINT("info", ("Using socket")); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR, unknown_sqlstate, @@ -3262,7 +3255,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, if (!net->vio && (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || - (! have_tcpip && (unix_socket || !host && is_NT())))) + (! have_tcpip && (unix_socket || !host )))) { if ((hPipe= create_named_pipe(mysql, mysql->options.connect_timeout, (char**) &host, (char**) &unix_socket)) == @@ -3296,7 +3289,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, struct addrinfo *res_lst, hints, *t_res; int gai_errno; char port_buf[NI_MAXSERV]; - my_socket sock= SOCKET_ERROR; + my_socket sock= INVALID_SOCKET; int saved_error= 0, status= -1; unix_socket=0; /* This is not used */ @@ -3344,7 +3337,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol)); sock= socket(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { saved_error= socket_errno; continue; @@ -3386,7 +3379,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, freeaddrinfo(res_lst); - if (sock == SOCKET_ERROR) + if (sock == INVALID_SOCKET) { set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate, ER(CR_IPSOCK_ERROR), saved_error); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 90d762c0191..7c32fde72fe 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2189,9 +2189,8 @@ char *Item_func_password::alloc(THD *thd, const char *password, String *Item_func_encrypt::val_str(String *str) { DBUG_ASSERT(fixed == 1); - String *res =args[0]->val_str(str); - #ifdef HAVE_CRYPT + String *res =args[0]->val_str(str); char salt[3],*salt_ptr; if ((null_value=args[0]->null_value)) return 0; diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index c4b528ae10d..3c127bd178c 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -173,6 +173,10 @@ public: class Json_writer_nesting_guard { +#ifdef DBUG_OFF +public: + Json_writer_nesting_guard(Json_writer *) {} +#else Json_writer* writer; int indent_level; public: @@ -185,6 +189,7 @@ public: { DBUG_ASSERT(indent_level == writer->indent_level); } +#endif }; diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index b4af5cc79ed..c76b279048b 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -442,7 +442,6 @@ static int set_directory_permissions(const char *dir, const char *os_user) ACL* pOldDACL; SECURITY_DESCRIPTOR* pSD= NULL; EXPLICIT_ACCESS ea={0}; - BOOL isWellKnownSID= FALSE; WELL_KNOWN_SID_TYPE wellKnownSidType = WinNullSid; PSID pSid= NULL; @@ -509,7 +508,7 @@ static int set_directory_permissions(const char *dir, const char *os_user) ea.grfInheritance= CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE; ea.Trustee.TrusteeType= TRUSTEE_IS_UNKNOWN; ACL* pNewDACL= 0; - DWORD err= SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL); + SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL); if (pNewDACL) { SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL, NULL, diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 2f242bebb0d..599f4a40ea0 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -51,7 +51,7 @@ static char *opt_service; static SC_HANDLE service; static SC_HANDLE scm; HANDLE mysqld_process; // mysqld.exe started for upgrade -DWORD initial_service_state= -1; // initial state of the service +DWORD initial_service_state= UINT_MAX; // initial state of the service HANDLE logfile_handle; /* @@ -126,7 +126,7 @@ static void die(const char *fmt, ...) Stop service that we started, if it was not initally running at program start. */ - if (initial_service_state != -1 && initial_service_state != SERVICE_RUNNING) + if (initial_service_state != UINT_MAX && initial_service_state != SERVICE_RUNNING) { SERVICE_STATUS service_status; ControlService(service, SERVICE_CONTROL_STOP, &service_status); @@ -252,7 +252,7 @@ void stop_mysqld_service() Remeber initial state of the service, we will restore it on exit. */ - if(initial_service_state == -1) + if(initial_service_state == UINT_MAX) initial_service_state= ssp.dwCurrentState; switch(ssp.dwCurrentState) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0d225dec151..b21d50a20fe 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2510,10 +2510,9 @@ static void set_user(const char *user, struct passwd *user_info_arg) allow_coredumps(); } - +#if !defined(__WIN__) static void set_effective_user(struct passwd *user_info_arg) { -#if !defined(__WIN__) DBUG_ASSERT(user_info_arg != 0); if (setregid((gid_t)-1, user_info_arg->pw_gid) == -1) { @@ -2526,9 +2525,8 @@ static void set_effective_user(struct passwd *user_info_arg) unireg_abort(1); } allow_coredumps(); -#endif } - +#endif /** Change root user if started with @c --chroot . */ static void set_root(const char *path) @@ -6191,10 +6189,10 @@ int mysqld_main(int argc, char **argv) ****************************************************************************/ #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) -int mysql_service(void *p) +void mysql_service(void *p) { if (my_thread_init()) - return 1; + abort(); if (use_opt_args) win_main(opt_argc, opt_argv); @@ -6202,7 +6200,6 @@ int mysql_service(void *p) win_main(Service.my_argc, Service.my_argv); my_thread_end(); - return 0; } @@ -6253,7 +6250,7 @@ default_service_handling(char **argv, the option name) should be quoted if it contains a string. */ *pos++= ' '; - if (opt_delim= strchr(extra_opt, '=')) + if ((opt_delim= strchr(extra_opt, '='))) { size_t length= ++opt_delim - extra_opt; pos= strnmov(pos, extra_opt, length); diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 654383c3320..9c754763aab 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -73,18 +73,18 @@ NTService::~NTService() */ -long NTService::Init(LPCSTR szInternName,void *ServiceThread) +long NTService::Init(LPCSTR szInternName, THREAD_FC ServiceThread) { pService = this; - fpServiceThread = (THREAD_FC)ServiceThread; + fpServiceThread = ServiceThread; ServiceName = new char[lstrlen(szInternName)+1]; lstrcpy(ServiceName,szInternName); SERVICE_TABLE_ENTRY stb[] = { - { (char *)szInternName,(LPSERVICE_MAIN_FUNCTION) ServiceMain} , + { (char *)szInternName, ServiceMain} , { NULL, NULL } }; @@ -219,7 +219,6 @@ void NTService::ServiceMain(DWORD argc, LPTSTR *argv) // registration function if (!(pService->hServiceStatusHandle = RegisterServiceCtrlHandler(pService->ServiceName, - (LPHANDLER_FUNCTION) NTService::ServiceCtrlHandler))) goto error; @@ -280,7 +279,7 @@ void NTService::SetSlowStarting(unsigned long timeout) BOOL NTService::StartService() { // Start the real service's thread (application) - if (!(hThreadHandle = (HANDLE) _beginthread((THREAD_FC)fpServiceThread,0, + if (!(hThreadHandle = (HANDLE) _beginthread(fpServiceThread,0, (void *) this))) return FALSE; bRunning = TRUE; diff --git a/sql/nt_servc.h b/sql/nt_servc.h index c8b64515b31..8ba29519c8f 100644 --- a/sql/nt_servc.h +++ b/sql/nt_servc.h @@ -46,7 +46,7 @@ class NTService DWORD dwState; //init service entry point - long Init(LPCSTR szInternName,void *ServiceThread); + long Init(LPCSTR szInternName,THREAD_FC ServiceThread); //application shutdown event void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; } @@ -99,8 +99,8 @@ class NTService void StopService(); BOOL StartService(); - static void ServiceMain(DWORD argc, LPTSTR *argv); - static void ServiceCtrlHandler (DWORD ctrlCode); + static void WINAPI ServiceMain(DWORD argc, LPTSTR *argv); + static void WINAPI ServiceCtrlHandler (DWORD ctrlCode); void Exit(DWORD error); BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode, diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 0452e181e22..cdda49c5796 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -88,7 +88,7 @@ extern "C" sig_handler handle_fatal_signal(int sig) tm.tm_hour, tm.tm_min, tm.tm_sec); if (opt_expect_abort #ifdef _WIN32 - && sig == EXCEPTION_BREAKPOINT /* __debugbreak in my_sigabrt_hander() */ + && sig == (int)EXCEPTION_BREAKPOINT /* __debugbreak in my_sigabrt_hander() */ #else && sig == SIGABRT #endif diff --git a/sql/slave.cc b/sql/slave.cc index 86c9105e1a6..bf70db66f35 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7951,7 +7951,7 @@ static bool get_row_event_stmt_end(const char* buf, The term 4 below signifies that master is of 'an intermediate source', see Rows_log_event::Rows_log_event. */ - flag_start += RW_MAPID_OFFSET + (post_header_len == 6) ? 4 : RW_FLAGS_OFFSET; + flag_start += RW_MAPID_OFFSET + ((post_header_len == 6) ? 4 : RW_FLAGS_OFFSET); return (uint2korr(flag_start) & Rows_log_event::STMT_END_F) != 0; } diff --git a/sql/sql_alloc.h b/sql/sql_alloc.h index e7cda5b2abf..c3bee260817 100644 --- a/sql/sql_alloc.h +++ b/sql/sql_alloc.h @@ -27,13 +27,11 @@ class Sql_alloc public: static void *operator new(size_t size) throw () { - DBUG_ASSERT(size < UINT_MAX32); - return thd_alloc(thd_get_current_thd(), uint(size)); + return thd_alloc(thd_get_current_thd(), size); } static void *operator new[](size_t size) throw () { - DBUG_ASSERT(size < UINT_MAX32); - return thd_alloc(thd_get_current_thd(), uint(size)); + return thd_alloc(thd_get_current_thd(), size); } static void *operator new[](size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 4722f3f5989..f026e2243ab 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5125,7 +5125,6 @@ class select_insert :public select_result_interceptor { class select_create: public select_insert { - ORDER *group; TABLE_LIST *create_table; Table_specification_st *create_info; TABLE_LIST *select_tables; @@ -5806,7 +5805,7 @@ class multi_update :public select_result_interceptor { TABLE_LIST *all_tables; /* query/update command tables */ List<TABLE_LIST> *leaves; /* list of leves of join table tree */ - TABLE_LIST *update_tables, *table_being_updated; + TABLE_LIST *update_tables; TABLE **tmp_tables, *main_table, *table_to_update; TMP_TABLE_PARAM *tmp_table_param; ha_rows updated, found; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c0ee0057016..ad97e70bdd8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -142,14 +142,12 @@ class READ_INFO { File file; String data; /* Read buffer */ uint fixed_length; /* Length of the fixed length record */ - uint max_length; /* Max length of row */ Term_string m_field_term; /* FIELDS TERMINATED BY 'string' */ Term_string m_line_term; /* LINES TERMINATED BY 'string' */ Term_string m_line_start; /* LINES STARTING BY 'string' */ int enclosed_char,escape_char; int *stack,*stack_pos; bool found_end_of_line,start_of_line,eof; - NET *io_net; int level; /* for load xml */ bool getbyte(char *to) diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 0f8f7dbefb7..cc0691f92cf 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -50,12 +50,12 @@ static Field_definition sequence_structure[]= { {"next_not_cached_value", 21, &type_handler_longlong, {STRING_WITH_LEN("")}, FL}, - {"minimum_value", 21, &type_handler_longlong, STRING_WITH_LEN(""), FL}, - {"maximum_value", 21, &type_handler_longlong, STRING_WITH_LEN(""), FL}, + {"minimum_value", 21, &type_handler_longlong, {STRING_WITH_LEN("")}, FL}, + {"maximum_value", 21, &type_handler_longlong, {STRING_WITH_LEN("")}, FL}, {"start_value", 21, &type_handler_longlong, {STRING_WITH_LEN("start value when sequences is created or value if RESTART is used")}, FL}, {"increment", 21, &type_handler_longlong, {STRING_WITH_LEN("increment value")}, FL}, - {"cache_size", 21, &type_handler_longlong, STRING_WITH_LEN(""), + {"cache_size", 21, &type_handler_longlong, {STRING_WITH_LEN("")}, FL | UNSIGNED_FLAG}, {"cycle_option", 1, &type_handler_tiny, {STRING_WITH_LEN("0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed")}, FL | UNSIGNED_FLAG }, diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 291f13d27f8..de9806ab289 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4642,14 +4642,13 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) oldval= logger.get_log_file_handler()->is_open(); log_type= QUERY_LOG_GENERAL; } - else if (self == &Sys_slow_query_log) + else { + DBUG_ASSERT(self == &Sys_slow_query_log); newvalptr= &global_system_variables.sql_log_slow; oldval= logger.get_slow_log_file_handler()->is_open(); log_type= QUERY_LOG_SLOW; } - else - DBUG_ASSERT(FALSE); newval= *newvalptr; if (oldval == newval) diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index e012cd48ecb..e04e09e9bc6 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -1567,7 +1567,6 @@ public: */ class Sys_var_pluginlist: public sys_var { - int plugin_type; public: Sys_var_pluginlist(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index 04a72034e5e..a306822b1f1 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -178,7 +178,7 @@ connection_queue_t; const int NQUEUES=2; /* We have high and low priority queues*/ -struct thread_group_t +struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) thread_group_t { mysql_mutex_t mutex; connection_queue_t queues[NQUEUES]; @@ -196,7 +196,7 @@ struct thread_group_t int shutdown_pipe[2]; bool shutdown; bool stalled; -} MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE); +}; static thread_group_t *all_groups; static uint group_count; @@ -1499,7 +1499,7 @@ void TP_connection_generic::set_io_timeout(int timeout_sec) } - +#ifndef HAVE_IOCP /** Handle a (rare) special case,where connection needs to migrate to a different group because group_count has changed @@ -1534,7 +1534,7 @@ static int change_group(TP_connection_generic *c, mysql_mutex_unlock(&new_group->mutex); return ret; } - +#endif int TP_connection_generic::start_io() { diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index adaca08982f..012f7c5a439 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -92,9 +92,6 @@ static void CALLBACK work_callback(PTP_CALLBACK_INSTANCE instance, PVOID context static void CALLBACK shm_read_callback(PTP_CALLBACK_INSTANCE instance, PVOID Context, PTP_WAIT wait,TP_WAIT_RESULT wait_result); -static void CALLBACK shm_close_callback(PTP_CALLBACK_INSTANCE instance, - PVOID Context, PTP_WAIT wait,TP_WAIT_RESULT wait_result); - static void pre_callback(PVOID context, PTP_CALLBACK_INSTANCE instance); /* Get current time as Windows time */ @@ -151,8 +148,8 @@ TP_connection_win::TP_connection_win(CONNECT *c) : timeout(ULONGLONG_MAX), callback_instance(0), io(0), - shm_read(0), timer(0), + shm_read(0), work(0) { } diff --git a/sql/udf_example.c b/sql/udf_example.c index afe3c5592bc..6db2b5e737a 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -112,6 +112,11 @@ ** */ +#ifdef _WIN32 +/* Silence warning about deprecated functions , gethostbyname etc*/ +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif + #ifdef STANDARD /* STANDARD is defined, don't use any mysql functions */ #include <stdlib.h> @@ -139,14 +144,6 @@ typedef long long longlong; #include <mysql.h> #include <ctype.h> -#ifdef _WIN32 -/* inet_aton needs winsock library */ -#pragma comment(lib, "ws2_32") -#if _MSC_VER -/* Silence warning about deprecated functions , gethostbyname etc*/ -#pragma warning(disable : 4996) -#endif -#endif #ifdef HAVE_DLOPEN diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index fb0c5d5f897..33b0477842d 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -69,6 +69,10 @@ ELSE(NOT UNIX) # Add exception handling to the CONNECT project) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") SET(IPHLPAPI_LIBRARY iphlpapi.lib) + IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang)) + # Connect does not work with clang-cl + RETURN() + ENDIF() ENDIF(UNIX) diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h index e264258a63a..8fe42bd2b08 100644 --- a/storage/federated/ha_federated.h +++ b/storage/federated/ha_federated.h @@ -89,7 +89,6 @@ class ha_federated: public handler */ DYNAMIC_ARRAY results; bool position_called, table_will_be_deleted; - uint fetch_num; // stores the fetch num MYSQL_ROW_OFFSET current_position; // Current position used by ::position() int remote_error_number; char remote_error_buf[FEDERATED_QUERY_BUFFER_SIZE]; diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 76431fd67f6..5413f324127 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -3510,7 +3510,9 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)( os_thread_create */ { my_thread_init(); +#ifndef DBUG_OFF os_thread_id_t cleaner_thread_id = os_thread_get_curr_id(); +#endif mutex_enter(&page_cleaner.mutex); ulint thread_no = page_cleaner.n_workers++; diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 910721d8b32..296494f6a63 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2972,7 +2972,7 @@ Optimize all FTS tables. @return Dummy return */ static os_thread_ret_t -fts_optimize_thread( +DECLARE_THREAD(fts_optimize_thread)( /*================*/ void* arg) /*!< in: work queue*/ { diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index c240f5dacdd..c1b96ef7a1f 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -53,12 +53,8 @@ typedef LPTHREAD_START_ROUTINE os_thread_func_t; /** Macro for specifying a Windows thread start function. */ #define DECLARE_THREAD(func) WINAPI func -/** Required to get around a build error on Windows. Even though our functions -are defined/declared as WINAPI f(LPVOID a); the compiler complains that they -are defined as: os_thread_ret_t (__cdecl*)(void*). Because our functions -don't access the arguments and don't return any value, we should be safe. */ #define os_thread_create(f,a,i) \ - os_thread_create_func(reinterpret_cast<os_thread_func_t>(f), a, i) + os_thread_create_func(f, a, i) #else diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc index b687af3e21c..98b474c0bda 100644 --- a/storage/innobase/os/os0event.cc +++ b/storage/innobase/os/os0event.cc @@ -35,9 +35,6 @@ Created 2012-09-23 Sunny Bains #include <list> -/** The number of microsecnds in a second. */ -static const ulint MICROSECS_IN_A_SECOND = 1000000; - #ifdef _WIN32 /** Native condition variable. */ typedef CONDITION_VARIABLE os_cond_t; @@ -381,13 +378,8 @@ os_event::wait_time_low( tv.tv_usec += time_in_usec; - if ((ulint) tv.tv_usec >= MICROSECS_IN_A_SECOND) { - tv.tv_sec += tv.tv_usec / MICROSECS_IN_A_SECOND; - tv.tv_usec %= MICROSECS_IN_A_SECOND; - } - - abstime.tv_sec = tv.tv_sec; - abstime.tv_nsec = tv.tv_usec * 1000; + abstime.tv_sec = tv.tv_sec + tv.tv_usec / 1000000; + abstime.tv_nsec = tv.tv_usec % 1000000 * 1000; } else { abstime.tv_nsec = 999999999; abstime.tv_sec = (time_t) ULINT_MAX; diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 942b512206f..b0f4b90b127 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3401,16 +3401,6 @@ static void __stdcall win_free_syncio_event(void *data) { /* -Initialize tls index.for event handle used for synchronized IO on files that -might be opened with FILE_FLAG_OVERLAPPED. -*/ -static void win_init_syncio_event() { - fls_sync_io = FlsAlloc(win_free_syncio_event); - ut_a(fls_sync_io != FLS_OUT_OF_INDEXES); -} - - -/* Retrieve per-thread event for doing synchronous io on asyncronously opened files */ static HANDLE win_get_syncio_event() @@ -3515,46 +3505,6 @@ struct WinIoInit /* Ensures proper initialization and shutdown */ static WinIoInit win_io_init; -/** Check if the file system supports sparse files. -@param[in] name File name -@return true if the file system supports sparse files */ -static -bool -os_is_sparse_file_supported_win32(const char* filename) -{ - char volname[MAX_PATH]; - BOOL result = GetVolumePathName(filename, volname, MAX_PATH); - - if (!result) { - - ib::error() - << "os_is_sparse_file_supported: " - << "Failed to get the volume path name for: " - << filename - << "- OS error number " << GetLastError(); - - return(false); - } - - DWORD flags; - - result = GetVolumeInformation( - volname, NULL, MAX_PATH, NULL, NULL, - &flags, NULL, MAX_PATH); - - - if (!result) { - ib::error() - << "os_is_sparse_file_supported: " - << "Failed to get the volume info for: " - << volname - << "- OS error number " << GetLastError(); - - return(false); - } - - return(flags & FILE_SUPPORTS_SPARSE_FILES) ? true : false; -} /** Free storage space associated with a section of the file. @param[in] fh Open file handle @@ -3851,7 +3801,7 @@ os_file_create_simple_func( ib::info() << "Read only mode set. Unable to" " open file '" << name << "' in RW mode, " - << "trying RO mode", name; + << "trying RO mode"; access = GENERIC_READ; @@ -4546,7 +4496,7 @@ bool os_file_close_func( os_file_t file) { - ut_a(file > 0); + ut_a(file); if (CloseHandle(file)) { return(true); diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index b467f9d1615..ef7e92e3a23 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -766,7 +766,7 @@ It also performs the initial in memory sort of the parsed records. @return OS_THREAD_DUMMY_RETURN */ static os_thread_ret_t -fts_parallel_tokenization( +DECLARE_THREAD(fts_parallel_tokenization)( /*======================*/ void* arg) /*!< in: psort_info for the thread */ { @@ -1106,7 +1106,7 @@ Function performs the merge and insertion of the sorted records. @return OS_THREAD_DUMMY_RETURN */ static os_thread_ret_t -fts_parallel_merge( +DECLARE_THREAD(fts_parallel_merge)( /*===============*/ void* arg) /*!< in: parallel merge info */ { diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 8b3841c1504..47fc4bb7556 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -860,7 +860,7 @@ srv_suspend_thread_low( ut_a(!slot->suspended); slot->suspended = TRUE; - if (my_atomic_addlint(&srv_sys.n_threads_active[type], -1) < 0) { + if ((lint)my_atomic_addlint(&srv_sys.n_threads_active[type], -1) < 0) { ut_error; } diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c index 1ccb67d5698..94f9ad46a48 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -217,7 +217,6 @@ static CONTROL_FILE_ERROR create_control_file(const char *name, static int lock_control_file(const char *name) { - uint retry= 0; /* On Windows, my_lock() uses locking() which is mandatory locking and so prevents maria-recovery.test from copying the control file. And in case of @@ -228,6 +227,7 @@ static int lock_control_file(const char *name) file under Windows. */ #ifndef __WIN__ + uint retry= 0; /* We can't here use the automatic wait in my_lock() as the alarm thread may not yet exists. diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index e5c108a18c6..5909a0175d9 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -1208,8 +1208,8 @@ err: my_errno is set to HA_ERR_WRONG_IN_RECORD */ -ulong _ma_rec_unpack(register MARIA_HA *info, register uchar *to, uchar *from, - ulong found_length) +size_t _ma_rec_unpack(register MARIA_HA *info, register uchar *to, uchar *from, + size_t found_length) { uint flag,bit,length,min_pack_length, column_length; enum en_fieldtype type; diff --git a/storage/maria/ma_norec.c b/storage/maria/ma_norec.c index 8ed0ef68eb4..da26d0d6dbd 100644 --- a/storage/maria/ma_norec.c +++ b/storage/maria/ma_norec.c @@ -32,14 +32,14 @@ my_bool _ma_update_no_record(MARIA_HA *info __attribute__((unused)), const uchar *oldrec __attribute__((unused)), const uchar *record __attribute__((unused))) { - return HA_ERR_WRONG_COMMAND; + return (my_bool)HA_ERR_WRONG_COMMAND; } my_bool _ma_delete_no_record(MARIA_HA *info __attribute__((unused)), const uchar *record __attribute__((unused))) { - return HA_ERR_WRONG_COMMAND; + return (my_bool)HA_ERR_WRONG_COMMAND; } diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 6922326da19..fd5995515c1 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -890,9 +890,9 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem, DBUG_PRINT("exit", ("disk_blocks: %zu block_root: %p hash_entries: %zu\ hash_root: %p hash_links: %zu hash_link_root: %p", - pagecache->disk_blocks, pagecache->block_root, + (size_t)pagecache->disk_blocks, pagecache->block_root, pagecache->hash_entries, pagecache->hash_root, - pagecache->hash_links, pagecache->hash_link_root)); + (size_t)pagecache->hash_links, pagecache->hash_link_root)); pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0; DBUG_RETURN((size_t)pagecache->disk_blocks); diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index cb8b374691e..01af4c0381f 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -857,7 +857,7 @@ get_one_option(int optid, case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; break; - default: assert(0); /* Impossible */ + default: abort(); /* Impossible */ } check_param.stats_method= method_conv; break; diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index f6d16960f5f..23dbf4431c5 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -1202,8 +1202,8 @@ extern my_bool _ma_read_cache(MARIA_HA *, IO_CACHE *info, uchar *buff, extern ulonglong ma_retrieve_auto_increment(const uchar *key, uint8 key_type); extern my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size, size_t new_size); -extern ulong _ma_rec_unpack(MARIA_HA *info, uchar *to, uchar *from, - ulong reclength); +extern size_t _ma_rec_unpack(MARIA_HA *info, uchar *to, uchar *from, + size_t reclength); extern my_bool _ma_rec_check(MARIA_HA *info, const uchar *record, uchar *packpos, ulong packed_length, my_bool with_checkum, ha_checksum checksum); diff --git a/storage/maria/unittest/test_file.c b/storage/maria/unittest/test_file.c index 7ee38c57068..1f74790c565 100644 --- a/storage/maria/unittest/test_file.c +++ b/storage/maria/unittest/test_file.c @@ -54,7 +54,7 @@ int test_file(PAGECACHE_FILE file, char *file_name, LARGE_INTEGER li; if(GetFileAttributesEx(file_name, GetFileExInfoStandard, &file_attr) == 0) { - diag("Can't GetFileAttributesEx %s (errno: %d)\n", file_name, + diag("Can't GetFileAttributesEx %s (errno: %lu)\n", file_name, GetLastError()); res= 0; goto err; diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index cb49ded0c20..905f8ecfbc9 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -1216,7 +1216,7 @@ err: /* Returns -1 and my_errno =HA_ERR_RECORD_DELETED if reclength isn't */ /* right. Returns reclength (>0) if ok */ -ulong _mi_rec_unpack(register MI_INFO *info, register uchar *to, uchar *from, +size_t _mi_rec_unpack(register MI_INFO *info, register uchar *to, uchar *from, ulong found_length) { uint flag,bit,length,rec_length,min_pack_length; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 2e36c364453..e2f99177894 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -727,7 +727,7 @@ get_one_option(int optid, case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; break; - default: assert(0); /* Impossible */ + default: abort(); /* Impossible */ } check_param.stats_method= method_conv; break; diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index e0e552ec5fa..41ad0e8dd7f 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -571,7 +571,7 @@ extern uchar *mi_alloc_rec_buff(MI_INFO *, ulong, uchar **); #define mi_get_rec_buff_len(info,buf) \ (*((uint32 *)(mi_get_rec_buff_ptr(info,buf)))) -extern ulong _mi_rec_unpack(MI_INFO *info, uchar *to, uchar *from, +extern size_t _mi_rec_unpack(MI_INFO *info, uchar *to, uchar *from, ulong reclength); extern my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *packpos, ulong packed_length, my_bool with_checkum); diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index a49cbbcb85c..7a6d8ef8765 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -57,6 +57,10 @@ ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang") SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}") ENDIF() SET(CXX11_FLAGS "-std=c++11 -stdlib=libstdc++") + IF(MSVC) + # clang-cl does not work yet + SKIP_ROCKSDB_PLUGIN("Clang-cl is not supported") + ENDIF() ELSEIF(MSVC) IF (MSVC_VERSION LESS 1900) SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}") diff --git a/strings/decimal.c b/strings/decimal.c index d7fd9a5722b..4473e754365 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1365,7 +1365,7 @@ int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale) case 2: x=mi_sint2korr(from); break; case 3: x=mi_sint3korr(from); break; case 4: x=mi_sint4korr(from); break; - default: DBUG_ASSERT(0); + default: abort(); } from+=i; *buf=x ^ mask; @@ -1406,7 +1406,7 @@ int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale) case 2: x=mi_sint2korr(from); break; case 3: x=mi_sint3korr(from); break; case 4: x=mi_sint4korr(from); break; - default: DBUG_ASSERT(0); + default: abort(); } *buf=(x ^ mask) * powers10[DIG_PER_DEC1 - frac0x]; if (((uint32)*buf) > DIG_MAX) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 23dc458f97a..f188287a001 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19549,7 +19549,9 @@ static void test_mdev4326() myquery(rc); } +/* Test uses MYSQL_PROTOCOL_SOCKET, not on Windows */ +#ifndef _WIN32 /** BUG#17512527: LIST HANDLING INCORRECT IN MYSQL_PRUNE_STMT_LIST() */ @@ -19590,7 +19592,7 @@ static void test_bug17512527() mysql_stmt_close(stmt2); mysql_stmt_close(stmt1); } - +#endif /* diff --git a/vio/viosocket.c b/vio/viosocket.c index 75d3fc51db1..d34bb13b1bd 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -843,7 +843,7 @@ static my_bool socket_peek_read(Vio *vio, uint *bytes) { my_socket sd= mysql_socket_getfd(vio->mysql_socket); #if defined(_WIN32) - int len; + u_long len; if (ioctlsocket(sd, FIONREAD, &len)) return TRUE; *bytes= len; diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index 025c4da4592..71c24e96f92 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -90,7 +90,7 @@ static void EscapeCommandLine(const wchar_t *in, wchar_t *out, size_t buflen) bool needs_escaping= false; size_t pos; - for(int i=0; i< sizeof(special_chars) -1; i++) + for(size_t i=0; i< sizeof(special_chars) -1; i++) { if (wcschr(in, special_chars[i])) { @@ -271,7 +271,7 @@ bool IsPortFree(short port) struct sockaddr_in sin; SOCKET sock; sock = socket(AF_INET, SOCK_STREAM, 0); - if(sock == -1) + if(sock == INVALID_SOCKET) { return false; } @@ -871,8 +871,6 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; - wchar_t* service= 0; - wchar_t* dir= 0; wchar_t installerVersion[MAX_VERSION_PROPERTY_SIZE]; char installDir[MAX_PATH]; DWORD size =MAX_VERSION_PROPERTY_SIZE; @@ -882,7 +880,7 @@ extern "C" UINT __stdcall CheckServiceUpgrades(MSIHANDLE hInstall) DWORD bufsize; int index; BOOL ok; - SC_HANDLE scm; + SC_HANDLE scm = NULL; hr = WcaInitialize(hInstall, __FUNCTION__); WcaLog(LOGMSG_STANDARD, "Initialized."); diff --git a/win/upgrade_wizard/CMakeLists.txt b/win/upgrade_wizard/CMakeLists.txt index dc4ef67387d..1285a5f41b7 100644 --- a/win/upgrade_wizard/CMakeLists.txt +++ b/win/upgrade_wizard/CMakeLists.txt @@ -1,6 +1,10 @@ IF(NOT MSVC) RETURN() ENDIF() +IF(CMAKE_C_COMPILER_ID MATCHES Clang) + # MFC stuff does not compile with clang + RETURN() +ENDIF() IF(CMAKE_USING_VC_FREE_TOOLS) # No MFC, so it cannot be built RETURN() |