summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStaale Smedseng <staale.smedseng@sun.com>2009-09-17 17:10:30 +0200
committerStaale Smedseng <staale.smedseng@sun.com>2009-09-17 17:10:30 +0200
commite5888b16afcef42e8127a815cc5a95abc283c6d9 (patch)
tree3cf056e46acab4ed88aecfc3171b43e75db69e48
parent3dea04c58bf665d98e3bbdb12a6386c5920c1b77 (diff)
downloadmariadb-git-e5888b16afcef42e8127a815cc5a95abc283c6d9.tar.gz
Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2 This is the fifth patch cleaning up more GCC warnings about variables used before initialized using the new macro UNINIT_VAR().
-rw-r--r--heap/hp_write.c7
-rw-r--r--include/my_global.h6
-rw-r--r--myisam/mi_search.c6
-rw-r--r--myisam/mi_write.c6
-rw-r--r--mysys/hash.c7
-rw-r--r--sql-common/my_time.c3
-rw-r--r--sql/item_func.cc6
-rw-r--r--sql/item_timefunc.cc11
-rw-r--r--sql/sql_handler.cc7
-rw-r--r--sql/sql_lex.cc3
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/udf_example.c4
12 files changed, 20 insertions, 49 deletions
diff --git a/heap/hp_write.c b/heap/hp_write.c
index 6aa34acf2c3..85551c1cc41 100644
--- a/heap/hp_write.c
+++ b/heap/hp_write.c
@@ -196,13 +196,10 @@ int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
HP_SHARE *share = info->s;
int flag;
ulong halfbuff,hashnr,first_index;
- byte *ptr_to_rec,*ptr_to_rec2;
- HASH_INFO *empty,*gpos,*gpos2,*pos;
+ byte *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2);
+ HASH_INFO *empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos;
DBUG_ENTER("hp_write_key");
- LINT_INIT(gpos); LINT_INIT(gpos2);
- LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2);
-
flag=0;
if (!(empty= hp_find_free_hash(share,&keyinfo->block,share->records)))
DBUG_RETURN(-1); /* No more memory */
diff --git a/include/my_global.h b/include/my_global.h
index 0b5458215c6..6910ae092e1 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -458,12 +458,6 @@ int __void__;
#define LINT_INIT(var)
#endif
-#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_purify)
-#define PURIFY_OR_LINT_INIT(var) var=0
-#else
-#define PURIFY_OR_LINT_INIT(var)
-#endif
-
/*
Suppress uninitialized variable warning without generating code.
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index 3b1cd6158f2..21efaa03744 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -295,7 +295,8 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
uchar *end, *kseg, *vseg;
uchar *sort_order=keyinfo->seg->charset->sort_order;
uchar tt_buff[MI_MAX_KEY_BUFF+2], *t_buff=tt_buff+2;
- uchar *saved_from, *saved_to, *saved_vseg;
+ uchar *UNINIT_VAR(saved_from), *UNINIT_VAR(saved_to);
+ uchar *UNINIT_VAR(saved_vseg);
uint saved_length=0, saved_prefix_len=0;
uint length_pack;
DBUG_ENTER("_mi_prefix_search");
@@ -303,9 +304,6 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
LINT_INIT(length);
LINT_INIT(prefix_len);
LINT_INIT(seg_len_pack);
- LINT_INIT(saved_from);
- LINT_INIT(saved_to);
- LINT_INIT(saved_vseg);
t_buff[0]=0; /* Avoid bugs */
end= page+mi_getint(page);
diff --git a/myisam/mi_write.c b/myisam/mi_write.c
index b4843a748dd..61cea588562 100644
--- a/myisam/mi_write.c
+++ b/myisam/mi_write.c
@@ -700,8 +700,8 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uint *return_key_length,
uchar **after_key)
{
- uint keys,length,last_length,key_ref_length;
- uchar *end,*lastpos,*prevpos;
+ uint keys,length,UNINIT_VAR(last_length),key_ref_length;
+ uchar *end,*lastpos,*UNINIT_VAR(prevpos);
uchar key_buff[MI_MAX_KEY_BUFF];
DBUG_ENTER("_mi_find_last_pos");
@@ -720,8 +720,6 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page,
DBUG_RETURN(end);
}
- LINT_INIT(prevpos);
- LINT_INIT(last_length);
end=page+length-key_ref_length;
*key='\0';
length=0;
diff --git a/mysys/hash.c b/mysys/hash.c
index 4aab75609f4..3e7851a886f 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -332,11 +332,8 @@ my_bool my_hash_insert(HASH *info,const byte *record)
{
int flag;
uint halfbuff,hash_nr,first_index,idx;
- byte *ptr_to_rec,*ptr_to_rec2;
- HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
-
- LINT_INIT(gpos); LINT_INIT(gpos2);
- LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2);
+ byte *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2);
+ HASH_LINK *data,*empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos;
flag=0;
if (!(empty=(HASH_LINK*) alloc_dynamic(&info->array)))
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index d2ef9da25f5..ed1279f7afb 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -165,7 +165,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
uint add_hours= 0, start_loop;
ulong not_zero_date, allow_space;
my_bool is_internal_format;
- const char *pos, *last_field_pos;
+ const char *pos, *UNINIT_VAR(last_field_pos);
const char *end=str+length;
const uchar *format_position;
my_bool found_delimitier= 0, found_space= 0;
@@ -174,7 +174,6 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
DBUG_PRINT("ENTER",("str: %.*s",length,str));
LINT_INIT(field_length);
- LINT_INIT(last_field_pos);
*was_cut= 0;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3c1e2126008..c6dbdb1d9a7 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -428,8 +428,7 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const
Field *Item_func::tmp_table_field(TABLE *t_arg)
{
- Field *res;
- LINT_INIT(res);
+ Field *res= NULL;
switch (result_type()) {
case INT_RESULT:
@@ -4202,9 +4201,8 @@ void Item_func_set_user_var::save_item_result(Item *item)
bool
Item_func_set_user_var::update()
{
- bool res;
+ bool res= NULL;
DBUG_ENTER("Item_func_set_user_var::update");
- LINT_INIT(res);
switch (cached_result_type) {
case REAL_RESULT:
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 39f869106b6..de76f821795 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -271,9 +271,9 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
int strict_week_number_year= -1;
int frac_part;
bool usa_time= 0;
- bool sunday_first_n_first_week_non_iso;
- bool strict_week_number;
- bool strict_week_number_year_type;
+ bool UNINIT_VAR(sunday_first_n_first_week_non_iso);
+ bool UNINIT_VAR(strict_week_number);
+ bool UNINIT_VAR(strict_week_number_year_type);
const char *val_begin= val;
const char *val_end= val + length;
const char *ptr= format->format.str;
@@ -281,11 +281,6 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
CHARSET_INFO *cs= &my_charset_bin;
DBUG_ENTER("extract_date_time");
- LINT_INIT(strict_week_number);
- /* Remove valgrind varnings when using gcc 3.3 and -O1 */
- PURIFY_OR_LINT_INIT(strict_week_number_year_type);
- PURIFY_OR_LINT_INIT(sunday_first_n_first_week_non_iso);
-
if (!sub_pattern_end)
bzero((char*) l_time, sizeof(*l_time));
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 721b365a7b9..5bd28add428 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -385,16 +385,13 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
String buffer(buff, sizeof(buff), system_charset_info);
int error, keyno= -1;
uint num_rows;
- byte *key;
- uint key_len;
+ byte *UNINIT_VAR(key);
+ uint UNINIT_VAR(key_len);
bool need_reopen;
DBUG_ENTER("mysql_ha_read");
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->table_name, tables->alias));
- LINT_INIT(key);
- LINT_INIT(key_len);
-
thd->lex->select_lex.context.resolve_in_table_list_only(tables);
list.push_front(new Item_field(&thd->lex->select_lex.context,
NULL, NULL, "*"));
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index b0b4256184c..17ee53d446b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -530,7 +530,7 @@ static inline uint int_token(const char *str,uint length)
int MYSQLlex(void *arg, void *yythd)
{
- reg1 uchar c;
+ reg1 uchar UNINIT_VAR(c);
bool comment_closed;
int tokval, result_state;
uint length;
@@ -550,7 +550,6 @@ int MYSQLlex(void *arg, void *yythd)
lip->tok_start=lip->tok_end=lip->ptr;
state=lip->next_state;
lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
- LINT_INIT(c);
for (;;)
{
switch (state) {
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9d5e67c9532..84b5b61c941 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10480,9 +10480,8 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
{
int rc= 0;
enum_nested_loop_state error= NESTED_LOOP_OK;
- JOIN_TAB *join_tab;
+ JOIN_TAB *UNINIT_VAR(join_tab);
DBUG_ENTER("do_select");
- LINT_INIT(join_tab);
join->procedure=procedure;
join->tmp_table= table; /* Save for easy recursion */
diff --git a/sql/udf_example.c b/sql/udf_example.c
index db48984eed8..019d4d834dd 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -139,10 +139,10 @@ typedef long long longlong;
#include <mysql.h>
#include <ctype.h>
-static pthread_mutex_t LOCK_hostname;
-
#ifdef HAVE_DLOPEN
+static pthread_mutex_t LOCK_hostname;
+
/* These must be right or mysqld will not find the symbol! */
my_bool metaphon_init(UDF_INIT *initid, UDF_ARGS *args, char *message);