diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-02-06 12:55:58 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-02-06 12:55:58 +0000 |
commit | 6c279ad6a71c63cb595fde7c951aadb31c3dbebc (patch) | |
tree | 3603f88e1b3bd1e622edb182cccd882dd31ddc8a /sql/protocol.cc | |
parent | f271100836d8a91a775894ec36b869a66a3145e5 (diff) | |
download | mariadb-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 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index fae399e66e2..032e79c9289 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -86,7 +86,7 @@ bool Protocol_binary::net_store_data_cs(const uchar *from, size_t length, { uint dummy_errors; /* Calculate maxumum possible result length */ - uint conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen; + size_t conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen; if (conv_length > 250) { @@ -106,8 +106,8 @@ bool Protocol_binary::net_store_data_cs(const uchar *from, size_t length, net_store_data((const uchar*) convert->ptr(), convert->length())); } - ulong packet_length= packet->length(); - ulong new_length= packet_length + conv_length + 1; + size_t packet_length= packet->length(); + size_t new_length= packet_length + conv_length + 1; if (new_length > packet->alloced_length() && packet->realloc(new_length)) return 1; @@ -480,8 +480,9 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, - ulonglong for bigger numbers. */ -static uchar *net_store_length_fast(uchar *packet, uint length) +static uchar *net_store_length_fast(uchar *packet, size_t length) { + DBUG_ASSERT(length < UINT_MAX16); if (length < 251) { *packet=(uchar) length; @@ -661,7 +662,7 @@ void net_send_progress_packet(THD *thd) { uchar buff[200], *pos; const char *proc_info= thd->proc_info ? thd->proc_info : ""; - uint length= strlen(proc_info); + size_t length= strlen(proc_info); ulonglong progress; DBUG_ENTER("net_send_progress_packet"); @@ -1015,7 +1016,7 @@ bool Protocol::store(const char *from, CHARSET_INFO *cs) { if (!from) return store_null(); - uint length= strlen(from); + size_t length= strlen(from); return store(from, length, cs); } |