Skip to content

Commit 1c7756c

Browse files
committed
Bug#11752665: WINDOWS SERVER X64: SO MANY COMPILER WARNINGS
Patch #8: This patch reduces the compiler warning count on Win64 by an additional 230, as reported by VS2013.
1 parent b2c1c14 commit 1c7756c

Some content is hidden

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

62 files changed

+230
-226
lines changed

client/mysql.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ static int read_and_execute(bool interactive)
21332133
ulong line_number=0;
21342134
bool ml_comment= 0;
21352135
COMMANDS *com;
2136-
ulong line_length= 0;
2136+
size_t line_length= 0;
21372137
status.exit_status=1;
21382138

21392139
real_binary_mode= !interactive && opt_binary_mode;
@@ -3823,7 +3823,7 @@ print_table_data(MYSQL_RES *result)
38233823
separator.copy("+",1,charset_info);
38243824
while ((field = mysql_fetch_field(result)))
38253825
{
3826-
uint length= column_names ? field->name_length : 0;
3826+
size_t length= column_names ? field->name_length : 0;
38273827
if (quick)
38283828
length= max<size_t>(length, field->length);
38293829
else
@@ -3842,7 +3842,7 @@ print_table_data(MYSQL_RES *result)
38423842
(void) tee_fputs("|", PAGER);
38433843
for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
38443844
{
3845-
uint name_length= (uint) strlen(field->name);
3845+
size_t name_length= strlen(field->name);
38463846
uint numcells= charset_info->cset->numcells(charset_info,
38473847
field->name,
38483848
field->name + name_length);
@@ -3868,7 +3868,7 @@ print_table_data(MYSQL_RES *result)
38683868
const char *buffer;
38693869
uint data_length;
38703870
uint field_max_length;
3871-
uint visible_length;
3871+
size_t visible_length;
38723872
uint extra_padding;
38733873

38743874
if (off)

client/mysql_config_editor.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static void remove_option(DYNAMIC_STRING *file_buf, const char *path_name,
978978

979979
char *start= NULL, *end= NULL;
980980
char *search_str;
981-
int search_len, shift_len;
981+
size_t search_len, shift_len;
982982
bool option_found= FALSE;
983983

984984
search_str= (char *) my_malloc(PSI_NOT_INSTRUMENTED,

client/mysql_secure_installation.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void execute_query_with_message(const char *query, const char *opt_message)
258258
return FALSE in case of success
259259
TRUE in case of failure
260260
*/
261-
bool execute_query(const char **query, unsigned int length)
261+
bool execute_query(const char **query, size_t length)
262262
{
263263
if (!mysql_real_query(&mysql, (const char *) *query, length))
264264
return FALSE;
@@ -363,7 +363,7 @@ int install_password_validation_plugin()
363363
}
364364
char *query, *end;
365365
int tmp= sizeof("SET GLOBAL validate_password_policy = ") + 3;
366-
int strength_length= strlen(strength);
366+
size_t strength_length= strlen(strength);
367367
/*
368368
query string needs memory which is atleast the length of initial part
369369
of query plus twice the size of variable being appended.
@@ -395,8 +395,8 @@ int install_password_validation_plugin()
395395
void estimate_password_strength(char *password_string)
396396
{
397397
char *query, *end;
398-
int tmp= sizeof("SELECT validate_password_strength(") + 3;
399-
int password_length= strlen(password_string);
398+
size_t tmp= sizeof("SELECT validate_password_strength(") + 3;
399+
size_t password_length= strlen(password_string);
400400
/*
401401
query string needs memory which is atleast the length of initial part
402402
of query plus twice the size of variable being appended.
@@ -438,7 +438,7 @@ void estimate_password_strength(char *password_string)
438438

439439
my_bool mysql_set_password(MYSQL *mysql, char *password)
440440
{
441-
int password_len= strlen(password);
441+
size_t password_len= strlen(password);
442442
char *query, *end;
443443
query= (char *)my_malloc(PSI_NOT_INSTRUMENTED, password_len+50, MYF(MY_WME));
444444
end= my_stpmov(query, "SET PASSWORD= PASSWORD('");
@@ -476,7 +476,7 @@ my_bool mysql_set_password(MYSQL *mysql, char *password)
476476
my_bool mysql_expire_password(MYSQL *mysql)
477477
{
478478
char sql[]= "UPDATE mysql.user SET password_expired= 'Y'";
479-
int sql_len= strlen(sql);
479+
size_t sql_len= strlen(sql);
480480
if (mysql_real_query(mysql, sql, sql_len))
481481
return FALSE;
482482

@@ -537,7 +537,7 @@ static void set_root_password(int plugin_set)
537537
"Yes, any other key for No) : ");
538538
}
539539

540-
int pass_length= strlen(password1);
540+
size_t pass_length= strlen(password1);
541541

542542
if ((!plugin_set) || (reply == (int) 'y' || reply == (int) 'Y'))
543543
{
@@ -689,7 +689,7 @@ void drop_users(MYSQL_RES *result)
689689
while ((row= mysql_fetch_row(result)))
690690
{
691691
char *query, *end;
692-
int user_length, host_length;
692+
size_t user_length, host_length;
693693
int tmp= sizeof("DROP USER ")+5;
694694
user_tmp= row[0];
695695
host_tmp= row[1];
@@ -843,8 +843,8 @@ my_bool find_temporary_password(char **p)
843843
if (home == NULL)
844844
home= root_path;
845845

846-
int home_len= strlen(home);
847-
int path_len= home_len + strlen(password_file_name)+1;
846+
size_t home_len= strlen(home);
847+
size_t path_len= home_len + strlen(password_file_name)+1;
848848
char *path= (char *)malloc(path_len);
849849
memset(path, 0, path_len);
850850

@@ -863,7 +863,7 @@ my_bool find_temporary_password(char **p)
863863
*/
864864
char header[256];
865865
char password[64];
866-
int password_len=0;
866+
size_t password_len=0;
867867
/* Read header and skip it */
868868
if (fgets(&header[0], sizeof(header), fp) == NULL || header[0] != '#')
869869
goto error;

client/mysqlbinlog.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
527527
uint file_id,
528528
Create_file_log_event *ce)
529529
{
530-
uint full_len= target_dir_name_len + blen + 9 + 9 + 1;
530+
size_t full_len= target_dir_name_len + blen + 9 + 9 + 1;
531531
Exit_status retval= OK_CONTINUE;
532532
char *fname, *ptr;
533533
File file;
@@ -603,7 +603,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
603603
Exit_status Load_log_processor::process(Create_file_log_event *ce)
604604
{
605605
const char *bname= ce->fname + dirname_length(ce->fname);
606-
uint blen= ce->fname_len - (bname-ce->fname);
606+
size_t blen= ce->fname_len - (bname-ce->fname);
607607

608608
return process_first_event(bname, blen, ce->block, ce->block_len,
609609
ce->file_id, ce);
@@ -2239,7 +2239,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
22392239
ptr_buffer+= BINLOG_NAME_INFO_SIZE;
22402240
int8store(ptr_buffer, start_position);
22412241
ptr_buffer+= ::BINLOG_POS_INFO_SIZE;
2242-
int4store(ptr_buffer, encoded_data_size);
2242+
int4store(ptr_buffer, static_cast<uint32>(encoded_data_size));
22432243
ptr_buffer+= ::BINLOG_DATA_SIZE_INFO_SIZE;
22442244
gtid_set_excluded->encode(ptr_buffer);
22452245
ptr_buffer+= encoded_data_size;

client/mysqltest.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ void handle_command_error(struct st_command *command, uint error)
13371337
{
13381338
const char var_name[]= "__error";
13391339
char buf[10];
1340-
int err_len= my_snprintf(buf, 10, "%u", error);
1340+
size_t err_len= my_snprintf(buf, 10, "%u", error);
13411341
buf[err_len > 9 ? 9 : err_len]= '0';
13421342
var_set(var_name, var_name + 7, buf, buf + err_len);
13431343
}
@@ -3143,8 +3143,8 @@ static void init_builtin_echo(void)
31433143
*/
31443144

31453145
static int replace(DYNAMIC_STRING *ds_str,
3146-
const char *search_str, ulong search_len,
3147-
const char *replace_str, ulong replace_len)
3146+
const char *search_str, size_t search_len,
3147+
const char *replace_str, size_t replace_len)
31483148
{
31493149
DYNAMIC_STRING ds_tmp;
31503150
const char *start= strstr(ds_str->str, search_str);
@@ -3289,7 +3289,7 @@ void do_exec(struct st_command *command)
32893289
{
32903290
const char var_name[]= "__error";
32913291
char buf[10];
3292-
int err_len= my_snprintf(buf, 10, "%u", error);
3292+
size_t err_len= my_snprintf(buf, 10, "%u", error);
32933293
buf[err_len > 9 ? 9 : err_len]= '0';
32943294
var_set(var_name, var_name + 7, buf, buf + err_len);
32953295
}

include/m_ctype.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ extern char *my_strchr(const CHARSET_INFO *cs, const char *str,
691691
const char *end, pchar c);
692692
extern size_t my_strcspn(const CHARSET_INFO *cs, const char *str,
693693
const char *end, const char *reject,
694-
int reject_length);
694+
size_t reject_length);
695695

696696
my_bool my_propagate_simple(const CHARSET_INFO *cs, const uchar *str,
697697
size_t len);

scripts/comp_sql.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
119119
char* infile_name= argv[2];
120120
char* outfile_name= argv[3];
121121
int rc;
122-
int query_length= 0;
122+
size_t query_length= 0;
123123
int error= 0;
124124
char *err_ptr;
125125

sql/auth/auth_common.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ extern my_bool validate_user_plugins;
378378

379379
/* sql_authentication */
380380

381-
int set_default_auth_plugin(char *plugin_name, int plugin_name_length);
382-
int acl_authenticate(THD *thd, uint com_change_user_pkt_len);
381+
int set_default_auth_plugin(char *plugin_name, size_t plugin_name_length);
382+
int acl_authenticate(THD *thd, size_t com_change_user_pkt_len);
383383
int check_password_strength(String *password);
384384
int check_password_policy(String *password);
385385
bool acl_check_host(const char *host, const char *ip);
@@ -388,7 +388,7 @@ bool acl_check_host(const char *host, const char *ip);
388388
void append_user(THD *thd, String *str, LEX_USER *user,
389389
bool comma, bool ident);
390390
int check_change_password(THD *thd, const char *host, const char *user,
391-
const char *password, uint password_len);
391+
const char *password, size_t password_len);
392392
bool change_password(THD *thd, const char *host, const char *user,
393393
char *password);
394394
bool mysql_create_user(THD *thd, List <LEX_USER> &list);

sql/auth/auth_internal.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ ACL_PROXY_USER * acl_find_proxy_user(const char *user,
6262
bool *proxy_used);
6363
bool set_user_salt(ACL_USER *acl_user,
6464
const char *password,
65-
uint password_len);
65+
size_t password_len);
6666
void acl_insert_proxy_user(ACL_PROXY_USER *new_value);
6767

6868
void acl_update_user(const char *user, const char *host,
69-
const char *password, uint password_len,
69+
const char *password, size_t password_len,
7070
enum SSL_type ssl_type,
7171
const char *ssl_cipher,
7272
const char *x509_issuer,
@@ -77,7 +77,7 @@ void acl_update_user(const char *user, const char *host,
7777
const LEX_CSTRING &auth,
7878
MYSQL_TIME password_change_time);
7979
void acl_insert_user(const char *user, const char *host,
80-
const char *password, uint password_len,
80+
const char *password, size_t password_len,
8181
enum SSL_type ssl_type,
8282
const char *ssl_cipher,
8383
const char *x509_issuer,
@@ -98,7 +98,7 @@ bool update_sctx_cache(Security_context *sctx, ACL_USER *acl_user_ptr,
9898
/* sql_user_table */
9999
ulong get_access(TABLE *form,uint fieldnr, uint *next_field);
100100
bool acl_trans_commit_and_close_tables(THD *thd);
101-
void acl_notify_htons(THD* thd, const char* query, uint query_length);
101+
void acl_notify_htons(THD* thd, const char* query, size_t query_length);
102102
bool update_user_table(THD *thd, TABLE *table,
103103
const char *host, const char *user,
104104
const char *new_password, uint new_password_len,

sql/auth/sql_auth_cache.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
11601160
*/
11611161

11621162
bool set_user_salt(ACL_USER *acl_user,
1163-
const char *password, uint password_len)
1163+
const char *password, size_t password_len)
11641164
{
11651165
bool result= false;
11661166
/* Using old password protocol */
@@ -1230,7 +1230,7 @@ validate_user_plugin_records()
12301230
" Nobody can currently login using this account.",
12311231
(int) acl_user->plugin.length, acl_user->plugin.str,
12321232
acl_user->user,
1233-
acl_user->host.get_host_len(),
1233+
static_cast<int>(acl_user->host.get_host_len()),
12341234
acl_user->host.get_host());
12351235
}
12361236
}
@@ -1248,7 +1248,7 @@ validate_user_plugin_records()
12481248
"Nobody can currently login using this account.",
12491249
sha256_password_plugin_name.str,
12501250
acl_user->user,
1251-
acl_user->host.get_host_len(),
1251+
static_cast<int>(acl_user->host.get_host_len()),
12521252
acl_user->host.get_host());
12531253
}
12541254
}
@@ -1349,7 +1349,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
13491349
char tmp_name[NAME_LEN+1];
13501350
int password_length;
13511351
char *password;
1352-
uint password_len;
1352+
size_t password_len;
13531353
sql_mode_t old_sql_mode= thd->variables.sql_mode;
13541354
bool password_expired= false;
13551355
DBUG_ENTER("acl_load");
@@ -2355,7 +2355,7 @@ my_bool grant_reload(THD *thd)
23552355

23562356

23572357
void acl_update_user(const char *user, const char *host,
2358-
const char *password, uint password_len,
2358+
const char *password, size_t password_len,
23592359
enum SSL_type ssl_type,
23602360
const char *ssl_cipher,
23612361
const char *x509_issuer,
@@ -2435,7 +2435,7 @@ void acl_update_user(const char *user, const char *host,
24352435

24362436

24372437
void acl_insert_user(const char *user, const char *host,
2438-
const char *password, uint password_len,
2438+
const char *password, size_t password_len,
24392439
enum SSL_type ssl_type,
24402440
const char *ssl_cipher,
24412441
const char *x509_issuer,

sql/auth/sql_auth_cache.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class String;
3333
class ACL_HOST_AND_IP
3434
{
3535
char *hostname;
36-
uint hostname_length;
36+
size_t hostname_length;
3737
long ip, ip_mask; // Used with masked ip:s
3838

3939
const char *calc_ip(const char *ip_arg, long *val, char end);
4040

4141
public:
4242
const char *get_host() const { return hostname; }
43-
int get_host_len() { return hostname_length; }
43+
size_t get_host_len() { return hostname_length; }
4444

4545
bool has_wildcard()
4646
{

sql/auth/sql_authentication.cc

+8-7
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Rsa_authentication_keys::read_rsa_keys()
343343
344344
*/
345345

346-
int set_default_auth_plugin(char *plugin_name, int plugin_name_length)
346+
int set_default_auth_plugin(char *plugin_name, size_t plugin_name_length)
347347
{
348348
default_auth_plugin_name.str= plugin_name;
349349
default_auth_plugin_name.length= plugin_name_length;
@@ -636,7 +636,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
636636
end+= SCRAMBLE_LENGTH_323;
637637
*end++= 0;
638638

639-
int2store(end, mpvio->client_capabilities);
639+
int2store(end, static_cast<uint16>(mpvio->client_capabilities));
640640
/* write server characteristics: up to 16 bytes allowed */
641641
end[2]= (char) default_charset_info->number;
642642
int2store(end + 3, mpvio->server_status[0]);
@@ -1121,7 +1121,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
11211121
char *end= user + packet_length;
11221122
/* Safe because there is always a trailing \0 at the end of the packet */
11231123
char *passwd= strend(user) + 1;
1124-
uint user_len= passwd - user - 1;
1124+
size_t user_len= passwd - user - 1;
11251125
char *db= passwd;
11261126
char db_buff[NAME_LEN + 1]; // buffer to store db in utf8
11271127
char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8
@@ -2197,7 +2197,7 @@ check_password_lifetime(THD *thd, const ACL_USER *acl_user)
21972197
@retval 1 error
21982198
*/
21992199
int
2200-
acl_authenticate(THD *thd, uint com_change_user_pkt_len)
2200+
acl_authenticate(THD *thd, size_t com_change_user_pkt_len)
22012201
{
22022202
int res= CR_OK;
22032203
MPVIO_EXT mpvio;
@@ -2212,7 +2212,7 @@ acl_authenticate(THD *thd, uint com_change_user_pkt_len)
22122212

22132213
server_mpvio_initialize(thd, &mpvio, &charset_adapter);
22142214

2215-
DBUG_PRINT("info", ("com_change_user_pkt_len=%u", com_change_user_pkt_len));
2215+
DBUG_PRINT("info", ("com_change_user_pkt_len=%zu", com_change_user_pkt_len));
22162216

22172217
/*
22182218
Clear thd->db as it points to something, that will be freed when
@@ -2654,7 +2654,6 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
26542654
MYSQL_SERVER_AUTH_INFO *info)
26552655
{
26562656
uchar *pkt;
2657-
int pkt_len;
26582657
MPVIO_EXT *mpvio= (MPVIO_EXT *) vio;
26592658

26602659
/* generate the scramble, or reuse the old one */
@@ -2666,9 +2665,11 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
26662665
return CR_AUTH_HANDSHAKE;
26672666

26682667
/* read the reply and authenticate */
2669-
if ((pkt_len= mpvio->read_packet(mpvio, &pkt)) < 0)
2668+
int res= mpvio->read_packet(mpvio, &pkt);
2669+
if (res < 0)
26702670
return CR_AUTH_HANDSHAKE;
26712671

2672+
size_t pkt_len= res;
26722673
#ifdef NO_EMBEDDED_ACCESS_CHECKS
26732674
return CR_OK;
26742675
#endif /* NO_EMBEDDED_ACCESS_CHECKS */

0 commit comments

Comments
 (0)