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.
This commit is contained in:
parent
0b7fecf9e4
commit
a073ee45c2
36
sql/field.cc
36
sql/field.cc
@ -1157,7 +1157,7 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len,
|
||||
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,uint len,CHARSET_INFO *cs)
|
||||
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,uint len,CHARSET_INFO *cs)
|
||||
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 unsigned_val)
|
||||
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, uint len,CHARSET_INFO *cs)
|
||||
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,16 @@ 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 +7986,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 +8065,7 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
|
||||
{
|
||||
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 +8284,7 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
|
||||
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 ||
|
||||
|
@ -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; }
|
||||
|
@ -95,7 +95,7 @@ static void do_field_to_null_str(Copy_field *copy)
|
||||
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 *copy)
|
||||
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 *to,Field *from))(Copy_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 ||
|
||||
|
@ -75,7 +75,7 @@ bool Gis_read_stream::get_next_number(double *d)
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -2587,7 +2587,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
|
||||
|
||||
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, bool no_conversions)
|
||||
{
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -4427,8 +4427,8 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
|
||||
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;
|
||||
|
@ -1232,8 +1232,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
|
||||
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(JOIN *join)
|
||||
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));
|
||||
|
@ -652,8 +652,8 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
|
||||
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_dec()
|
||||
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 *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;
|
||||
|
@ -439,7 +439,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
|
||||
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_FORMAT *format,
|
||||
%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 */
|
||||
|
@ -1733,7 +1733,8 @@ void Query_log_event::print_query_header(FILE* file,
|
||||
|
||||
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);
|
||||
|
@ -2032,7 +2032,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
|
||||
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(PARAM *param, SEL_IMERGE *imerge,
|
||||
|
||||
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_ref(THD *thd, TABLE *table,
|
||||
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_RANGE *range_arg)
|
||||
|
||||
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_in_range()
|
||||
/* 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_in_range()
|
||||
/* 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;
|
||||
}
|
||||
|
@ -690,8 +690,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
|
||||
}
|
||||
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)
|
||||
|
@ -1334,7 +1334,7 @@ static int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user