Skip to content

Commit e5cc397

Browse files
author
monty@mysql.com/narttu.mysql.fi
committed
Fixed compiler warnings (for linux and win32 and win64)
Fixed a couple of usage of not initialized warnings (unlikely cases)
1 parent 6946fa6 commit e5cc397

Some content is hidden

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

43 files changed

+122
-61
lines changed

client/mysqldump.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,8 @@ static uint get_table_structure(char *table, char *db, char *table_type,
20162016
20172017
*/
20182018

2019-
static void dump_triggers_for_table(char *table, char *db)
2019+
static void dump_triggers_for_table(char *table,
2020+
char *db __attribute__((unused)))
20202021
{
20212022
char *result_table;
20222023
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
@@ -2025,7 +2026,6 @@ static void dump_triggers_for_table(char *table, char *db)
20252026
FILE *sql_file= md_result_file;
20262027
MYSQL_RES *result;
20272028
MYSQL_ROW row;
2028-
20292029
DBUG_ENTER("dump_triggers_for_table");
20302030
DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
20312031

client/mysqltest.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ void do_copy_file(struct st_command *command)
18441844

18451845
void do_chmod_file(struct st_command *command)
18461846
{
1847-
ulong mode= 0;
1847+
long mode= 0;
18481848
static DYNAMIC_STRING ds_mode;
18491849
static DYNAMIC_STRING ds_file;
18501850
const struct command_arg chmod_file_args[] = {
@@ -1864,7 +1864,7 @@ void do_chmod_file(struct st_command *command)
18641864
die("You must write a 4 digit octal number for mode");
18651865

18661866
DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str));
1867-
handle_command_error(command, chmod(ds_file.str, mode));
1867+
handle_command_error(command, chmod(ds_file.str, (mode_t) mode));
18681868
dynstr_free(&ds_mode);
18691869
dynstr_free(&ds_file);
18701870
DBUG_VOID_RETURN;
@@ -6275,7 +6275,8 @@ typedef struct st_replace_found {
62756275

62766276

62776277
void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
6278-
const char *str, int len)
6278+
const char *str,
6279+
int len __attribute__((unused)))
62796280
{
62806281
reg1 REPLACE *rep_pos;
62816282
reg2 REPLACE_STRING *rep_str;
@@ -6666,7 +6667,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
66666667
we need at least what we have so far in the buffer + the part
66676668
before this match
66686669
*/
6669-
need_buf_len= (res_p - buf) + subs[0].rm_so;
6670+
need_buf_len= (res_p - buf) + (int) subs[0].rm_so;
66706671

66716672
/* on this pass, calculate the memory for the result buffer */
66726673
while (expr_p < replace_end)
@@ -6676,17 +6677,17 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
66766677

66776678
if (c == '\\' && expr_p + 1 < replace_end)
66786679
{
6679-
back_ref_num= expr_p[1] - '0';
6680+
back_ref_num= (int) (expr_p[1] - '0');
66806681
}
66816682

66826683
/* found a valid back_ref (eg. \1)*/
66836684
if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
66846685
{
6685-
int start_off,end_off;
6686+
regoff_t start_off, end_off;
66866687
if ((start_off=subs[back_ref_num].rm_so) > -1 &&
66876688
(end_off=subs[back_ref_num].rm_eo) > -1)
66886689
{
6689-
need_buf_len += (end_off - start_off);
6690+
need_buf_len += (int) (end_off - start_off);
66906691
}
66916692
expr_p += 2;
66926693
}
@@ -6706,7 +6707,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
67066707
/* copy the pre-match part */
67076708
if (subs[0].rm_so)
67086709
{
6709-
memcpy(res_p, str_p, subs[0].rm_so);
6710+
memcpy(res_p, str_p, (size_t) subs[0].rm_so);
67106711
res_p+= subs[0].rm_so;
67116712
}
67126713

cmd-line-utils/readline/xmalloc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ xmalloc (bytes)
5757

5858
temp = malloc (bytes);
5959
if (temp == 0)
60-
memory_error_and_abort ("xmalloc");
60+
memory_error_and_abort ((char*) "xmalloc");
6161
return (temp);
6262
}
6363

@@ -71,7 +71,7 @@ xrealloc (pointer, bytes)
7171
temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
7272

7373
if (temp == 0)
74-
memory_error_and_abort ("xrealloc");
74+
memory_error_and_abort ((char*) "xrealloc");
7575
return (temp);
7676
}
7777

extra/comp_err.c

+4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ static char *NAMEFILE= (char*) "mysqld_ername.h";
4141
static char *STATEFILE= (char*) "sql_state.h";
4242
static char *TXTFILE= (char*) "../sql/share/errmsg.txt";
4343
static char *DATADIRECTORY= (char*) "../sql/share/";
44+
#ifndef DBUG_OFF
4445
static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace";
46+
#endif
4547

4648
/* Header for errmsg.sys files */
4749
uchar file_head[]= { 254, 254, 2, 1 };
@@ -402,6 +404,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
402404
int rcount= 0;
403405
DBUG_ENTER("parse_input_file");
404406

407+
*top_error= 0;
408+
*top_lang= 0;
405409
if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME))))
406410
DBUG_RETURN(0);
407411

extra/yassl/include/openssl/ssl.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "opensslv.h" /* for version number */
3434
#include "rsa.h"
3535

36-
3736
#define YASSL_VERSION "1.5.8"
3837

3938

@@ -190,11 +189,16 @@ enum { /* ERR Constants */
190189
EVP_R_BAD_DECRYPT = 2
191190
};
192191

192+
#ifdef WIN
193+
typedef SOCKET socket_t;
194+
#else
195+
typedef int socket_t;
196+
#endif
193197

194198

195199
SSL_CTX* SSL_CTX_new(SSL_METHOD*);
196200
SSL* SSL_new(SSL_CTX*);
197-
int SSL_set_fd (SSL*, int);
201+
int SSL_set_fd (SSL*, socket_t);
198202
int SSL_connect(SSL*);
199203
int SSL_write(SSL*, const void*, int);
200204
int SSL_read(SSL*, void*, int);

extra/yassl/include/socket_wrapper.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@
3838
#include <netinet/in.h>
3939
#include <arpa/inet.h>
4040
#endif
41+
#include "openssl/ssl.h" /* for socket_t */
4142

4243

4344
namespace yaSSL {
4445

4546
typedef unsigned int uint;
4647

47-
#ifdef _WIN32
48-
typedef SOCKET socket_t;
49-
#else
50-
typedef int socket_t;
48+
#ifndef _WIN32
5149
const socket_t INVALID_SOCKET = -1;
5250
const int SD_RECEIVE = 0;
5351
const int SD_SEND = 1;

extra/yassl/src/ssl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void SSL_free(SSL* ssl)
229229
}
230230

231231

232-
int SSL_set_fd(SSL* ssl, int fd)
232+
int SSL_set_fd(SSL* ssl, socket_t fd)
233233
{
234234
ssl->useSocket().set_fd(fd);
235235
return SSL_SUCCESS;

extra/yassl/taocrypt/src/integer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,7 @@ void Integer::DivideByPowerOf2(Integer &r, Integer &q, const Integer &a,
33903390
CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount);
33913391
SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount);
33923392
if (n % WORD_BITS != 0)
3393-
r.reg_[wordCount-1] %= (1 << (n % WORD_BITS));
3393+
r.reg_[wordCount-1] %= ((word) 1 << (n % WORD_BITS));
33943394
}
33953395
else
33963396
{

include/my_global.h

+15
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,21 @@ typedef long long my_ptrdiff_t;
846846
#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
847847
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
848848

849+
/*
850+
Custom version of standard offsetof() macro which can be used to get
851+
offsets of members in class for non-POD types (according to the current
852+
version of C++ standard offsetof() macro can't be used in such cases and
853+
attempt to do so causes warnings to be emitted, OTOH in many cases it is
854+
still OK to assume that all instances of the class has the same offsets
855+
for the same members).
856+
857+
This is temporary solution which should be removed once File_parser class
858+
and related routines are refactored.
859+
*/
860+
861+
#define my_offsetof(TYPE, MEMBER) \
862+
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
863+
849864
#define NullS (char *) 0
850865
/* Nowdays we do not support MessyDos */
851866
#ifndef NEAR

innobase/include/ut0byte.ic

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ ut_bit_set_nth(
388388
ut_ad(TRUE == 1);
389389

390390
if (val) {
391-
return((1 << n) | a);
391+
return(((ulint) 1 << n) | a);
392392
} else {
393-
return(~(1 << n) & a);
393+
return(~((ulint) 1 << n) & a);
394394
}
395395
}

innobase/include/ut0ut.ic

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ ut_2_exp(
170170
/* out: 2 to power n */
171171
ulint n) /* in: number */
172172
{
173-
return(1 << n);
173+
return((ulint) 1 << n);
174174
}

libmysql/libmysql.def

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
LIBRARY LIBMYSQL
2-
DESCRIPTION 'MySQL 5.0 Client Library'
32
VERSION 6.0
43
EXPORTS
54
_dig_vec_lower

myisam/mi_packrec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static void fill_quick_table(uint16 *table, uint bits, uint max_bits,
564564
*/
565565
value|= (max_bits - bits) << 8 | IS_CHAR;
566566

567-
for (end= table + (1 << bits); table < end; table++)
567+
for (end= table + ((uint) 1 << bits); table < end; table++)
568568
{
569569
*table= (uint16) value;
570570
}

myisam/myisamchk.c

+1
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ get_one_option(int optid,
720720
case 2:
721721
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
722722
break;
723+
default: assert(0); /* Impossible */
723724
}
724725
check_param.stats_method= method_conv;
725726
break;

mysys/base64.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ base64_encode(const void *src, size_t src_len, char *dst)
9898
}
9999

100100

101-
static inline unsigned
101+
static inline uint
102102
pos(unsigned char c)
103103
{
104-
return strchr(base64_table, c) - base64_table;
104+
return (uint) (strchr(base64_table, c) - base64_table);
105105
}
106106

107107

mysys/mf_keycache.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue,
167167
struct st_my_thread_var *thread);
168168
#endif
169169
static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block);
170+
#ifndef DBUG_OFF
170171
static void test_key_cache(KEY_CACHE *keycache,
171172
const char *where, my_bool lock);
173+
#endif
172174

173175
#define KEYCACHE_HASH(f, pos) \
174176
(((ulong) ((pos) >> keycache->key_cache_shift)+ \
@@ -2605,7 +2607,8 @@ static int flush_all_key_blocks(KEY_CACHE *keycache)
26052607
0 on success (always because it can't fail)
26062608
*/
26072609

2608-
int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache)
2610+
int reset_key_cache_counters(const char *name __attribute__((unused)),
2611+
KEY_CACHE *key_cache)
26092612
{
26102613
DBUG_ENTER("reset_key_cache_counters");
26112614
if (!key_cache->key_cache_inited)

mysys/my_getopt.c

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ int handle_options(int *argc, char ***argv,
194194
Find first the right option. Return error in case of an ambiguous,
195195
or unknown option
196196
*/
197+
LINT_INIT(prev_found);
197198
optp= longopts;
198199
if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
199200
{

mysys/my_init.c

+2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
197197
}
198198

199199
if (!(infoflag & MY_DONT_FREE_DBUG))
200+
{
200201
DBUG_END(); /* Must be done before my_thread_end */
202+
}
201203
#ifdef THREAD
202204
my_thread_end();
203205
my_thread_global_end();

mysys/my_thr_init.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ pthread_mutexattr_t my_errorcheck_mutexattr;
5454
race conditions in NPTL pthread_exit code.
5555
*/
5656

57-
static
58-
pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
57+
static pthread_handler_t
58+
nptl_pthread_exit_hack_handler(void *arg __attribute__((unused)))
5959
{
6060
/* Do nothing! */
6161
pthread_exit(0);
@@ -400,9 +400,9 @@ const char *my_thread_name(void)
400400

401401
static uint get_thread_lib(void)
402402
{
403+
#ifdef _CS_GNU_LIBPTHREAD_VERSION
403404
char buff[64];
404405

405-
#ifdef _CS_GNU_LIBPTHREAD_VERSION
406406
confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff));
407407

408408
if (!strncasecmp(buff, "NPTL", 4))

mysys/ptr_cmp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ my_off_t my_get_ptr(byte *ptr, uint pack_length)
185185
case 3: pos= (my_off_t) mi_uint3korr(ptr); break;
186186
case 2: pos= (my_off_t) mi_uint2korr(ptr); break;
187187
case 1: pos= (my_off_t) mi_uint2korr(ptr); break;
188-
default: DBUG_ASSERT(0);
188+
default: DBUG_ASSERT(0); return 0;
189189
}
190190
return pos;
191191
}

ndb/include/kernel/signaldata/DictTabInfo.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ inline int my_decimal_get_binary_size(uint precision, uint scale)
4646
#endif
4747

4848
#define DTIMAP(x, y, z) \
49-
{ DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 }
49+
{ DictTabInfo::y, my_offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 }
5050

5151
#define DTIMAP2(x, y, z, u, v) \
52-
{ DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, u, v, 0 }
52+
{ DictTabInfo::y, my_offsetof(x, z), SimpleProperties::Uint32Value, u, v, 0 }
5353

5454
#define DTIMAPS(x, y, z, u, v) \
55-
{ DictTabInfo::y, offsetof(x, z), SimpleProperties::StringValue, u, v, 0 }
55+
{ DictTabInfo::y, my_offsetof(x, z), SimpleProperties::StringValue, u, v, 0 }
5656

5757
#define DTIMAPB(x, y, z, u, v, l) \
58-
{ DictTabInfo::y, offsetof(x, z), SimpleProperties::BinaryValue, u, v, \
59-
offsetof(x, l) }
58+
{ DictTabInfo::y, my_offsetof(x, z), SimpleProperties::BinaryValue, u, v, \
59+
my_offsetof(x, l) }
6060

6161
#define DTIBREAK(x) \
6262
{ DictTabInfo::x, 0, SimpleProperties::InvalidValue, 0, 0, 0 }

server-tools/instance-manager/mysql_connection.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int Mysql_connection_thread::init()
135135
/* Initialize random number generator */
136136
{
137137
ulong seed1= (ulong) &rand_st + rand();
138-
ulong seed2= rand() + time(0);
138+
ulong seed2= rand() + (ulong) time(0);
139139
randominit(&rand_st, seed1, seed2);
140140
}
141141
/* Fill scramble - server's random message used for handshake */

server-tools/instance-manager/mysqlmanager.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void init_environment(char *progname)
199199
MY_INIT(progname);
200200
log_init();
201201
umask(0117);
202-
srand(time(0));
202+
srand((uint) time(0));
203203
}
204204

205205

sql/filesort.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
9898
uint maxbuffer;
9999
BUFFPEK *buffpek;
100100
ha_rows records= HA_POS_ERROR;
101-
uchar **sort_keys;
101+
uchar **sort_keys= 0;
102102
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
103103
SORTPARAM param;
104104
bool multi_byte_charset;

0 commit comments

Comments
 (0)