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 /storage/myisam | |
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 'storage/myisam')
-rw-r--r-- | storage/myisam/ft_boolean_search.c | 6 | ||||
-rw-r--r-- | storage/myisam/ft_myisam.c | 4 | ||||
-rw-r--r-- | storage/myisam/ft_parser.c | 2 | ||||
-rw-r--r-- | storage/myisam/ft_stopwords.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_cache.c | 12 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 22 | ||||
-rw-r--r-- | storage/myisam/mi_locking.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_open.c | 6 | ||||
-rw-r--r-- | storage/myisam/mi_preload.c | 4 | ||||
-rw-r--r-- | storage/myisam/mi_test1.c | 10 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 2 |
11 files changed, 40 insertions, 40 deletions
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 0649d02b73f..8065bb696a1 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -290,7 +290,7 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, info.prev= ' '; info.quot= 0; while (ft_get_word(cs, start, end, &w, &info)) - param->mysql_add_word(param, (char*) w.pos, w.len, &info); + param->mysql_add_word(param, (char*) w.pos, (int)w.len, &info); return(0); } @@ -675,7 +675,7 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, while (ft_simple_get_word(phrase_param->cs, (uchar**) &document, docend, &word, FALSE)) { - param->mysql_add_word(param, (char*) word.pos, word.len, 0); + param->mysql_add_word(param, (char*) word.pos, (int)word.len, 0); if (phrase_param->match) break; } @@ -961,7 +961,7 @@ static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, uchar *end= (uchar*) doc + len; FT_WORD w; while (ft_simple_get_word(ftb->charset, (uchar**) &doc, end, &w, TRUE)) - param->mysql_add_word(param, (char*) w.pos, w.len, 0); + param->mysql_add_word(param, (char*) w.pos, (int)w.len, 0); return(0); } diff --git a/storage/myisam/ft_myisam.c b/storage/myisam/ft_myisam.c index 4e1879fa8ce..4cbf67ba30f 100644 --- a/storage/myisam/ft_myisam.c +++ b/storage/myisam/ft_myisam.c @@ -28,9 +28,9 @@ FT_INFO *ft_init_search(uint flags, void *info, uint keynr, { FT_INFO *res; if (flags & FT_BOOL) - res= ft_init_boolean_search((MI_INFO *)info, keynr, query, query_len,cs); + res= ft_init_boolean_search((MI_INFO *)info, keynr, query, (uint)query_len,cs); else - res= ft_init_nlq_search((MI_INFO *)info, keynr, query, query_len, flags, + res= ft_init_nlq_search((MI_INFO *)info, keynr, query, (uint)query_len, flags, record); return res; } diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index c36a3e3f5c8..aec7bd338ac 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -295,7 +295,7 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, DBUG_ENTER("ft_parse_internal"); while (ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE)) - if (param->mysql_add_word(param, (char*) w.pos, w.len, 0)) + if (param->mysql_add_word(param, (char*) w.pos, (int)w.len, 0)) DBUG_RETURN(1); DBUG_RETURN(0); } diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 7c743743adc..7294106b569 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -77,7 +77,7 @@ int ft_init_stopwords() if (ft_stopword_file) { File fd; - uint len; + size_t len; uchar *buffer, *start, *end; FT_WORD w; int error=-1; @@ -87,7 +87,7 @@ int ft_init_stopwords() if ((fd=my_open(ft_stopword_file, O_RDONLY, MYF(MY_WME))) == -1) DBUG_RETURN(-1); - len=(uint)my_seek(fd, 0L, MY_SEEK_END, MYF(0)); + len=(size_t)my_seek(fd, 0L, MY_SEEK_END, MYF(0)); my_seek(fd, 0L, MY_SEEK_SET, MYF(0)); if (!(start=buffer=my_malloc(len+1, MYF(MY_WME)))) goto err0; @@ -124,7 +124,7 @@ int is_stopword(const char *word, size_t len) { FT_STOPWORD sw; sw.pos=word; - sw.len=len; + sw.len=(uint)len; return tree_search(stopwords3,&sw, stopwords3->custom_arg) != NULL; } diff --git a/storage/myisam/mi_cache.c b/storage/myisam/mi_cache.c index 6fa599ff981..012d410c793 100644 --- a/storage/myisam/mi_cache.c +++ b/storage/myisam/mi_cache.c @@ -35,10 +35,10 @@ #include "myisamdef.h" -int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, +int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, size_t length, int flag) { - uint read_length,in_buff_length; + size_t read_length,in_buff_length; my_off_t offset; uchar *in_buff_pos; DBUG_ENTER("_mi_read_cache"); @@ -48,7 +48,7 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, { read_length=length; if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos)) - read_length=(uint) (info->pos_in_file-pos); + read_length=(size_t)(info->pos_in_file-pos); info->seek_not_done=1; if (mysql_file_pread(info->file, buff, read_length, pos, MYF(MY_NABP))) DBUG_RETURN(1); @@ -61,9 +61,9 @@ int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, (offset= (my_off_t) (pos - info->pos_in_file)) < (my_off_t) (info->read_end - info->request_pos)) { - in_buff_pos=info->request_pos+(uint) offset; - in_buff_length= MY_MIN(length, (size_t) (info->read_end-in_buff_pos)); - memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length); + in_buff_pos=info->request_pos+ (uint)offset; + in_buff_length= MY_MIN(length, (size_t)(info->read_end-in_buff_pos)); + memcpy(buff,info->request_pos+(uint) offset, in_buff_length); if (!(length-=in_buff_length)) DBUG_RETURN(0); pos+=in_buff_length; diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 9a2526ad2cf..52066c0033d 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -74,8 +74,8 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++) { enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type; - uint length=keyseg->length; - uint char_length; + size_t length=keyseg->length; + size_t char_length; CHARSET_INFO *cs=keyseg->charset; if (keyseg->null_bit) @@ -116,11 +116,11 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, uchar *end= pos + length; while (pos < end && pos[0] == ' ') pos++; - length=(uint) (end-pos); + length=(size_t) (end-pos); } FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); + memcpy(key, pos,char_length); key+=char_length; continue; } @@ -133,7 +133,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); + memcpy(key, pos, char_length); key+= char_length; continue; } @@ -144,7 +144,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); + memcpy(key, pos, char_length); key+= char_length; continue; } @@ -235,8 +235,8 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, old+= keyseg->length, keyseg++) { enum ha_base_keytype type= (enum ha_base_keytype) keyseg->type; - uint length= keyseg->length; - uint char_length; + size_t length= keyseg->length; + size_t char_length; uchar *pos; CHARSET_INFO *cs=keyseg->charset; @@ -259,7 +259,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, uchar *end= pos + length; while (pos < end && pos[0] == ' ') pos++; - length= (uint) (end - pos); + length= (size_t)(end - pos); } else if (type != HA_KEYTYPE_BINARY) { @@ -267,7 +267,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, } FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((uchar*) key,pos,(size_t) char_length); + memcpy(key,pos,char_length); key+= char_length; continue; } @@ -280,7 +280,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); old+=2; /* Skip length */ - memcpy((uchar*) key, pos,(size_t) char_length); + memcpy(key, pos, char_length); key+= char_length; continue; } diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 1921926463e..5e5e56db6e8 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -608,7 +608,7 @@ int _mi_mark_file_changed(MI_INFO *info) { mi_int2store(buff,share->state.open_count); buff[2]=1; /* Mark that it's changed */ - DBUG_RETURN(mysql_file_pwrite(share->kfile, buff, sizeof(buff), + DBUG_RETURN((int)mysql_file_pwrite(share->kfile, buff, sizeof(buff), sizeof(share->state.header), MYF(MY_NABP))); } @@ -637,9 +637,9 @@ int _mi_decrement_open_count(MI_INFO *info) { share->state.open_count--; mi_int2store(buff,share->state.open_count); - write_error= mysql_file_pwrite(share->kfile, buff, sizeof(buff), + write_error= (mysql_file_pwrite(share->kfile, buff, sizeof(buff), sizeof(share->state.header), - MYF(MY_NABP)); + MYF(MY_NABP)) != 0); } if (!lock_error && !my_disable_locking) lock_error=mi_lock_database(info,old_lock); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 41b0e18da02..a50fe0879c3 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -127,7 +127,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share= &share_buff; bzero((uchar*) &share_buff,sizeof(share_buff)); share_buff.key_cache= multi_key_cache_search((uchar*) name_buff, - strlen(name_buff), + (uint)strlen(name_buff), dflt_key_cache); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_open", @@ -342,7 +342,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (char*) key_del, (sizeof(my_off_t) * share->state.header.max_block_size_index)); strmov(share->unique_file_name, name_buff); - share->unique_name_length= strlen(name_buff); + share->unique_name_length= (uint)strlen(name_buff); strmov(share->index_file_name, index_name); strmov(share->data_file_name, data_name); @@ -687,7 +687,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (myisam_log_file >= 0) { intern_filename(name_buff,share->index_file_name); - _myisam_log(MI_LOG_OPEN, m_info, (uchar*) name_buff, strlen(name_buff)); + _myisam_log(MI_LOG_OPEN, m_info, (uchar*) name_buff, (uint)strlen(name_buff)); } DBUG_RETURN(m_info); diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index e0d23e0fca0..5c782defcde 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -98,7 +98,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, - (uchar*) buff, block_length)) + buff, (uint)block_length)) goto err; } pos+= block_length; @@ -110,7 +110,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, - (uchar*) buff, length)) + (uchar*) buff, (uint)length)) goto err; pos+= length; } diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index bc1f6438e31..61e992694d2 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -386,7 +386,7 @@ static void create_key(uchar *key,uint rownr) } if (keyinfo[0].seg[0].flag & (HA_BLOB_PART | HA_VAR_LENGTH_PART)) { - uint tmp; + size_t tmp; create_key_part(key+2,rownr); tmp=strlen((char*) key+2); int2store(key,tmp); @@ -411,7 +411,7 @@ static void create_record(uchar *record,uint rownr) pos=record+1; if (recinfo[1].type == FIELD_BLOB) { - uint tmp; + size_t tmp; uchar *ptr; create_key_part(blob_key,rownr); tmp=strlen((char*) blob_key); @@ -422,7 +422,7 @@ static void create_record(uchar *record,uint rownr) } else if (recinfo[1].type == FIELD_VARCHAR) { - uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); + size_t tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); create_key_part(pos+pack_length,rownr); tmp= strlen((char*) pos+pack_length); if (pack_length == 1) @@ -438,7 +438,7 @@ static void create_record(uchar *record,uint rownr) } if (recinfo[2].type == FIELD_BLOB) { - uint tmp; + size_t tmp; uchar *ptr;; sprintf((char*) blob_record,"... row: %d", rownr); strappend((char*) blob_record,MY_MAX(MAX_REC_LENGTH-rownr,10),' '); @@ -449,7 +449,7 @@ static void create_record(uchar *record,uint rownr) } else if (recinfo[2].type == FIELD_VARCHAR) { - uint tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); + size_t tmp, pack_length= HA_VARCHAR_PACKLENGTH(recinfo[1].length-1); sprintf((char*) pos+pack_length, "... row: %d", rownr); tmp= strlen((char*) pos+pack_length); if (pack_length == 1) diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 1431f98ec1b..2c0c1eec49a 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -561,7 +561,7 @@ extern uint _mi_pack_key(MI_INFO *info, uint keynr, uchar *key, HA_KEYSEG ** last_used_keyseg); extern int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf); extern int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, - uint length, int re_read_if_possibly); + size_t length, int re_read_if_possibly); extern ulonglong retrieve_auto_increment(MI_INFO *info, const uchar *record); extern uchar *mi_alloc_rec_buff(MI_INFO *, ulong, uchar **); |