diff --git a/include/ma_global.h b/include/ma_global.h index 5318ff6f..790fb991 100644 --- a/include/ma_global.h +++ b/include/ma_global.h @@ -303,7 +303,7 @@ typedef unsigned short ushort; #define my_reinterpret_cast(A) (A) #define my_const_cast(A) (A) #endif -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +#if !defined(__GNUC__) && !defined(__clang__) #define __attribute__(A) #endif diff --git a/include/mysql.h b/include/mysql.h index ea30c4ec..f75ab66f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -440,7 +440,7 @@ struct st_mysql_client_plugin MYSQL_CLIENT_PLUGIN_HEADER }; -struct st_mysql_client_plugin * STDCALL +struct st_mysql_client_plugin * mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, int argc, ...); struct st_mysql_client_plugin * STDCALL @@ -493,7 +493,7 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql); void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs); int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname); -my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...); +my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...); my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *arg); MYSQL * STDCALL mysql_init(MYSQL *mysql); int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, @@ -570,8 +570,8 @@ MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_name(const char *csname); MARIADB_CHARSET_INFO * STDCALL mariadb_get_charset_by_nr(unsigned int csnr); size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs, char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode); -int STDCALL mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...); -int STDCALL mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...); +int mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...); +int mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...); int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, void *arg); unsigned long STDCALL mysql_hex_string(char *to, const char *from, unsigned long len); my_socket STDCALL mysql_get_socket(MYSQL *mysql); diff --git a/include/mysql/client_plugin.h b/include/mysql/client_plugin.h index eb2cea0a..d6ced69a 100644 --- a/include/mysql/client_plugin.h +++ b/include/mysql/client_plugin.h @@ -176,7 +176,7 @@ typedef struct st_mysql_client_plugin_REMOTEIO @retval a pointer to the loaded plugin, or NULL in case of a failure */ -struct st_mysql_client_plugin * STDCALL +struct st_mysql_client_plugin * mysql_load_plugin(struct st_mysql *mysql, const char *name, int type, int argc, ...); diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index a178ce96..9eb66752 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -526,13 +526,6 @@ void read_user_name(char *name) #endif -#ifdef _WIN32 -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif /************************************************************************** ** Shut down connection diff --git a/libmariadb/secure/ma_schannel.c b/libmariadb/secure/ma_schannel.c index 23dc48a8..67a0f990 100644 --- a/libmariadb/secure/ma_schannel.c +++ b/libmariadb/secure/ma_schannel.c @@ -501,7 +501,7 @@ SECURITY_STATUS ma_schannel_handshake_loop(MARIADB_PVIO *pvio, my_bool InitialRe if (rc == SEC_E_OK || rc == SEC_I_CONTINUE_NEEDED || - FAILED(rc) && (dwSSPIOutFlags & ISC_RET_EXTENDED_ERROR)) + (FAILED(rc) && (dwSSPIOutFlags & ISC_RET_EXTENDED_ERROR))) { if(OutBuffers.cbBuffer && OutBuffers.pvBuffer) { diff --git a/plugins/auth/sha256_pw.c b/plugins/auth/sha256_pw.c index c141b19f..efd702bd 100644 --- a/plugins/auth/sha256_pw.c +++ b/plugins/auth/sha256_pw.c @@ -229,14 +229,14 @@ static int auth_sha256_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) der_buffer_len= packet_length; /* Load pem and convert it to binary object. New length will be returned in der_buffer_len */ - if (!(der_buffer= ma_load_pem(filebuffer ? filebuffer : packet, &der_buffer_len))) + if (!(der_buffer= ma_load_pem(filebuffer ? filebuffer : (char *)packet, &der_buffer_len))) goto error; /* Create context and load public key */ if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, der_buffer, der_buffer_len, CRYPT_ENCODE_ALLOC_FLAG, NULL, - &publicKeyInfo, &publicKeyInfoLen)) + &publicKeyInfo, (DWORD *)&publicKeyInfoLen)) goto error; LocalFree(der_buffer); @@ -268,7 +268,7 @@ static int auth_sha256_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) if (RSA_public_encrypt(pwlen, (unsigned char *)passwd, rsa_enc_pw, pubkey, RSA_PKCS1_OAEP_PADDING) < 0) goto error; #elif defined(HAVE_WINCRYPT) - if (!CryptEncrypt(pubkey, 0, TRUE, CRYPT_OAEP, passwd, &pwlen, MAX_PW_LEN)) + if (!CryptEncrypt(pubkey, 0, TRUE, CRYPT_OAEP, passwd, (DWORD *)&pwlen, MAX_PW_LEN)) goto error; /* Windows encrypts as little-endian, while server (openssl) expects big-endian, so we have to revert the string */ diff --git a/plugins/pvio/pvio_npipe.c b/plugins/pvio/pvio_npipe.c index f16beec6..d745027b 100644 --- a/plugins/pvio/pvio_npipe.c +++ b/plugins/pvio/pvio_npipe.c @@ -162,7 +162,6 @@ end: int pvio_npipe_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout) { - int r= -1; DWORD status; int save_error; struct st_pvio_npipe *cpipe= NULL; diff --git a/plugins/pvio/pvio_shmem.c b/plugins/pvio/pvio_shmem.c index 09586c63..86cd2ba1 100644 --- a/plugins/pvio/pvio_shmem.c +++ b/plugins/pvio/pvio_shmem.c @@ -243,7 +243,7 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) char *shm_name, *shm_suffix, *shm_prefix; uchar i= 0; int len; - DWORD cid; + int cid; DWORD dwDesiredAccess= EVENT_MODIFY_STATE | SYNCHRONIZE; HANDLE hdlConnectRequest= NULL, hdlConnectRequestAnswer= NULL, diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index 737ca15f..6255b372 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -64,6 +64,10 @@ #define SOCKET_ERROR -1 #endif +#ifndef INVALID_SOCKET +#define INVALID_SOCKET -1 +#endif + #define DNS_TIMEOUT 30 #ifndef O_NONBLOCK @@ -732,7 +736,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) return 1; } pvio->data= (void *)csock; - csock->socket= -1; + csock->socket= INVALID_SOCKET; mysql= pvio->mysql= cinfo->mysql; pvio->type= cinfo->type; @@ -741,7 +745,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) #ifndef _WIN32 #ifdef HAVE_SYS_UN_H struct sockaddr_un UNIXaddr; - if ((csock->socket = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) + if ((csock->socket = socket(AF_UNIX,SOCK_STREAM,0)) == INVALID_SOCKET) { PVIO_SET_ERROR(cinfo->mysql, CR_SOCKET_CREATE_ERROR, unknown_sqlstate, 0, errno); goto error; @@ -843,7 +847,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) { csock->socket= socket(save_res->ai_family, save_res->ai_socktype, save_res->ai_protocol); - if (csock->socket == SOCKET_ERROR) + if (csock->socket == INVALID_SOCKET) /* Errors will be handled after loop finished */ continue; @@ -881,7 +885,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) if (bind_res) freeaddrinfo(bind_res); - if (csock->socket == SOCKET_ERROR) + if (csock->socket == INVALID_SOCKET) { PVIO_SET_ERROR(cinfo->mysql, CR_IPSOCK_ERROR, SQLSTATE_UNKNOWN, ER(CR_IPSOCK_ERROR), socket_errno); @@ -919,7 +923,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) return 0; error: /* close socket: MDEV-10891 */ - if (csock->socket != -1) + if (csock->socket != INVALID_SOCKET) closesocket(csock->socket); if (pvio->data) { @@ -941,11 +945,10 @@ my_bool pvio_socket_close(MARIADB_PVIO *pvio) if (pvio->data) { csock= (struct st_pvio_socket *)pvio->data; - if (csock && csock->socket != -1) + if (csock && csock->socket != INVALID_SOCKET) { - r= shutdown(csock->socket ,2); r= closesocket(csock->socket); - csock->socket= -1; + csock->socket= INVALID_SOCKET; } free((gptr)pvio->data); pvio->data= NULL; diff --git a/unittest/libmariadb/ma_getopt.c b/unittest/libmariadb/ma_getopt.c index 411f4ba7..00064af1 100644 --- a/unittest/libmariadb/ma_getopt.c +++ b/unittest/libmariadb/ma_getopt.c @@ -45,10 +45,9 @@ Cambridge, MA 02139, USA. */ #define const #endif #endif - -#include /* Changes for mysys */ -#include - +#include +#include +#include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling