#At file:///export/home/tmp/ss156133/z/43414-50/ based on revid:azundris@stripped
2768 Staale Smedseng 2009-06-09
Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
Compiling MySQL with gcc 4.3.2 and later produces a number of
warnings, many of which are new with the recent compiler
versions.
This bug will be resolved in more than one patch to limit the
size of changesets. This is the first patch, fixing a number
of the warnings, predominantly "suggest using parentheses
around && in ||", and empty for and while bodies.
modified:
sql/field.cc
sql/field.h
sql/field_conv.cc
sql/gstream.cc
sql/handler.cc
sql/item.cc
sql/item_cmpfunc.cc
sql/item_func.cc
sql/item_subselect.cc
sql/item_sum.cc
sql/item_timefunc.cc
sql/log_event.cc
sql/opt_range.cc
sql/opt_sum.cc
sql/slave.cc
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2009-05-15 08:16:00 +0000
+++ b/sql/field.cc 2009-06-09 12:55:30 +0000
@@ -1157,7 +1157,7 @@ bool Field_num::get_int(CHARSET_INFO *cs
if (unsigned_flag)
{
- if (((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max) ||
+ if ((((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max)) ||
error == MY_ERRNO_ERANGE)
{
goto out_of_range;
@@ -1324,7 +1324,7 @@ void Field::copy_from_tmp(int row_offset
if (null_ptr)
{
*null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) |
- null_ptr[row_offset] & (uchar) null_bit);
+ (null_ptr[row_offset] & (uchar) null_bit));
}
}
@@ -3674,8 +3674,8 @@ int Field_float::store(const char *from,
int error;
char *end;
double nr= my_strntod(cs,(char*) from,len,&end,&error);
- if (error || (!len || (uint) (end-from) != len &&
- table->in_use->count_cuted_fields))
+ if (error || (!len || ((uint) (end-from) != len &&
+ table->in_use->count_cuted_fields)))
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
@@ -3915,8 +3915,8 @@ int Field_double::store(const char *from
int error;
char *end;
double nr= my_strntod(cs,(char*) from, len, &end, &error);
- if (error || (!len || (uint) (end-from) != len &&
- table->in_use->count_cuted_fields))
+ if (error || (!len || ((uint) (end-from) != len &&
+ table->in_use->count_cuted_fields)))
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
@@ -4771,7 +4771,7 @@ int Field_time::store(longlong nr, bool
MYSQL_TIMESTAMP_TIME, 1);
error= 1;
}
- else if (nr > (longlong) TIME_MAX_VALUE || nr < 0 && unsigned_val)
+ else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val))
{
tmp= TIME_MAX_VALUE;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -4930,7 +4930,7 @@ int Field_year::store(const char *from,
int error;
longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error);
- if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155 ||
+ if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155 ||
error == MY_ERRNO_ERANGE)
{
*ptr=0;
@@ -4973,7 +4973,7 @@ int Field_year::store(double nr)
int Field_year::store(longlong nr, bool unsigned_val)
{
- if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
+ if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155)
{
*ptr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -5968,16 +5968,22 @@ int Field_str::store(double nr)
/* Calculate the exponent from the 'e'-format conversion */
if (anr < 1.0 && anr > 0)
{
- for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100);
- for (; anr < 1e-10; exp-= 10, anr*= 1e10);
- for (i= 1; anr < 1 / log_10[i]; exp--, i++);
+ for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100)
+ {}
+ for (; anr < 1e-10; exp-= 10, anr*= 1e10)
+ {}
+ for (i= 1; anr < 1 / log_10[i]; exp--, i++)
+ {}
exp--;
}
else
{
- for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100);
- for (; anr > 1e10; exp+= 10, anr/= 1e10);
- for (i= 1; anr > log_10[i]; exp++, i++);
+ for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100)
+ {}
+ for (; anr > 1e10; exp+= 10, anr/= 1e10)
+ {}
+ for (i= 1; anr > log_10[i]; exp++, i++)
+ {}
}
max_length= local_char_length - neg;
@@ -7986,7 +7992,7 @@ bool Field_num::eq_def(Field *field)
Field_num *from_num= (Field_num*) field;
if (unsigned_flag != from_num->unsigned_flag ||
- zerofill && !from_num->zerofill && !zero_pack() ||
+ (zerofill && !from_num->zerofill && !zero_pack()) ||
dec != from_num->dec)
return 0;
return 1;
@@ -8065,7 +8071,8 @@ int Field_bit::store(const char *from, u
{
int delta;
- for (; length && !*from; from++, length--); // skip left 0's
+ for (; length && !*from; from++, length--) // skip left 0's
+ {}
delta= bytes_in_rec - length;
if (delta < -1 ||
@@ -8284,7 +8291,8 @@ int Field_bit_as_char::store(const char
int delta;
uchar bits= (uchar) (field_length & 7);
- for (; length && !*from; from++, length--); // skip left 0's
+ for (; length && !*from; from++, length--) // skip left 0's
+ {}
delta= bytes_in_rec - length;
if (delta < 0 ||
=== modified file 'sql/field.h'
--- a/sql/field.h 2009-01-15 10:48:31 +0000
+++ b/sql/field.h 2009-06-09 12:55:30 +0000
@@ -170,7 +170,7 @@ public:
memcpy(ptr, ptr + l_offset, pack_length());
if (null_ptr)
*null_ptr= ((*null_ptr & (uchar) ~null_bit) |
- null_ptr[l_offset] & null_bit);
+ (null_ptr[l_offset] & null_bit));
}
virtual bool binary() const { return 1; }
virtual bool zero_pack() const { return 1; }
=== modified file 'sql/field_conv.cc'
--- a/sql/field_conv.cc 2007-07-11 19:55:40 +0000
+++ b/sql/field_conv.cc 2009-06-09 12:55:30 +0000
@@ -95,7 +95,7 @@ static void do_field_to_null_str(Copy_fi
static void do_outer_field_to_null_str(Copy_field *copy)
{
if (*copy->null_row ||
- copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))
+ (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
{
bzero(copy->to_ptr,copy->from_length);
copy->to_null_ptr[0]=1; // Always bit 1
@@ -209,7 +209,7 @@ static void do_copy_null(Copy_field *cop
static void do_outer_field_null(Copy_field *copy)
{
if (*copy->null_row ||
- copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))
+ (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
{
*copy->to_null_ptr|=copy->to_bit;
copy->to_field->reset();
@@ -656,9 +656,9 @@ void (*Copy_field::get_copy_func(Field *
*/
if (to->real_type() != from->real_type() ||
!compatible_db_low_byte_first ||
- ((to->table->in_use->variables.sql_mode &
+ (((to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
- to->type() == FIELD_TYPE_DATE ||
+ to->type() == FIELD_TYPE_DATE) ||
to->type() == FIELD_TYPE_DATETIME))
{
if (from->real_type() == FIELD_TYPE_ENUM ||
=== modified file 'sql/gstream.cc'
--- a/sql/gstream.cc 2007-10-05 11:33:08 +0000
+++ b/sql/gstream.cc 2009-06-09 12:55:30 +0000
@@ -75,7 +75,7 @@ bool Gis_read_stream::get_next_number(do
skip_space();
if ((m_cur >= m_limit) ||
- (*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
+ ((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+'))
{
set_error_msg("Numeric constant expected");
return 1;
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2009-03-27 06:24:32 +0000
+++ b/sql/handler.cc 2009-06-09 12:55:30 +0000
@@ -1642,8 +1642,8 @@ int handler::update_auto_increment()
thd->prev_insert_id= thd->next_insert_id;
if ((nr= table->next_number_field->val_int()) != 0 ||
- table->auto_increment_field_not_null &&
- thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
+ (table->auto_increment_field_not_null &&
+ thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO))
{
/* Mark that we didn't generate a new value **/
auto_increment_column_changed=0;
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2009-06-04 09:52:40 +0000
+++ b/sql/item.cc 2009-06-09 12:55:30 +0000
@@ -1478,7 +1478,7 @@ bool DTCollation::aggregate(DTCollation
set(dt);
}
else
- ; // Do nothing
+ {} // Do nothing
}
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
left_is_superset(this, &dt))
@@ -2587,7 +2587,7 @@ void Item_param::set_time(MYSQL_TIME *tm
if (value.time.year > 9999 || value.time.month > 12 ||
value.time.day > 31 ||
- time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23 ||
+ (time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) ||
value.time.minute > 59 || value.time.second > 59)
{
char buff[MAX_DATE_STRING_REP_LENGTH];
@@ -4728,8 +4728,8 @@ int Item::save_in_field(Field *field, bo
{
int error;
if (result_type() == STRING_RESULT ||
- result_type() == REAL_RESULT &&
- field->result_type() == STRING_RESULT)
+ (result_type() == REAL_RESULT &&
+ field->result_type() == STRING_RESULT))
{
String *result;
CHARSET_INFO *cs= collation.collation;
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2009-04-14 17:20:13 +0000
+++ b/sql/item_cmpfunc.cc 2009-06-09 12:55:30 +0000
@@ -1419,8 +1419,8 @@ longlong Item_func_truth::val_int()
bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
{
- if (!args[0]->fixed && args[0]->fix_fields(thd, args) ||
- !cache && !(cache= Item_cache::get_cache(args[0])))
+ if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
+ (!cache && !(cache= Item_cache::get_cache(args[0]))))
return 1;
cache->setup(args[0]);
@@ -2934,8 +2934,8 @@ int cmp_longlong(void *cmp_arg,
One of the args is unsigned and is too big to fit into the
positive signed range. Report no match.
*/
- if (a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX ||
- b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX)
+ if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) ||
+ (b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX))
return a->unsigned_flag ? 1 : -1;
/*
Although the signedness differs both args can fit into the signed
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2009-06-02 06:38:13 +0000
+++ b/sql/item_func.cc 2009-06-09 12:55:30 +0000
@@ -4427,8 +4427,8 @@ int Item_func_set_user_var::save_in_fiel
update();
if (result_type() == STRING_RESULT ||
- result_type() == REAL_RESULT &&
- field->result_type() == STRING_RESULT)
+ (result_type() == REAL_RESULT &&
+ field->result_type() == STRING_RESULT))
{
String *result;
CHARSET_INFO *cs= collation.collation;
=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc 2008-03-28 11:31:52 +0000
+++ b/sql/item_subselect.cc 2009-06-09 12:55:30 +0000
@@ -1232,8 +1232,8 @@ Item_in_subselect::row_value_transformer
Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++)
{
- DBUG_ASSERT(left_expr->fixed &&
- select_lex->ref_pointer_array[i]->fixed ||
+ DBUG_ASSERT((left_expr->fixed &&
+ select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF));
@@ -1310,8 +1310,8 @@ Item_in_subselect::row_value_transformer
for (uint i= 0; i < cols_num; i++)
{
Item *item, *item_isnull;
- DBUG_ASSERT(left_expr->fixed &&
- select_lex->ref_pointer_array[i]->fixed ||
+ DBUG_ASSERT((left_expr->fixed &&
+ select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF));
=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc 2009-03-11 12:10:44 +0000
+++ b/sql/item_sum.cc 2009-06-09 12:55:30 +0000
@@ -652,8 +652,8 @@ Item_sum_hybrid::fix_fields(THD *thd, It
return TRUE;
// 'item' can be changed during fix_fields
- if (!item->fixed &&
- item->fix_fields(thd, args) ||
+ if ((!item->fixed &&
+ item->fix_fields(thd, args)) ||
(item= args[0])->check_cols(1))
return TRUE;
decimals=item->decimals;
@@ -969,8 +969,8 @@ void Item_sum_distinct::fix_length_and_d
integers each <= 2^32.
*/
if (table_field_type == MYSQL_TYPE_INT24 ||
- table_field_type >= MYSQL_TYPE_TINY &&
- table_field_type <= MYSQL_TYPE_LONG)
+ (table_field_type >= MYSQL_TYPE_TINY &&
+ table_field_type <= MYSQL_TYPE_LONG))
{
val.traits= Hybrid_type_traits_fast_decimal::instance();
break;
@@ -2608,8 +2608,8 @@ bool Item_sum_count_distinct::setup(THD
enum enum_field_types f_type= f->type();
tree_key_length+= f->pack_length();
if ((f_type == MYSQL_TYPE_VARCHAR) ||
- !f->binary() && (f_type == MYSQL_TYPE_STRING ||
- f_type == MYSQL_TYPE_VAR_STRING))
+ (!f->binary() && (f_type == MYSQL_TYPE_STRING ||
+ f_type == MYSQL_TYPE_VAR_STRING)))
{
all_binary= FALSE;
break;
=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc 2009-02-10 22:47:54 +0000
+++ b/sql/item_timefunc.cc 2009-06-09 12:55:30 +0000
@@ -439,7 +439,7 @@ static bool extract_date_time(DATE_TIME_
strict_week_number= (*ptr=='V' || *ptr=='v');
tmp= (char*) val + min(val_len, 2);
if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- strict_week_number && !week_number ||
+ (strict_week_number && !week_number) ||
week_number > 53)
goto err;
val= tmp;
@@ -535,10 +535,10 @@ static bool extract_date_time(DATE_TIME_
%V,%v require %X,%x resprectively,
%U,%u should be used with %Y and not %X or %x
*/
- if (strict_week_number &&
+ if ((strict_week_number &&
(strict_week_number_year < 0 ||
- strict_week_number_year_type != sunday_first_n_first_week_non_iso) ||
- !strict_week_number && strict_week_number_year >= 0)
+ strict_week_number_year_type != sunday_first_n_first_week_non_iso)) ||
+ (!strict_week_number && strict_week_number_year >= 0))
goto err;
/* Number of days since year 0 till 1st Jan of this year */
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2009-05-31 03:26:58 +0000
+++ b/sql/log_event.cc 2009-06-09 12:55:30 +0000
@@ -1733,7 +1733,8 @@ void Query_log_event::print_query_header
if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
{
- if (different_db= memcmp(print_event_info->db, db, db_len + 1))
+ different_db= memcmp(print_event_info->db, db, db_len + 1);
+ if (different_db)
memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db)
fprintf(file, "use %s%s\n", db, print_event_info->delimiter);
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2009-03-19 13:44:58 +0000
+++ b/sql/opt_range.cc 2009-06-09 12:55:30 +0000
@@ -2032,7 +2032,7 @@ int SQL_SELECT::test_quick_select(THD *t
quick=0;
needed_reg.clear_all();
quick_keys.clear_all();
- if ((specialflag & SPECIAL_SAFE_MODE) && ! force_quick_range ||
+ if (((specialflag & SPECIAL_SAFE_MODE) && ! force_quick_range) ||
!limit)
DBUG_RETURN(0); /* purecov: inspected */
if (keys_to_use.is_clear_all())
@@ -2462,8 +2462,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick
DBUG_PRINT("info", ("index_merge scans cost %g", imerge_cost));
if (imerge_too_expensive || (imerge_cost > read_time) ||
- (non_cpk_scan_records+cpk_scan_records >= param->table->file->records) &&
- read_time != DBL_MAX)
+ ((non_cpk_scan_records+cpk_scan_records >= param->table->file->records) &&
+ read_time != DBL_MAX))
{
/*
Bail out if it is obvious that both index_merge and ROR-union will be
@@ -6490,7 +6490,7 @@ QUICK_RANGE_SELECT *get_quick_select_for
goto err;
quick->records= records;
- if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
+ if ((cp_buffer_from_ref(thd,ref) && thd->is_fatal_error) ||
!(range= new(alloc) QUICK_RANGE()))
goto err; // out of memory
@@ -7342,7 +7342,7 @@ int QUICK_RANGE_SELECT::cmp_prev(QUICK_R
cmp= key_cmp(key_part_info, (byte*) range_arg->min_key,
range_arg->min_length);
- if (cmp > 0 || cmp == 0 && !(range_arg->flag & NEAR_MIN))
+ if (cmp > 0 || (cmp == 0 && !(range_arg->flag & NEAR_MIN)))
return 0;
return 1; // outside of range
}
@@ -9395,7 +9395,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min
/* Compare the found key with max_key. */
int cmp_res= key_cmp(index_info->key_part, max_key,
real_prefix_len + min_max_arg_len);
- if (!((cur_range->flag & NEAR_MAX) && (cmp_res == -1) ||
+ if (!(((cur_range->flag & NEAR_MAX) && (cmp_res == -1)) ||
(cmp_res <= 0)))
{
result = HA_ERR_KEY_NOT_FOUND;
@@ -9511,7 +9511,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max
/* Compare the found key with min_key. */
int cmp_res= key_cmp(index_info->key_part, min_key,
real_prefix_len + min_max_arg_len);
- if (!((cur_range->flag & NEAR_MIN) && (cmp_res == 1) ||
+ if (!(((cur_range->flag & NEAR_MIN) && (cmp_res == 1)) ||
(cmp_res >= 0)))
continue;
}
=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc 2009-02-10 22:47:54 +0000
+++ b/sql/opt_sum.cc 2009-06-09 12:55:30 +0000
@@ -690,8 +690,8 @@ static bool matching_cond(bool max_fl, T
}
else if (eq_type)
{
- if (!is_null && !cond->val_int() ||
- is_null && !test(part->field->is_null()))
+ if ((!is_null && !cond->val_int()) ||
+ (is_null && !test(part->field->is_null())))
return 0; // Impossible test
}
else if (is_field_part)
=== modified file 'sql/slave.cc'
--- a/sql/slave.cc 2009-05-22 23:15:21 +0000
+++ b/sql/slave.cc 2009-06-09 12:55:30 +0000
@@ -1334,7 +1334,8 @@ static int init_strvar_from_file(char *v
up to and including newline.
*/
int c;
- while (((c=my_b_get(f)) != '\n' && c != my_b_EOF));
+ while (((c=my_b_get(f)) != '\n' && c != my_b_EOF))
+ {}
}
return 0;
}
Attachment: [text/bzr-bundle] bzr/staale.smedseng@sun.com-20090609125530-rx3qsuwltlg31nan.bundle