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 /mysys | |
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 'mysys')
-rw-r--r-- | mysys/hash.c | 2 | ||||
-rw-r--r-- | mysys/lf_hash.c | 4 | ||||
-rw-r--r-- | mysys/mf_iocache.c | 2 | ||||
-rw-r--r-- | mysys/mf_keycache.c | 6 | ||||
-rw-r--r-- | mysys/my_compare.c | 4 | ||||
-rw-r--r-- | mysys/my_getopt.c | 4 | ||||
-rw-r--r-- | mysys/my_wincond.c | 5 | ||||
-rw-r--r-- | mysys/stacktrace.c | 8 | ||||
-rw-r--r-- | mysys/string.c | 6 |
9 files changed, 21 insertions, 20 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 57242735d99..d9952afe318 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -380,7 +380,7 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, my_bool my_hash_insert(HASH *info, const uchar *record) { int flag; - uint idx, halfbuff, first_index; + size_t idx, halfbuff, first_index; size_t length; my_hash_value_type current_hash_nr, UNINIT_VAR(rec_hash_nr), UNINIT_VAR(rec2_hash_nr); diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 6b3fa78475d..a7c07679993 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -86,12 +86,12 @@ typedef struct { 1 - error (callbck returned 1) */ static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, - const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins, + const uchar *key, size_t keylen, CURSOR *cursor, LF_PINS *pins, my_hash_walk_action callback) { uint32 cur_hashnr; const uchar *cur_key; - uint cur_keylen; + size_t cur_keylen; intptr link; DBUG_ASSERT(!cs || !callback); /* should not be set both */ diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 4dd0f7500aa..62d2b0a210c 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -557,7 +557,7 @@ int _my_b_read(IO_CACHE *info, uchar *Buffer, size_t Count) } res= info->read_function(info, Buffer, Count); if (res && info->error >= 0) - info->error+= left_length; /* update number or read bytes */ + info->error+= (int)left_length; /* update number or read bytes */ return res; } diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 2f0f2bf05c0..edf8cd3be8a 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -2429,7 +2429,7 @@ restart: The call is thread safe because only the current thread might change the block->hash_link value */ - error= my_pwrite(block->hash_link->file, + error= (int)my_pwrite(block->hash_link->file, block->buffer + block->offset, block->length - block->offset, block->hash_link->diskpos + block->offset, @@ -2674,7 +2674,7 @@ static void read_block_primary(SIMPLE_KEY_CACHE_CB *keycache, else { block->status|= BLOCK_READ; - block->length= got_length; + block->length= (uint)got_length; /* Do not set block->offset here. If this block is marked BLOCK_CHANGED later, we want to flush only the modified part. So @@ -3809,7 +3809,7 @@ static int flush_cached_blocks(SIMPLE_KEY_CACHE_CB *keycache, (BLOCK_READ | BLOCK_IN_FLUSH | BLOCK_CHANGED | BLOCK_IN_USE)); block->status|= BLOCK_IN_FLUSHWRITE; keycache_pthread_mutex_unlock(&keycache->cache_lock); - error= my_pwrite(file, block->buffer + block->offset, + error= (int)my_pwrite(file, block->buffer + block->offset, block->length - block->offset, block->hash_link->diskpos + block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); diff --git a/mysys/my_compare.c b/mysys/my_compare.c index 5ba1b409abb..4d384936a55 100644 --- a/mysys/my_compare.c +++ b/mysys/my_compare.c @@ -20,8 +20,8 @@ #include <my_compare.h> #include <my_sys.h> -int ha_compare_text(CHARSET_INFO *charset_info, const uchar *a, uint a_length, - const uchar *b, uint b_length, my_bool part_key) +int ha_compare_text(CHARSET_INFO *charset_info, const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool part_key) { if (!part_key) return charset_info->coll->strnncollsp(charset_info, a, a_length, diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 9e617366ed5..830b7f42473 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -826,7 +826,7 @@ static int setval(const struct my_option *opts, void *value, char *argument, *((ulonglong*)value)= find_set_from_flags(opts->typelib, opts->typelib->count, *(ulonglong *)value, opts->def_value, - argument, strlen(argument), + argument, (uint)strlen(argument), &error, &error_len); if (error) { @@ -1621,7 +1621,7 @@ void my_print_variables(const struct my_option *options) for (optp= options; optp->name; optp++) { - length= strlen(optp->name)+1; + length= (uint)strlen(optp->name)+1; if (length > name_space) name_space= length; } diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 54b272d7025..514e9a92ecf 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -98,9 +98,10 @@ int pthread_attr_init(pthread_attr_t *connect_att) return 0; } -int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack) +int pthread_attr_setstacksize(pthread_attr_t *connect_att,size_t stack) { - connect_att->dwStackSize=stack; + DBUG_ASSERT(stack < UINT_MAX); + connect_att->dwStackSize=(DWORD)stack; return 0; } diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 398ade7ad59..cc759d38664 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -70,7 +70,7 @@ static void print_buffer(char *buffer, size_t count) @return Zero on success. */ -static int safe_print_str(const char *addr, int max_len) +static int safe_print_str(const char *addr, size_t max_len) { int fd; pid_t tid; @@ -147,7 +147,7 @@ static int safe_print_str(const char *addr, int max_len) returns 1, it does not mean 100% that the pointer is corrupted. */ -int my_safe_print_str(const char* val, int max_len) +int my_safe_print_str(const char* val, size_t max_len) { char *heap_end; @@ -763,7 +763,7 @@ void my_write_core(int unused) } -int my_safe_print_str(const char *val, int len) +int my_safe_print_str(const char *val, size_t len) { __try { @@ -780,7 +780,7 @@ int my_safe_print_str(const char *val, int len) size_t my_write_stderr(const void *buf, size_t count) { - return (size_t) write(fileno(stderr), buf, count); + return (size_t) write(fileno(stderr), buf, (uint)count); } diff --git a/mysys/string.c b/mysys/string.c index a0fa3a02e17..18c5f4ec9af 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -178,9 +178,9 @@ my_bool dynstr_append_quoted(DYNAMIC_STRING *str, const char *append, size_t len, char quote) { - uint additional= (str->alloc_increment ? str->alloc_increment : 10); - uint lim= additional; - uint i; + size_t additional= (str->alloc_increment ? str->alloc_increment : 10); + size_t lim= additional; + size_t i; if (dynstr_realloc(str, len + additional + 2)) return TRUE; str->str[str->length++]= quote; |