Skip to content

Commit

Permalink
MDEV-13384 - misc Windows warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vaintroub committed Sep 28, 2017
1 parent 5099287 commit 7354dc6
Show file tree
Hide file tree
Showing 147 changed files with 545 additions and 491 deletions.
2 changes: 1 addition & 1 deletion client/mysql_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name,
last_fn_libchar -= 6;
}

len= last_fn_libchar - self_name;
len= (int)(last_fn_libchar - self_name);

my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s",
len, self_name, FN_LIBCHAR, tool_name);
Expand Down
2 changes: 1 addition & 1 deletion client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
Exit_status Load_log_processor::process(Create_file_log_event *ce)
{
const char *bname= ce->fname + dirname_length(ce->fname);
uint blen= ce->fname_len - (bname-ce->fname);
size_t blen= ce->fname_len - (bname-ce->fname);

return process_first_event(bname, blen, ce->block, ce->block_len,
ce->file_id, ce);
Expand Down
10 changes: 5 additions & 5 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ static struct my_option my_long_options[] =
&opt_slave_apply, &opt_slave_apply, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
"Directory for character set files.", &charsets_dir,
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
"Directory for character set files.", (char **)&charsets_dir,
(char **)&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"comments", 'i', "Write additional information.",
&opt_comments, &opt_comments, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -285,8 +285,8 @@ static struct my_option my_long_options[] =
{"debug", '#', "This is a non-debug version. Catch this and exit.",
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else
{"debug", '#', "Output debug log.", &default_dbug_option,
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log.", (char *)&default_dbug_option,
(char *)&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
&debug_check_flag, &debug_check_flag, 0,
Expand Down Expand Up @@ -5733,7 +5733,7 @@ static int replace(DYNAMIC_STRING *ds_str,
return 1;
init_dynamic_string_checked(&ds_tmp, "",
ds_str->length + replace_len, 256);
dynstr_append_mem_checked(&ds_tmp, ds_str->str, start - ds_str->str);
dynstr_append_mem_checked(&ds_tmp, ds_str->str, (uint)(start - ds_str->str));
dynstr_append_mem_checked(&ds_tmp, replace_str, replace_len);
dynstr_append_checked(&ds_tmp, start + search_len);
dynstr_set_checked(ds_str, ds_tmp.str);
Expand Down
6 changes: 3 additions & 3 deletions client/mysqlslap.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ static struct my_option my_long_options[] =
&auto_generate_sql_number, &auto_generate_sql_number,
0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
"Directory for character set files.", &charsets_dir,
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
"Directory for character set files.", (char **)&charsets_dir,
(char **)&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"commit", OPT_SLAP_COMMIT, "Commit records every X number of statements.",
&commit_rate, &commit_rate, 0, GET_UINT, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -817,7 +817,7 @@ get_random_string(char *buf)
DBUG_ENTER("get_random_string");
for (x= RAND_STRING_SIZE; x > 0; x--)
*buf_ptr++= ALPHANUMERICS[random() % ALPHANUMERICS_SIZE];
DBUG_RETURN(buf_ptr - buf);
DBUG_RETURN((uint)(buf_ptr - buf));
}


Expand Down
24 changes: 13 additions & 11 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class LogFile {
if (show_from != buf)
{
// The last new line was found in this buf, adjust offset
show_offset+= (show_from - buf) + 1;
show_offset+= (int)(show_from - buf) + 1;
DBUG_PRINT("info", ("adjusted offset to %d", show_offset));
}
DBUG_PRINT("info", ("show_offset: %d", show_offset));
Expand Down Expand Up @@ -2700,7 +2700,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
DBUG_ASSERT(query_end);
memset(&command, 0, sizeof(command));
command.query= (char*)query;
command.first_word_len= (*query_end - query);
command.first_word_len= (int)(*query_end - query);
command.first_argument= command.query + command.first_word_len;
command.end= (char*)*query_end;
command.abort_on_error= 1; /* avoid uninitialized variables */
Expand Down Expand Up @@ -6501,7 +6501,7 @@ void do_delimiter(struct st_command* command)
if (!(*p))
die("Can't set empty delimiter");

delimiter_length= strmake_buf(delimiter, p) - delimiter;
delimiter_length= (uint)(strmake_buf(delimiter, p) - delimiter);

DBUG_PRINT("exit", ("delimiter: %s", delimiter));
command->last_argument= p + delimiter_length;
Expand Down Expand Up @@ -6987,7 +6987,7 @@ int read_command(struct st_command** command_ptr)
command->first_argument= p;

command->end= strend(command->query);
command->query_len= (command->end - command->query);
command->query_len= (int)(command->end - command->query);
parser.read_lines++;
DBUG_RETURN(0);
}
Expand Down Expand Up @@ -7544,7 +7544,7 @@ void fix_win_paths(char *val, size_t len)
*/

void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
char* val, ulonglong len, my_bool is_null)
char* val, size_t len, my_bool is_null)
{
char null[]= "NULL";

Expand Down Expand Up @@ -8540,7 +8540,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
if (flags & QUERY_PRINT_ORIGINAL_FLAG)
{
print_query= command->query;
print_len= command->end - command->query;
print_len= (int)(command->end - command->query);
}
replace_dynstr_append_mem(ds, print_query, print_len);
dynstr_append_mem(ds, delimiter, delimiter_length);
Expand Down Expand Up @@ -10237,7 +10237,7 @@ void free_replace_regex()
*/
#define SECURE_REG_BUF if (buf_len < need_buf_len) \
{ \
int off= res_p - buf; \
ssize_t off= res_p - buf; \
buf= (char*)my_realloc(buf,need_buf_len,MYF(MY_WME+MY_FAE)); \
res_p= buf + off; \
buf_len= need_buf_len; \
Expand All @@ -10262,13 +10262,15 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
regmatch_t *subs;
char *replace_end;
char *buf= *buf_p;
int len;
int buf_len, need_buf_len;
size_t len;
size_t buf_len, need_buf_len;
int cflags= REG_EXTENDED | REG_DOTALL;
int err_code;
char *res_p,*str_p,*str_end;

buf_len= *buf_len_p;
DBUG_ASSERT(*buf_len_p > 0);

buf_len= (size_t)*buf_len_p;
len= strlen(string);
str_end= string + len;

Expand Down Expand Up @@ -10411,7 +10413,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
}
else /* no match this time, just copy the string as is */
{
int left_in_str= str_end-str_p;
size_t left_in_str= str_end-str_p;
need_buf_len= (res_p-buf) + left_in_str;
SECURE_REG_BUF
memcpy(res_p,str_p,left_in_str);
Expand Down
4 changes: 2 additions & 2 deletions cmake/os/Windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ IF(MSVC)
ENDIF()

#TODO: update the code and remove the disabled warnings
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /we4700 /we4311 /we4477 /we4302")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700 /we4311 /we4477 /we4302")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /we4700 /we4311 /we4477 /we4302 /we4090 /wd4267 ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090 /wd4267")

ENDIF()

Expand Down
4 changes: 2 additions & 2 deletions cmake/os/WindowsCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SET(HAVE_LDIV 1 CACHE INTERNAL "")
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "")
SET(HAVE_LOG2 CACHE INTERNAL "")
#SET(HAVE_LOG2 CACHE INTERNAL "")
SET(HAVE_LRAND48 CACHE INTERNAL "")
SET(HAVE_LSTAT CACHE INTERNAL "")
SET(HAVE_MADVISE CACHE INTERNAL "")
Expand Down Expand Up @@ -141,7 +141,7 @@ SET(HAVE_READLINK CACHE INTERNAL "")
SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
SET(HAVE_REALPATH CACHE INTERNAL "")
SET(HAVE_RENAME 1 CACHE INTERNAL "")
SET(HAVE_RINT CACHE INTERNAL "")
#SET(HAVE_RINT CACHE INTERNAL "")
SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
SET(HAVE_SCHED_H CACHE INTERNAL "")
SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
Expand Down
2 changes: 1 addition & 1 deletion extra/innochecksum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ is_page_corrupted(
normal method. */
if (is_encrypted && key_version != 0) {
is_corrupted = !fil_space_verify_crypt_checksum(buf,
page_size, space_id, cur_page_num);
page_size, space_id, (ulint)cur_page_num);
} else {
is_corrupted = true;
}
Expand Down
4 changes: 2 additions & 2 deletions extra/yassl/taocrypt/src/algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ struct WindowSlider

exp >>= skipCount;
windowBegin += skipCount;
expWindow = exp % (1 << windowSize);
expWindow = (unsigned int)(exp % (1LL << windowSize));

if (fastNegate && exp.GetBit(windowSize))
{
Expand Down Expand Up @@ -248,7 +248,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
{
exponents.push_back(WindowSlider(*expBegin++, InversionIsFast(), 0));
exponents[i].FindNextWindow();
buckets[i].resize(1<<(exponents[i].windowSize-1), Identity());
buckets[i].resize(size_t(1)<<(exponents[i].windowSize-1), Identity());
}

unsigned int expBitPosition = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/mysql_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
extern int my_connect_async(struct mysql_async_context *b, my_socket fd,
const struct sockaddr *name, uint namelen,
int vio_timeout);
extern ssize_t my_recv_async(struct mysql_async_context *b, int fd,
extern ssize_t my_recv_async(struct mysql_async_context *b, my_socket fd,
unsigned char *buf, size_t size, int timeout);
extern ssize_t my_send_async(struct mysql_async_context *b, int fd,
extern ssize_t my_send_async(struct mysql_async_context *b, my_socket fd,
const unsigned char *buf, size_t size,
int timeout);
extern my_bool my_io_wait_async(struct mysql_async_context *b,
Expand Down
2 changes: 1 addition & 1 deletion libmysqld/libmysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
ulong copy_length;
if (start < end)
{
copy_length= end - start;
copy_length= (ulong)(end - start);
/* We've got some data beyond offset: copy up to buffer_length bytes */
if (param->buffer_length)
memcpy(buffer, start, MY_MIN(copy_length, param->buffer_length));
Expand Down
2 changes: 1 addition & 1 deletion mysys/lf_alloc-pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void lf_pinbox_real_free(LF_PINS *pins)
lf_dynarray_iterate(&pinbox->pinarray,
(lf_dynarray_func)harvest_pins, &hv);

npins= hv.granary-addr;
npins= (int)(hv.granary-addr);
/* and sort them */
if (npins)
qsort(addr, npins, sizeof(void *), (qsort_cmp)ptr_cmp);
Expand Down
2 changes: 1 addition & 1 deletion mysys/mf_keycache.c
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,7 @@ int init_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
}
}

keycache->partitions= partitions= partition_ptr-keycache->partition_array;
keycache->partitions= partitions= (uint) (partition_ptr-keycache->partition_array);
keycache->key_cache_mem_size= mem_per_cache * partitions;
for (i= 0; i < (int) partitions; i++)
keycache->partition_array[i]->hash_factor= partitions;
Expand Down
4 changes: 2 additions & 2 deletions mysys/my_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ static uint print_name(const struct my_option *optp)

for (;*s;s++)
putchar(*s == '_' ? '-' : *s);
return s - optp->name;
return (uint)(s - optp->name);
}

/** prints option comment with indentation and wrapping.
Expand Down Expand Up @@ -1441,7 +1441,7 @@ static uint print_comment(const char *comment,
putchar(' ');
}
printf("%s", comment);
return curpos + (end - comment);
return curpos + (int)(end - comment);
}


Expand Down
2 changes: 1 addition & 1 deletion mysys/typelib.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ my_ulonglong find_set_from_flags(const TYPELIB *lib, uint default_name,
continue;
err:
*err_pos= (char*)start;
*err_len= end - start;
*err_len= (uint)(end - start);
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions mysys_ssl/my_md5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void my_md5(uchar *digest, const char *buf, size_t len)
char ctx_buf[EVP_MD_CTX_SIZE];
EVP_MD_CTX * const ctx= (EVP_MD_CTX*)ctx_buf;
md5_init(ctx);
md5_input(ctx, (const uchar *)buf, len);
md5_input(ctx, (const uchar *)buf, (uint) len);
md5_result(ctx, digest);
}

Expand All @@ -117,7 +117,7 @@ void my_md5_multi(uchar *digest, ...)

md5_init(ctx);
for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*))
md5_input(ctx, str, va_arg(args, size_t));
md5_input(ctx, str, (uint) va_arg(args, size_t));

md5_result(ctx, digest);
va_end(args);
Expand All @@ -135,7 +135,7 @@ void my_md5_init(void *context)

void my_md5_input(void *context, const uchar *buf, size_t len)
{
md5_input((EVP_MD_CTX *)context, buf, len);
md5_input((EVP_MD_CTX *)context, buf, (uint) len);
}

void my_md5_result(void *context, uchar *digest)
Expand Down
4 changes: 2 additions & 2 deletions mysys_ssl/my_sha.ic
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void my_sha_multi(uchar *digest, ...)

sha_init_fast(&context);
for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*))
sha_input(&context, str, va_arg(args, size_t));
sha_input(&context, str, (uint) va_arg(args, size_t));

sha_result(&context, digest);
va_end(args);
Expand All @@ -179,7 +179,7 @@ void my_sha_init(void *context)

void my_sha_input(void *context, const uchar *buf, size_t len)
{
sha_input((CONTEXT *)context, buf, len);
sha_input((CONTEXT *)context, buf, (uint) len);
}

void my_sha_result(void *context, uchar *digest)
Expand Down
5 changes: 2 additions & 3 deletions plugin/auth_ed25519/server_ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ static int loaded= 0;

static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
{
unsigned int i;
int pkt_len;
unsigned long nonce[CRYPTO_LONGS + NONCE_LONGS];
unsigned char *pkt, *reply= (unsigned char*)nonce;
Expand All @@ -51,8 +50,8 @@ static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
info->password_used= PASSWORD_USED_YES;

/* prepare random nonce */
for (i=CRYPTO_LONGS; i < CRYPTO_LONGS + NONCE_LONGS; i++)
nonce[i]= thd_rnd(info->thd) * ~0UL;
if (my_random_bytes((unsigned char *)nonce, (int)sizeof(nonce)))
return CR_AUTH_USER_CREDENTIALS;

/* send it */
if (vio->write_packet(vio, reply + CRYPTO_BYTES, NONCE_BYTES))
Expand Down
4 changes: 2 additions & 2 deletions plugin/auth_pipe/auth_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
unsigned char *pkt;
MYSQL_PLUGIN_VIO_INFO vio_info;
char username[UNLEN + 1];
size_t username_length;
DWORD username_length;
int ret;

/* no user name yet ? read the client handshake packet with the user name */
Expand All @@ -54,7 +54,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
if (!ImpersonateNamedPipeClient(vio_info.handle))
return CR_ERROR;

username_length= sizeof(username) - 1;
username_length=UNLEN;
ret= CR_ERROR;
if (GetUserName(username, &username_length))
{
Expand Down
2 changes: 1 addition & 1 deletion plugin/feedback/feedback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
Item_field *fld= new (thd->mem_root) Item_field(thd, &nrc, db, table,
field);
Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str,
filter->length, cs);
(uint) filter->length, cs);
Item_string *escape= new (thd->mem_root) Item_string(thd, "\\", 1, cs);

if (!fld || !pattern || !escape)
Expand Down
2 changes: 1 addition & 1 deletion plugin/feedback/sender_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static void send_report(const char *when)
Url *url= todo[i];

if (thd) // for nicer SHOW PROCESSLIST
thd->set_query(const_cast<char*>(url->url()), url->url_length());
thd->set_query(const_cast<char*>(url->url()), (uint) url->url_length());

if (url->send(str.ptr(), str.length()))
i++;
Expand Down

0 comments on commit 7354dc6

Please sign in to comment.