summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
commit6c279ad6a71c63cb595fde7c951aadb31c3dbebc (patch)
tree3603f88e1b3bd1e622edb182cccd882dd31ddc8a /plugin
parentf271100836d8a91a775894ec36b869a66a3145e5 (diff)
downloadmariadb-git-6c279ad6a71c63cb595fde7c951aadb31c3dbebc.tar.gz
MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from 'size_t' to 'type', possible loss of data)
Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/auth_gssapi/server_plugin.cc2
-rw-r--r--plugin/auth_gssapi/sspi_errmsg.cc2
-rw-r--r--plugin/auth_gssapi/sspi_server.cc2
-rw-r--r--plugin/aws_key_management/aws_key_management_plugin.cc4
-rw-r--r--plugin/feedback/url_http.cc8
-rw-r--r--plugin/win_auth_client/common.cc10
-rw-r--r--plugin/win_auth_client/handshake.h2
-rw-r--r--plugin/win_auth_client/handshake_client.cc2
8 files changed, 16 insertions, 16 deletions
diff --git a/plugin/auth_gssapi/server_plugin.cc b/plugin/auth_gssapi/server_plugin.cc
index 6ffcf5c65c1..b991c764f05 100644
--- a/plugin/auth_gssapi/server_plugin.cc
+++ b/plugin/auth_gssapi/server_plugin.cc
@@ -110,7 +110,7 @@ static int initialize_plugin(void *unused)
strcpy(first_packet, srv_principal_name);
strcpy(first_packet + strlen(srv_principal_name) + 1,srv_mech_name);
- first_packet_len = strlen(srv_principal_name) + strlen(srv_mech_name) + 2;
+ first_packet_len = (int)(strlen(srv_principal_name) + strlen(srv_mech_name) + 2);
return 0;
}
diff --git a/plugin/auth_gssapi/sspi_errmsg.cc b/plugin/auth_gssapi/sspi_errmsg.cc
index 961ef51f42e..8e59da6f1ed 100644
--- a/plugin/auth_gssapi/sspi_errmsg.cc
+++ b/plugin/auth_gssapi/sspi_errmsg.cc
@@ -138,7 +138,7 @@ void sspi_errmsg(int err, char *buf, size_t size)
len = FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
err, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
- buf, size, NULL);
+ buf, (DWORD)size, NULL);
if(len > 0)
{
diff --git a/plugin/auth_gssapi/sspi_server.cc b/plugin/auth_gssapi/sspi_server.cc
index 73c74c2e200..140c6adf733 100644
--- a/plugin/auth_gssapi/sspi_server.cc
+++ b/plugin/auth_gssapi/sspi_server.cc
@@ -108,7 +108,7 @@ static int get_client_name_from_context(CtxtHandle *ctxt,
sspi_ret= ImpersonateSecurityContext(ctxt);
if (sspi_ret == SEC_E_OK)
{
- ULONG len= name_len;
+ ULONG len= (ULONG)name_len;
if (!GetUserNameEx(NameSamCompatible, name, &len))
{
log_error(GetLastError(), "GetUserNameEx");
diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc
index 60ca6fd1ff3..b99beb0774d 100644
--- a/plugin/aws_key_management/aws_key_management_plugin.cc
+++ b/plugin/aws_key_management/aws_key_management_plugin.cc
@@ -469,7 +469,7 @@ static int read_and_decrypt_key(const char *path, KEY_INFO *info)
return(ENCRYPTION_KEY_BUFFER_TOO_SMALL);
}
memcpy(info->data, plaintext.GetUnderlyingData(), len);
- info->length= len;
+ info->length= (unsigned int)len;
return(0);
}
@@ -527,7 +527,7 @@ static int generate_and_save_datakey(uint keyid, uint version)
my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Can't create file %s", ME_ERROR_LOG, filename);
return(-1);
}
- size_t len= byteBuffer.GetLength();
+ unsigned int len= (unsigned int)byteBuffer.GetLength();
if (write(fd, byteBuffer.GetUnderlyingData(), len) != len)
{
my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: can't write to %s", ME_ERROR_LOG, filename);
diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc
index 4851097e63f..76aef909756 100644
--- a/plugin/feedback/url_http.cc
+++ b/plugin/feedback/url_http.cc
@@ -40,9 +40,9 @@ class Url_http: public Url {
bool ssl;
LEX_STRING proxy_host, proxy_port;
- int use_proxy()
+ bool use_proxy()
{
- return proxy_host.length;
+ return proxy_host.length != 0;
}
Url_http(LEX_STRING &url_arg, LEX_STRING &host_arg,
@@ -166,7 +166,7 @@ int Url_http::send(const char* data, size_t data_length)
{
my_socket fd= INVALID_SOCKET;
char buf[1024];
- uint len= 0;
+ size_t len= 0;
addrinfo *addrs, *addr, filter= {0, AF_UNSPEC, SOCK_STREAM, 6, 0, 0, 0, 0};
int res= use_proxy() ?
@@ -186,7 +186,7 @@ int Url_http::send(const char* data, size_t data_length)
if (fd == INVALID_SOCKET)
continue;
- if (connect(fd, addr->ai_addr, addr->ai_addrlen) == 0)
+ if (connect(fd, addr->ai_addr, (int) addr->ai_addrlen) == 0)
break;
closesocket(fd);
diff --git a/plugin/win_auth_client/common.cc b/plugin/win_auth_client/common.cc
index 30a8e0b3b13..1c872c07e14 100644
--- a/plugin/win_auth_client/common.cc
+++ b/plugin/win_auth_client/common.cc
@@ -69,7 +69,7 @@ Connection::Connection(MYSQL_PLUGIN_VIO *vio): m_vio(vio), m_error(0)
int Connection::write(const Blob &blob)
{
- m_error= m_vio->write_packet(m_vio, blob.ptr(), blob.len());
+ m_error= m_vio->write_packet(m_vio, blob.ptr(), (int)blob.len());
#ifndef DBUG_OFF
if (m_error)
@@ -392,8 +392,8 @@ char* wchar_to_utf8(const wchar_t *string, size_t *len)
int res= WideCharToMultiByte(CP_UTF8, // convert to UTF-8
0, // conversion flags
string, // input buffer
- str_len, // its length
- buf, buf_len, // output buffer and its size
+ (int)str_len, // its length
+ buf, (int)buf_len, // output buffer and its size
NULL, NULL); // default character (not used)
if (res)
@@ -460,8 +460,8 @@ wchar_t* utf8_to_wchar(const char *string, size_t *len)
res= MultiByteToWideChar(CP_UTF8, // convert from UTF-8
0, // conversion flags
string, // input buffer
- buf_len, // its size
- buf, buf_len); // output buffer and its size
+ (int)buf_len, // its size
+ buf, (int)buf_len); // output buffer and its size
if (res)
{
buf[res]= '\0';
diff --git a/plugin/win_auth_client/handshake.h b/plugin/win_auth_client/handshake.h
index adab4715c99..bbad5ca36bc 100644
--- a/plugin/win_auth_client/handshake.h
+++ b/plugin/win_auth_client/handshake.h
@@ -49,7 +49,7 @@ class Security_buffer: public SecBufferDesc
m_buf.BufferType= SECBUFFER_TOKEN;
m_buf.pvBuffer= ptr;
- m_buf.cbBuffer= len;
+ m_buf.cbBuffer= (ULONG)len;
}
/// If @c false, no deallocation will be done in the destructor.
diff --git a/plugin/win_auth_client/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc
index 856dda76217..7969a6f3c49 100644
--- a/plugin/win_auth_client/handshake_client.cc
+++ b/plugin/win_auth_client/handshake_client.cc
@@ -160,7 +160,7 @@ int Handshake_client::write_packet(Blob &data)
Store in byte 255 the number of 512b blocks that are needed to
keep all the data.
*/
- unsigned block_count= data.len()/512 + ((data.len() % 512) ? 1 : 0);
+ unsigned block_count= (uint)(data.len()/512) + ((data.len() % 512) ? 1 : 0);
#if !defined(DBUG_OFF) && defined(WINAUTH_USE_DBUG_LIB)