Skip to content

Commit 0964a19

Browse files
committed
Bug#11752665: WINDOWS SERVER X64: SO MANY COMPILER WARNINGS
Patch #12: This patch reduces the compiler warning count on Win64 by an additional 180, as reported by VS2013. It also fixes most of the remaining Win32 warnings.
1 parent 054df2e commit 0964a19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+195
-161
lines changed

client/mysqlbinlog.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,13 +2208,13 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
22082208
if (stop_never_slave_server_id == -1)
22092209
server_id= 1;
22102210
else
2211-
server_id= stop_never_slave_server_id;
2211+
server_id= static_cast<uint>(stop_never_slave_server_id);
22122212
}
22132213
else
22142214
server_id= 0;
22152215

22162216
if (connection_server_id != -1)
2217-
server_id= connection_server_id;
2217+
server_id= static_cast<uint>(connection_server_id);
22182218

22192219
size_t tlen = strlen(logname);
22202220
if (tlen > UINT_MAX)
@@ -2778,8 +2778,8 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
27782778
my_off_t length,tmp;
27792779
for (length= start_position_mot ; length > 0 ; length-=tmp)
27802780
{
2781-
tmp= min<size_t>(length, sizeof(buff));
2782-
if (my_b_read(file, buff, (uint) tmp))
2781+
tmp= min(static_cast<size_t>(length), sizeof(buff));
2782+
if (my_b_read(file, buff, (uint) tmp))
27832783
{
27842784
error("Failed reading from file.");
27852785
goto err;

client/mysqlslap.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,9 @@ get_options(int *argc,char ***argv)
14131413
exit(1);
14141414
}
14151415
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED,
1416-
sbuf.st_size + 1,
1416+
(size_t)sbuf.st_size + 1,
14171417
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1418-
my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
1418+
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
14191419
tmp_string[sbuf.st_size]= '\0';
14201420
my_close(data_file,MYF(0));
14211421
parse_delimiter(tmp_string, &create_statements, delimiter[0]);
@@ -1441,9 +1441,9 @@ get_options(int *argc,char ***argv)
14411441
exit(1);
14421442
}
14431443
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED,
1444-
sbuf.st_size + 1,
1444+
(size_t)sbuf.st_size + 1,
14451445
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1446-
my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
1446+
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
14471447
tmp_string[sbuf.st_size]= '\0';
14481448
my_close(data_file,MYF(0));
14491449
if (user_supplied_query)
@@ -1473,9 +1473,9 @@ get_options(int *argc,char ***argv)
14731473
exit(1);
14741474
}
14751475
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED,
1476-
sbuf.st_size + 1,
1476+
(size_t)sbuf.st_size + 1,
14771477
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1478-
my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
1478+
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
14791479
tmp_string[sbuf.st_size]= '\0';
14801480
my_close(data_file,MYF(0));
14811481
if (user_supplied_pre_statements)
@@ -1505,9 +1505,9 @@ get_options(int *argc,char ***argv)
15051505
exit(1);
15061506
}
15071507
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED,
1508-
sbuf.st_size + 1,
1508+
(size_t)sbuf.st_size + 1,
15091509
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
1510-
my_read(data_file, (uchar*) tmp_string, sbuf.st_size, MYF(0));
1510+
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
15111511
tmp_string[sbuf.st_size]= '\0';
15121512
my_close(data_file,MYF(0));
15131513
if (user_supplied_post_statements)

extra/yassl/taocrypt/src/random.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <time.h>
2828

2929
#if defined(_WIN32)
30-
#define _WIN32_WINNT 0x0400
3130
#include <windows.h>
3231
#include <wincrypt.h>
3332
#else

include/keycache.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ typedef struct st_key_cache
5252
my_bool can_be_used; /* usage of cache for read/write is allowed */
5353
size_t key_cache_mem_size; /* specified size of the cache memory */
5454
uint key_cache_block_size; /* size of the page buffer of a cache block */
55-
ulong min_warm_blocks; /* min number of warm blocks; */
56-
ulong age_threshold; /* age threshold for hot blocks */
55+
ulonglong min_warm_blocks; /* min number of warm blocks; */
56+
ulonglong age_threshold; /* age threshold for hot blocks */
5757
ulonglong keycache_time; /* total number of block link operations */
5858
uint hash_entries; /* max number of entries in the hash table */
5959
int hash_links; /* max number of hash links */
@@ -109,10 +109,10 @@ typedef struct st_key_cache
109109
/* The default key cache */
110110
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
111111

112-
extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
112+
extern int init_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
113113
size_t use_mem, ulonglong division_limit,
114114
ulonglong age_threshold);
115-
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
115+
extern int resize_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
116116
size_t use_mem, ulonglong division_limit,
117117
ulonglong age_threshold);
118118
extern void change_key_cache_param(KEY_CACHE *keycache, ulonglong division_limit,

mysys/mf_keycache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static inline uint next_power(uint value)
359359
360360
*/
361361

362-
int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
362+
int init_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
363363
size_t use_mem, ulonglong division_limit,
364364
ulonglong age_threshold)
365365
{
@@ -397,8 +397,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
397397
}
398398

399399
keycache->key_cache_mem_size= use_mem;
400-
keycache->key_cache_block_size= key_cache_block_size;
401-
DBUG_PRINT("info", ("key_cache_block_size: %u",
400+
keycache->key_cache_block_size= (uint)key_cache_block_size;
401+
DBUG_PRINT("info", ("key_cache_block_size: %llu",
402402
key_cache_block_size));
403403

404404
blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
@@ -555,7 +555,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
555555
(when cnt_for_resize=0).
556556
*/
557557

558-
int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
558+
int resize_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
559559
size_t use_mem, ulonglong division_limit,
560560
ulonglong age_threshold)
561561
{

plugin/password_validation/validate_password.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static char *validate_password_dictionary_file;
6666
static void read_dictionary_file()
6767
{
6868
string_type words;
69-
long file_length;
69+
std::streamoff file_length;
7070

7171
if (validate_password_dictionary_file == NULL)
7272
{

sql-common/my_time.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ number_to_time(longlong nr, MYSQL_TIME *ltime, int *warnings)
874874
}
875875
ltime->time_type= MYSQL_TIMESTAMP_TIME;
876876
ltime->year= ltime->month= ltime->day= 0;
877-
TIME_set_hhmmss(ltime, nr);
877+
TIME_set_hhmmss(ltime, (uint)nr);
878878
ltime->second_part= 0;
879879
return FALSE;
880880
}
@@ -1837,11 +1837,11 @@ void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong tmp)
18371837

18381838
ltime->day= ymd % (1 << 5);
18391839
ltime->month= ym % 13;
1840-
ltime->year= ym / 13;
1840+
ltime->year= (uint)(ym / 13);
18411841

18421842
ltime->second= hms % (1 << 6);
18431843
ltime->minute= (hms >> 6) % (1 << 6);
1844-
ltime->hour= (hms >> 12);
1844+
ltime->hour= (uint)(hms >> 12);
18451845

18461846
ltime->time_type= MYSQL_TIMESTAMP_DATETIME;
18471847
}

sql/auth/sql_authentication.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ read_client_connect_attrs(char **ptr, size_t *max_bytes_available,
890890

891891
/* read the length */
892892
ptr_save= *ptr;
893-
length= net_field_length_ll((uchar **) ptr);
893+
length= static_cast<size_t>(net_field_length_ll((uchar **) ptr));
894894
length_length= *ptr - ptr_save;
895895
if (*max_bytes_available < length_length)
896896
return true;
@@ -2024,7 +2024,8 @@ check_password_lifetime(THD *thd, const ACL_USER *acl_user)
20242024
INTERVAL interval;
20252025

20262026
thd->set_time();
2027-
thd->variables.time_zone->gmt_sec_to_TIME(&cur_time, thd->query_start());
2027+
thd->variables.time_zone->gmt_sec_to_TIME(&cur_time,
2028+
static_cast<my_time_t>(thd->query_start()));
20282029
password_change_by= acl_user->password_last_changed;
20292030
memset(&interval, 0, sizeof(interval));
20302031

sql/auth/sql_user.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ bool change_password(THD *thd, const char *host, const char *user,
338338
goto end;
339339
}
340340
thd->variables.time_zone->gmt_sec_to_TIME(&acl_user->password_last_changed,
341-
thd->query_start());
341+
static_cast<my_time_t>(thd->query_start()));
342342

343343
}
344344
else
@@ -387,7 +387,7 @@ bool change_password(THD *thd, const char *host, const char *user,
387387
goto end;
388388
}
389389
thd->variables.time_zone->gmt_sec_to_TIME(&acl_user->password_last_changed,
390-
thd->query_start());
390+
static_cast<my_time_t>(thd->query_start()));
391391
}
392392
else
393393
{

sql/binlog.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ void check_binlog_cache_size(THD *thd)
798798
(ulong) binlog_cache_size,
799799
(ulong) max_binlog_cache_size);
800800
}
801-
binlog_cache_size= max_binlog_cache_size;
801+
binlog_cache_size= static_cast<ulong>(max_binlog_cache_size);
802802
}
803803
}
804804

@@ -824,7 +824,7 @@ void check_binlog_stmt_cache_size(THD *thd)
824824
(ulong) binlog_stmt_cache_size,
825825
(ulong) max_binlog_stmt_cache_size);
826826
}
827-
binlog_stmt_cache_size= max_binlog_stmt_cache_size;
827+
binlog_stmt_cache_size= static_cast<ulong>(max_binlog_stmt_cache_size);
828828
}
829829
}
830830

@@ -3676,9 +3676,10 @@ bool MYSQL_BIN_LOG::open_binlog(const char *log_name,
36763676
relay_log_checksum_alg :
36773677
/* otherwise use slave's local preference of RL events verification */
36783678
(opt_slave_sql_verify_checksum == 0) ?
3679-
(uint8) BINLOG_CHECKSUM_ALG_OFF : binlog_checksum_options):
3679+
static_cast<uint8>(BINLOG_CHECKSUM_ALG_OFF) :
3680+
static_cast<uint8>(binlog_checksum_options)):
36803681
/* binlog */
3681-
binlog_checksum_options;
3682+
static_cast<uint8>(binlog_checksum_options);
36823683
DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
36833684
if (!s.is_valid())
36843685
goto err;
@@ -6609,7 +6610,7 @@ void MYSQL_BIN_LOG::close(uint exiting)
66096610
Stop_log_event s;
66106611
// the checksumming rule for relay-log case is similar to Rotate
66116612
s.checksum_alg= is_relay_log ?
6612-
relay_log_checksum_alg : binlog_checksum_options;
6613+
relay_log_checksum_alg : static_cast<uint8>(binlog_checksum_options);
66136614
DBUG_ASSERT(!is_relay_log ||
66146615
relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
66156616
s.write(&log_file);

sql/discover.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
7070
error= 2;
7171
if (mysql_file_fstat(file, &state, MYF(0)))
7272
goto err;
73-
read_len= state.st_size;
73+
read_len= static_cast<size_t>(state.st_size);
7474

7575
// Read whole frm file
7676
error= 3;

sql/field.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4943,7 +4943,8 @@ Field_temporal::store_lldiv_t(const lldiv_t *lld, int *warnings)
49434943
ASSERT_COLUMN_MARKED_FOR_WRITE;
49444944
type_conversion_status error;
49454945
MYSQL_TIME ltime;
4946-
error= convert_number_to_TIME(lld->quot, 0, lld->rem, &ltime, warnings);
4946+
error= convert_number_to_TIME(lld->quot, 0, static_cast<int>(lld->rem),
4947+
&ltime, warnings);
49474948
if (error == TYPE_OK || error == TYPE_NOTE_TRUNCATED)
49484949
error= store_internal_with_round(&ltime, warnings);
49494950
else if (!*warnings)

sql/filesort.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ ha_rows filesort(THD *thd, QEP_TAB *qep_tab, Filesort *filesort,
383383
goto err;
384384
}
385385

386-
num_chunks= my_b_tell(&chunk_file)/sizeof(Merge_chunk);
386+
num_chunks= static_cast<size_t>(my_b_tell(&chunk_file)) /
387+
sizeof(Merge_chunk);
387388

388389
Opt_trace_object(trace, "filesort_summary")
389390
.add("rows", num_rows)
@@ -1673,18 +1674,19 @@ uint read_to_buffer(IO_CACHE *fromfile,
16731674
uint rec_length= param->rec_length;
16741675
ha_rows count;
16751676

1676-
if ((count= min<ha_rows>(merge_chunk->max_keys(), merge_chunk->rowcount())))
1677+
if ((count= min(merge_chunk->max_keys(), merge_chunk->rowcount())))
16771678
{
16781679
size_t bytes_to_read;
16791680
if (param->using_packed_addons())
16801681
{
16811682
count= merge_chunk->rowcount();
16821683
bytes_to_read=
1683-
min<my_off_t>(merge_chunk->buffer_size(),
1684-
fromfile->end_of_file - merge_chunk->file_position());
1684+
min(merge_chunk->buffer_size(),
1685+
static_cast<size_t>(fromfile->end_of_file -
1686+
merge_chunk->file_position()));
16851687
}
16861688
else
1687-
bytes_to_read= rec_length * count;
1689+
bytes_to_read= rec_length * static_cast<size_t>(count);
16881690

16891691
DBUG_PRINT("info", ("read_to_buffer %p at file_pos %llu bytes %llu",
16901692
merge_chunk,
@@ -1797,7 +1799,7 @@ int merge_buffers(Sort_param *param, IO_CACHE *from_file,
17971799
int error;
17981800
uint rec_length,res_length;
17991801
size_t sort_length;
1800-
ulong maxcount;
1802+
ha_rows maxcount;
18011803
ha_rows max_rows,org_max_rows;
18021804
my_off_t to_start_filepos;
18031805
uchar *strpos;

sql/ha_partition.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6842,7 +6842,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info,
68426842
stat_info->max_data_file_length= file->stats.max_data_file_length;
68436843
stat_info->index_file_length= file->stats.index_file_length;
68446844
stat_info->delete_length= file->stats.delete_length;
6845-
stat_info->create_time= file->stats.create_time;
6845+
stat_info->create_time= static_cast<ulong>(file->stats.create_time);
68466846
stat_info->update_time= file->stats.update_time;
68476847
stat_info->check_time= file->stats.check_time;
68486848
stat_info->check_sum= 0;

sql/handler.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,7 +4789,7 @@ void handler::get_dynamic_partition_info(PARTITION_STATS *stat_info,
47894789
stat_info->max_data_file_length= stats.max_data_file_length;
47904790
stat_info->index_file_length= stats.index_file_length;
47914791
stat_info->delete_length= stats.delete_length;
4792-
stat_info->create_time= stats.create_time;
4792+
stat_info->create_time= static_cast<ulong>(stats.create_time);
47934793
stat_info->update_time= stats.update_time;
47944794
stat_info->check_time= stats.check_time;
47954795
stat_info->check_sum= 0;
@@ -5832,10 +5832,13 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
58325832

58335833
DBUG_ASSERT(cost->is_zero());
58345834
if (*flags & HA_MRR_INDEX_ONLY)
5835-
*cost= index_scan_cost(keyno, n_ranges, total_rows);
5835+
*cost= index_scan_cost(keyno, static_cast<double>(n_ranges),
5836+
static_cast<double>(total_rows));
58365837
else
5837-
*cost= read_cost(keyno, n_ranges, total_rows);
5838-
cost->add_cpu(cost_model->row_evaluate_cost(total_rows) + 0.01);
5838+
*cost= read_cost(keyno, static_cast<double>(n_ranges),
5839+
static_cast<double>(total_rows));
5840+
cost->add_cpu(cost_model->row_evaluate_cost(
5841+
static_cast<double>(total_rows)) + 0.01);
58395842
}
58405843
return total_rows;
58415844
}
@@ -6661,13 +6664,14 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
66616664
cost->add_mem(*buffer_size);
66626665

66636666
/* Total cost of all index accesses */
6664-
(*cost)+= h->index_scan_cost(keynr, 1, rows);
6667+
(*cost)+= h->index_scan_cost(keynr, 1, static_cast<double>(rows));
66656668

66666669
/*
66676670
Add CPU cost for processing records (see
66686671
@handler::multi_range_read_info_const()).
66696672
*/
6670-
cost->add_cpu(table->cost_model()->row_evaluate_cost(rows));
6673+
cost->add_cpu(table->cost_model()->row_evaluate_cost(
6674+
static_cast<double>(rows)));
66716675
return FALSE;
66726676
}
66736677

sql/handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ class ha_statistics
18011801
ha_rows records;
18021802
ha_rows deleted; /* Deleted records */
18031803
ulong mean_rec_length; /* physical reclength */
1804-
ulong create_time; /* When table was created */
1804+
time_t create_time; /* When table was created */
18051805
ulong check_time;
18061806
ulong update_time;
18071807
uint block_size; /* index block size */

sql/item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ class Item : public Parse_tree_node
12931293
12941294
@return The value val_int() should return.
12951295
*/
1296-
longlong error_int()
1296+
int error_int()
12971297
{
12981298
null_value= maybe_null;
12991299
return 0;

sql/item_cmpfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
13241324
return ~(ulonglong) 0;
13251325

13261326
/* Convert year to DATETIME packed format */
1327-
return year_to_longlong_datetime_packed(value);
1327+
return year_to_longlong_datetime_packed(static_cast<long>(value));
13281328
}
13291329

13301330

@@ -7012,7 +7012,7 @@ float Item_equal::get_filtering_effect(table_map filter_for_table,
70127012
if (cur_field->field->key_start.is_set(j) &&
70137013
tab->key_info[j].has_records_per_key(0))
70147014
{
7015-
cur_filter= tab->key_info[j].records_per_key(0) / rows_in_table;
7015+
cur_filter= static_cast<float>(tab->key_info[j].records_per_key(0) / rows_in_table);
70167016
break;
70177017
}
70187018
}

0 commit comments

Comments
 (0)