Skip to content

Commit db40af2

Browse files
author
monty@mysql.com
committed
Fix warnings from icc
Added BUILD scripts for icc Fixed (one time) memory leak in grant handling
1 parent ca5b291 commit db40af2

13 files changed

+212
-118
lines changed

BUILD/compile-pentium-icc

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#! /bin/sh
2+
3+
path=`dirname $0`
4+
. "$path/SETUP.sh"
5+
6+
# Note that we can't use ccache with icc as the generated .deps file will
7+
# then contain wrong information
8+
CC=icc
9+
CXX=icpc
10+
CXXLD="$CXX -static-libcxa"
11+
export CC CXX
12+
13+
14+
extra_flags="$pentium_cflags $debug_cflags $max_cflags -USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify -DMYSQL_SERVER_SUFFIX=-valgrind-max"
15+
16+
# Disable following warnings as these are generated by header files:
17+
# 161 unrecognized pragma
18+
# 444 destructor for base class xxx is not virtual
19+
# 279 controlling expression is constant
20+
# 810 conversion from ulonglong to ulong with cast
21+
# 981 operands are evaluated in unspecified order
22+
# 1292 warning for unknown 'attribute' options
23+
# 1469 "xxx" clobber ignored
24+
# 1572 floating-point equality and inequality comparisons are unreliable
25+
26+
# In C++
27+
# 869 parameter "xxx" was never referenced
28+
# (Problem with virtual functions)
29+
# 874 support for placement delete is disabled
30+
31+
c_warnings=""
32+
cxx_warnings=""
33+
extra_flags="-O3 -unroll2 -ip -mp -no-gcc -restrict"
34+
base_cxxflags="-fno-exceptions -fno-rtti"
35+
extra_configs="$pentium_configs $static_link"
36+
37+
. "$path/FINISH.sh"
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/sh
2+
3+
path=`dirname $0`
4+
. "$path/SETUP.sh"
5+
6+
# Note that we can't use ccache with icc as the generated .deps file will
7+
# then contain wrong information
8+
CC=icc
9+
CXX=icpc
10+
export CC CXX
11+
12+
extra_flags="$pentium_cflags $debug_cflags $max_cflags -USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify -DMYSQL_SERVER_SUFFIX=-valgrind-max"
13+
14+
# Disable following warnings as these are generated by header files:
15+
# 161 unrecognized pragma
16+
# 444 destructor for base class xxx is not virtual
17+
# 279 controlling expression is constant
18+
# 810 conversion from ulonglong to ulong with cast
19+
# 981 operands are evaluated in unspecified order
20+
# 1292 warning for unknown 'attribute' options
21+
# 1469 "xxx" clobber ignored
22+
# 1572 floating-point equality and inequality comparisons are unreliable
23+
24+
# In C++
25+
# 869 parameter "xxx" was never referenced
26+
# (Problem with virtual functions)
27+
# 874 support for placement delete is disabled
28+
29+
c_warnings="-Wall -Wcheck -wd161,444,279,810,981,1292,1469,1572"
30+
cxx_warnings="$c_warnings -wd869,874"
31+
base_cxxflags="-fno-exceptions -fno-rtti"
32+
extra_configs="$pentium_configs $debug_configs"
33+
34+
. "$path/FINISH.sh"

config/ac-macros/misc.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AC_LANG_PUSH(C++)
3838
if test "$ac_cv_prog_gxx" = "yes"
3939
then
4040
# Add -Werror, remove -fbranch-probabilities (Bug #268)
41-
CXXFLAGS=`echo $CXXFLAGS -Werror | sed 's/-fbranch-probabilities//'`
41+
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
4242
fi
4343
mysql_cv_btype_last_arg_accept=none
4444
[AC_TRY_COMPILE([#if defined(inline)
@@ -98,7 +98,7 @@ AC_LANG_PUSH(C++)
9898
if test "$ac_cv_prog_gxx" = "yes"
9999
then
100100
# Add -Werror, remove -fbranch-probabilities (Bug #268)
101-
CXXFLAGS=`echo $CXXFLAGS -Werror | sed 's/-fbranch-probabilities//'`
101+
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
102102
fi
103103
mysql_cv_btype_struct_rlimit=none
104104
[AC_TRY_COMPILE([#if defined(inline)

configure.in

+6-3
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,12 @@ AC_LANG_CPLUSPLUS
19651965
# with respect to ANSI C++
19661966
# We also remove the -fbranch-probabilities option as this will give warnings
19671967
# about not profiled code, which confuses configure
1968+
# We also must remove -W and -Wcheck which on icc produces warnings that
1969+
# we don't want to catch with -Werror
1970+
19681971
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
19691972
then
1970-
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
1973+
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
19711974
fi
19721975

19731976
AC_TRY_COMPILE(
@@ -2002,7 +2005,7 @@ AC_LANG_SAVE
20022005
AC_LANG_CPLUSPLUS
20032006
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
20042007
then
2005-
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
2008+
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
20062009
fi
20072010
AC_TRY_COMPILE(
20082011
[#undef inline
@@ -2035,7 +2038,7 @@ AC_LANG_SAVE
20352038
AC_LANG_CPLUSPLUS
20362039
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
20372040
then
2038-
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
2041+
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
20392042
fi
20402043
AC_TRY_COMPILE(
20412044
[#undef inline

extra/replace.c

+39-38
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef struct st_pointer_array { /* when using array-strings */
6363
#define LAST_CHAR_CODE 259
6464

6565
typedef struct st_replace {
66-
bool found;
66+
my_bool found;
6767
struct st_replace *next[256];
6868
} REPLACE;
6969

@@ -80,19 +80,18 @@ typedef struct st_replace_found {
8080

8181
/* functions defined in this file */
8282

83-
extern int main(int argc,char * *argv);
8483
static int static_get_options(int *argc,char * * *argv);
8584
static int get_replace_strings(int *argc,char * * *argv,
8685
POINTER_ARRAY *from_array,
8786
POINTER_ARRAY *to_array);
88-
int insert_pointer_name(POINTER_ARRAY *pa, my_string name);
89-
void free_pointer_array(POINTER_ARRAY *pa);
87+
static int insert_pointer_name(POINTER_ARRAY *pa, my_string name);
88+
static void free_pointer_array(POINTER_ARRAY *pa);
9089
static int convert_pipe(REPLACE *,FILE *,FILE *);
9190
static int convert_file(REPLACE *, my_string);
92-
REPLACE *init_replace(my_string *from, my_string *to,uint count, my_string
93-
word_end_chars);
94-
uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
95-
my_string from);
91+
static REPLACE *init_replace(my_string *from, my_string *to,uint count,
92+
my_string word_end_chars);
93+
static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
94+
my_string from);
9695
static int initialize_buffer(void);
9796
static void reset_buffer(void);
9897
static void free_buffer(void);
@@ -101,9 +100,7 @@ static int silent=0,verbose=0,updated=0;
101100

102101
/* The main program */
103102

104-
int main(argc,argv)
105-
int argc;
106-
char *argv[];
103+
int main(int argc, char *argv[])
107104
{
108105
int i,error;
109106
char word_end_chars[256],*pos;
@@ -118,7 +115,7 @@ char *argv[];
118115

119116
for (i=1,pos=word_end_chars ; i < 256 ; i++)
120117
if (my_isspace(&my_charset_latin1,i))
121-
*pos++=i;
118+
*pos++= (char) i;
122119
*pos=0;
123120
if (!(replace=init_replace((char**) from.typelib.type_names,
124121
(char**) to.typelib.type_names,
@@ -153,7 +150,7 @@ static int static_get_options(argc,argv)
153150
register int *argc;
154151
register char **argv[];
155152
{
156-
int help,version,opt;
153+
int help,version;
157154
char *pos;
158155

159156
silent=verbose=help=0;
@@ -162,7 +159,7 @@ register char **argv[];
162159
while (*++pos)
163160
{
164161
version=0;
165-
switch((opt= *pos)) {
162+
switch((*pos)) {
166163
case 's':
167164
silent=1;
168165
break;
@@ -249,7 +246,7 @@ POINTER_ARRAY *from_array,*to_array;
249246
return 0;
250247
}
251248

252-
int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
249+
static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
253250
{
254251
uint i,length,old_count;
255252
byte *new_pos;
@@ -323,8 +320,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
323320

324321
/* free pointer array */
325322

326-
void free_pointer_array(pa)
327-
reg1 POINTER_ARRAY *pa;
323+
static void free_pointer_array(reg1 POINTER_ARRAY *pa)
328324
{
329325
if (pa->typelib.count)
330326
{
@@ -382,9 +378,9 @@ static void or_bits(REP_SET *to,REP_SET *from);
382378
static void copy_bits(REP_SET *to,REP_SET *from);
383379
static int cmp_bits(REP_SET *set1,REP_SET *set2);
384380
static int get_next_bit(REP_SET *set,uint lastpos);
385-
static int find_set(REP_SETS *sets,REP_SET *find);
386-
static int find_found(FOUND_SET *found_set,uint table_offset,
387-
int found_offset);
381+
static short find_set(REP_SETS *sets,REP_SET *find);
382+
static short find_found(FOUND_SET *found_set,uint table_offset,
383+
int found_offset);
388384
static uint start_at_word(my_string pos);
389385
static uint end_of_word(my_string pos);
390386
static uint replace_len(my_string pos);
@@ -394,11 +390,12 @@ static uint found_sets=0;
394390

395391
/* Init a replace structure for further calls */
396392

397-
REPLACE *init_replace(my_string *from, my_string *to,uint count,
398-
my_string word_end_chars)
393+
static REPLACE *init_replace(my_string *from, my_string *to,uint count,
394+
my_string word_end_chars)
399395
{
400396
uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr;
401-
int used_sets,chr,default_state;
397+
int used_sets,chr;
398+
short default_state;
402399
char used_chars[LAST_CHAR_CODE],is_word_end[256];
403400
my_string pos,to_pos,*to_array;
404401
REP_SETS sets;
@@ -561,7 +558,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
561558
for (chr= 0 ; chr < 256 ; chr++)
562559
{
563560
if (! used_chars[chr])
564-
set->next[chr]= chr ? default_state : -1;
561+
set->next[chr]= (short) (chr ? default_state : -1);
565562
else
566563
{
567564
new_set=make_new_set(&sets);
@@ -652,7 +649,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
652649
for (i=1 ; i <= found_sets ; i++)
653650
{
654651
pos=from[found_set[i-1].table_offset];
655-
rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1;
652+
rep_str[i].found= (my_bool) (!bcmp(pos,"\\^",3) ? 2 : 1);
656653
rep_str[i].replace_string=to_array[found_set[i-1].table_offset];
657654
rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos);
658655
rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+
@@ -812,38 +809,41 @@ static int get_next_bit(REP_SET *set,uint lastpos)
812809
free given set, else put in given set in sets and return it's
813810
position */
814811

815-
static int find_set(REP_SETS *sets,REP_SET *find)
812+
static short find_set(REP_SETS *sets,REP_SET *find)
816813
{
817814
uint i;
818815
for (i=0 ; i < sets->count-1 ; i++)
819816
{
820817
if (!cmp_bits(sets->set+i,find))
821818
{
822819
free_last_set(sets);
823-
return i;
820+
return (short) i;
824821
}
825822
}
826-
return i; /* return new postion */
823+
return (short) i; /* return new postion */
827824
}
828825

829-
/* find if there is a found_set with same table_offset & found_offset
830-
If there is return offset to it, else add new offset and return pos.
831-
Pos returned is -offset-2 in found_set_structure because it's is
832-
saved in set->next and set->next[] >= 0 points to next set and
833-
set->next[] == -1 is reserved for end without replaces.
834-
*/
835826

836-
static int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
827+
/*
828+
find if there is a found_set with same table_offset & found_offset
829+
If there is return offset to it, else add new offset and return pos.
830+
Pos returned is -offset-2 in found_set_structure because it's is
831+
saved in set->next and set->next[] >= 0 points to next set and
832+
set->next[] == -1 is reserved for end without replaces.
833+
*/
834+
835+
static short find_found(FOUND_SET *found_set,uint table_offset,
836+
int found_offset)
837837
{
838838
int i;
839839
for (i=0 ; (uint) i < found_sets ; i++)
840840
if (found_set[i].table_offset == table_offset &&
841841
found_set[i].found_offset == found_offset)
842-
return -i-2;
842+
return (short) (-i-2);
843843
found_set[i].table_offset=table_offset;
844844
found_set[i].found_offset=found_offset;
845845
found_sets++;
846-
return -i-2; /* return new postion */
846+
return (short) (-i-2); /* return new postion */
847847
}
848848

849849
/* Return 1 if regexp starts with \b or ends with \b*/
@@ -878,7 +878,8 @@ static uint replace_len(my_string str)
878878

879879
/* The actual loop */
880880

881-
uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, my_string from)
881+
static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
882+
my_string from)
882883
{
883884
reg1 REPLACE *rep_pos;
884885
reg2 REPLACE_STRING *rep_str;

include/my_dbug.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ extern void _db_pargs_(uint _line_,const char *keyword);
3939
extern void _db_doprnt_ _VARARGS((const char *format,...));
4040
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
4141
uint length);
42-
extern void _db_output_();
43-
extern void _db_lock_file();
44-
extern void _db_unlock_file();
42+
extern void _db_output_(void);
43+
extern void _db_lock_file(void);
44+
extern void _db_unlock_file(void);
4545

4646
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
4747
char **_db_framep_; \

sql/gen_lex_hash.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void print_hash_map(const char *name)
300300
char *cur;
301301
int i;
302302

303-
printf("uchar %s[%d]= {\n",name,size_hash_map);
303+
printf("static uchar %s[%d]= {\n",name,size_hash_map);
304304
for (i=0, cur= hash_map; i<size_hash_map; i++, cur++)
305305
{
306306
switch(i%4){
@@ -459,11 +459,11 @@ int main(int argc,char **argv)
459459
generate_find_structs();
460460
print_find_structs();
461461

462-
printf("\nunsigned int sql_functions_max_len=%d;\n",max_len);
463-
printf("\nunsigned int symbols_max_len=%d;\n\n",max_len2);
462+
printf("\static unsigned int sql_functions_max_len=%d;\n",max_len);
463+
printf("\static unsigned int symbols_max_len=%d;\n\n",max_len2);
464464

465465
printf("\
466-
inline SYMBOL *get_hash_symbol(const char *s,\n \
466+
static inline SYMBOL *get_hash_symbol(const char *s,\n\
467467
unsigned int len,bool function)\n\
468468
{\n\
469469
register uchar *hash_map;\n\

sql/mysql_priv.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,8 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
11131113
LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
11141114
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
11151115
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
1116-
LOCK_global_system_variables, LOCK_user_conn;
1116+
LOCK_global_system_variables, LOCK_user_conn,
1117+
LOCK_bytes_sent, LOCK_bytes_received;
11171118
extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
11181119
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
11191120
extern pthread_attr_t connection_attrib;

0 commit comments

Comments
 (0)