From 6c279ad6a71c63cb595fde7c951aadb31c3dbebc Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 6 Feb 2018 12:55:58 +0000 Subject: 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. --- storage/federatedx/federatedx_io_mysql.cc | 19 ++++++++++--------- storage/federatedx/federatedx_io_null.cc | 4 ++-- storage/federatedx/ha_federatedx.cc | 10 +++++----- storage/federatedx/ha_federatedx.h | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) (limited to 'storage/federatedx') diff --git a/storage/federatedx/federatedx_io_mysql.cc b/storage/federatedx/federatedx_io_mysql.cc index 2068716eeba..a83e54513d3 100644 --- a/storage/federatedx/federatedx_io_mysql.cc +++ b/storage/federatedx/federatedx_io_mysql.cc @@ -69,14 +69,14 @@ class federatedx_io_mysql :public federatedx_io bool requested_autocommit; bool actual_autocommit; - int actual_query(const char *buffer, uint length); + int actual_query(const char *buffer, size_t length); bool test_all_restrict() const; public: federatedx_io_mysql(FEDERATEDX_SERVER *); ~federatedx_io_mysql(); int simple_query(const char *fmt, ...); - int query(const char *buffer, uint length); + int query(const char *buffer, size_t length); virtual FEDERATEDX_IO_RESULT *store_result(); virtual size_t max_query_size() const; @@ -273,7 +273,7 @@ ulong federatedx_io_mysql::savepoint_release(ulong sp) if (last) { char buffer[STRING_BUFFER_USUAL_SIZE]; - int length= my_snprintf(buffer, sizeof(buffer), + size_t length= my_snprintf(buffer, sizeof(buffer), "RELEASE SAVEPOINT save%lu", last->level); actual_query(buffer, length); } @@ -308,7 +308,7 @@ ulong federatedx_io_mysql::savepoint_rollback(ulong sp) if (savept && !(savept->flags & SAVEPOINT_RESTRICT)) { char buffer[STRING_BUFFER_USUAL_SIZE]; - int length= my_snprintf(buffer, sizeof(buffer), + size_t length= my_snprintf(buffer, sizeof(buffer), "ROLLBACK TO SAVEPOINT save%lu", savept->level); actual_query(buffer, length); } @@ -341,7 +341,8 @@ void federatedx_io_mysql::savepoint_restrict(ulong sp) int federatedx_io_mysql::simple_query(const char *fmt, ...) { char buffer[STRING_BUFFER_USUAL_SIZE]; - int length, error; + size_t length; + int error; va_list arg; DBUG_ENTER("federatedx_io_mysql::simple_query"); @@ -377,7 +378,7 @@ bool federatedx_io_mysql::test_all_restrict() const } -int federatedx_io_mysql::query(const char *buffer, uint length) +int federatedx_io_mysql::query(const char *buffer, size_t length) { int error; bool wants_autocommit= requested_autocommit | is_readonly(); @@ -402,7 +403,7 @@ int federatedx_io_mysql::query(const char *buffer, uint length) if (!(savept->flags & SAVEPOINT_RESTRICT)) { char buf[STRING_BUFFER_USUAL_SIZE]; - int len= my_snprintf(buf, sizeof(buf), + size_t len= my_snprintf(buf, sizeof(buf), "SAVEPOINT save%lu", savept->level); if ((error= actual_query(buf, len))) DBUG_RETURN(error); @@ -419,7 +420,7 @@ int federatedx_io_mysql::query(const char *buffer, uint length) } -int federatedx_io_mysql::actual_query(const char *buffer, uint length) +int federatedx_io_mysql::actual_query(const char *buffer, size_t length) { int error; DBUG_ENTER("federatedx_io_mysql::actual_query"); @@ -452,7 +453,7 @@ int federatedx_io_mysql::actual_query(const char *buffer, uint length) mysql.reconnect= 1; } - error= mysql_real_query(&mysql, buffer, length); + error= mysql_real_query(&mysql, buffer, (ulong)length); DBUG_RETURN(error); } diff --git a/storage/federatedx/federatedx_io_null.cc b/storage/federatedx/federatedx_io_null.cc index aa35d4bdecc..1976f22124a 100644 --- a/storage/federatedx/federatedx_io_null.cc +++ b/storage/federatedx/federatedx_io_null.cc @@ -58,7 +58,7 @@ public: federatedx_io_null(FEDERATEDX_SERVER *); ~federatedx_io_null(); - int query(const char *buffer, uint length); + int query(const char *buffer, size_t length); virtual FEDERATEDX_IO_RESULT *store_result(); virtual size_t max_query_size() const; @@ -178,7 +178,7 @@ void federatedx_io_null::savepoint_restrict(ulong sp) } -int federatedx_io_null::query(const char *buffer, uint length) +int federatedx_io_null::query(const char *buffer, size_t length) { return 0; } diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 8d5eee99476..8c21906fe84 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -482,7 +482,7 @@ int federatedx_done(void *p) in sql_show.cc except that quoting always occurs. */ -bool append_ident(String *string, const char *name, uint length, +bool append_ident(String *string, const char *name, size_t length, const char quote_char) { bool result; @@ -520,7 +520,7 @@ static int parse_url_error(FEDERATEDX_SHARE *share, TABLE_SHARE *table_s, int error_num) { char buf[FEDERATEDX_QUERY_BUFFER_SIZE]; - int buf_len; + size_t buf_len; DBUG_ENTER("ha_federatedx parse_url_error"); buf_len= MY_MIN(table_s->connect_string.length, @@ -1583,7 +1583,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table) mysql_mutex_lock(&federatedx_mutex); tmp_share.share_key= table_name; - tmp_share.share_key_length= strlen(table_name); + tmp_share.share_key_length= (int)strlen(table_name); if (parse_url(&mem_root, &tmp_share, table->s, 0)) goto error; @@ -1768,7 +1768,7 @@ int ha_federatedx::open(const char *name, int mode, uint test_if_locked) DBUG_RETURN(error); } - ref_length= io->get_ref_length(); + ref_length= (uint)io->get_ref_length(); txn->release(&io); @@ -3066,7 +3066,7 @@ int ha_federatedx::info(uint flag) stats.block_size= 4096; if ((*iop)->table_metadata(&stats, share->table_name, - share->table_name_length, flag)) + (uint)share->table_name_length, flag)) goto error; } diff --git a/storage/federatedx/ha_federatedx.h b/storage/federatedx/ha_federatedx.h index 02b622b15af..f5affebc426 100644 --- a/storage/federatedx/ha_federatedx.h +++ b/storage/federatedx/ha_federatedx.h @@ -120,7 +120,7 @@ typedef struct st_federatedx_share { int share_key_length; ushort port; - uint table_name_length, server_name_length, connect_string_length; + size_t table_name_length, server_name_length, connect_string_length; uint use_count; THR_LOCK lock; FEDERATEDX_SERVER *s; @@ -171,7 +171,7 @@ public: static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } - virtual int query(const char *buffer, uint length)=0; + virtual int query(const char *buffer, size_t length)=0; virtual FEDERATEDX_IO_RESULT *store_result()=0; virtual size_t max_query_size() const=0; @@ -450,7 +450,7 @@ extern const char ident_quote_char; // Character for quoting extern const char value_quote_char; // Character for quoting // literals -extern bool append_ident(String *string, const char *name, uint length, +extern bool append_ident(String *string, const char *name, size_t length, const char quote_char); -- cgit v1.2.1