Skip to content

Commit dae006c

Browse files
author
Staale Smedseng
committed
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.
1 parent e43d8e5 commit dae006c

File tree

15 files changed

+61
-60
lines changed

15 files changed

+61
-60
lines changed

sql/field.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len,
11571157
if (unsigned_flag)
11581158
{
11591159

1160-
if (((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max) ||
1160+
if ((((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max)) ||
11611161
error == MY_ERRNO_ERANGE)
11621162
{
11631163
goto out_of_range;
@@ -1324,7 +1324,7 @@ void Field::copy_from_tmp(int row_offset)
13241324
if (null_ptr)
13251325
{
13261326
*null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) |
1327-
null_ptr[row_offset] & (uchar) null_bit);
1327+
(null_ptr[row_offset] & (uchar) null_bit));
13281328
}
13291329
}
13301330

@@ -3674,8 +3674,8 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
36743674
int error;
36753675
char *end;
36763676
double nr= my_strntod(cs,(char*) from,len,&end,&error);
3677-
if (error || (!len || (uint) (end-from) != len &&
3678-
table->in_use->count_cuted_fields))
3677+
if (error || (!len || ((uint) (end-from) != len &&
3678+
table->in_use->count_cuted_fields)))
36793679
{
36803680
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
36813681
(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)
39153915
int error;
39163916
char *end;
39173917
double nr= my_strntod(cs,(char*) from, len, &end, &error);
3918-
if (error || (!len || (uint) (end-from) != len &&
3919-
table->in_use->count_cuted_fields))
3918+
if (error || (!len || ((uint) (end-from) != len &&
3919+
table->in_use->count_cuted_fields)))
39203920
{
39213921
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
39223922
(error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1);
@@ -4771,7 +4771,7 @@ int Field_time::store(longlong nr, bool unsigned_val)
47714771
MYSQL_TIMESTAMP_TIME, 1);
47724772
error= 1;
47734773
}
4774-
else if (nr > (longlong) TIME_MAX_VALUE || nr < 0 && unsigned_val)
4774+
else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val))
47754775
{
47764776
tmp= TIME_MAX_VALUE;
47774777
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -4930,7 +4930,7 @@ int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
49304930
int error;
49314931
longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error);
49324932

4933-
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155 ||
4933+
if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155 ||
49344934
error == MY_ERRNO_ERANGE)
49354935
{
49364936
*ptr=0;
@@ -4973,7 +4973,7 @@ int Field_year::store(double nr)
49734973

49744974
int Field_year::store(longlong nr, bool unsigned_val)
49754975
{
4976-
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
4976+
if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155)
49774977
{
49784978
*ptr= 0;
49794979
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
@@ -5968,16 +5968,16 @@ int Field_str::store(double nr)
59685968
/* Calculate the exponent from the 'e'-format conversion */
59695969
if (anr < 1.0 && anr > 0)
59705970
{
5971-
for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100);
5972-
for (; anr < 1e-10; exp-= 10, anr*= 1e10);
5973-
for (i= 1; anr < 1 / log_10[i]; exp--, i++);
5971+
for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100) ;
5972+
for (; anr < 1e-10; exp-= 10, anr*= 1e10) ;
5973+
for (i= 1; anr < 1 / log_10[i]; exp--, i++) ;
59745974
exp--;
59755975
}
59765976
else
59775977
{
5978-
for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100);
5979-
for (; anr > 1e10; exp+= 10, anr/= 1e10);
5980-
for (i= 1; anr > log_10[i]; exp++, i++);
5978+
for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100) ;
5979+
for (; anr > 1e10; exp+= 10, anr/= 1e10) ;
5980+
for (i= 1; anr > log_10[i]; exp++, i++) ;
59815981
}
59825982

59835983
max_length= local_char_length - neg;
@@ -7986,7 +7986,7 @@ bool Field_num::eq_def(Field *field)
79867986
Field_num *from_num= (Field_num*) field;
79877987

79887988
if (unsigned_flag != from_num->unsigned_flag ||
7989-
zerofill && !from_num->zerofill && !zero_pack() ||
7989+
(zerofill && !from_num->zerofill && !zero_pack()) ||
79907990
dec != from_num->dec)
79917991
return 0;
79927992
return 1;
@@ -8065,7 +8065,7 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
80658065
{
80668066
int delta;
80678067

8068-
for (; length && !*from; from++, length--); // skip left 0's
8068+
for (; length && !*from; from++, length--) ; // skip left 0's
80698069
delta= bytes_in_rec - length;
80708070

80718071
if (delta < -1 ||
@@ -8284,7 +8284,7 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
82848284
int delta;
82858285
uchar bits= (uchar) (field_length & 7);
82868286

8287-
for (; length && !*from; from++, length--); // skip left 0's
8287+
for (; length && !*from; from++, length--) ; // skip left 0's
82888288
delta= bytes_in_rec - length;
82898289

82908290
if (delta < 0 ||

sql/field.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Field
170170
memcpy(ptr, ptr + l_offset, pack_length());
171171
if (null_ptr)
172172
*null_ptr= ((*null_ptr & (uchar) ~null_bit) |
173-
null_ptr[l_offset] & null_bit);
173+
(null_ptr[l_offset] & null_bit));
174174
}
175175
virtual bool binary() const { return 1; }
176176
virtual bool zero_pack() const { return 1; }

sql/field_conv.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void do_field_to_null_str(Copy_field *copy)
9595
static void do_outer_field_to_null_str(Copy_field *copy)
9696
{
9797
if (*copy->null_row ||
98-
copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))
98+
(copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
9999
{
100100
bzero(copy->to_ptr,copy->from_length);
101101
copy->to_null_ptr[0]=1; // Always bit 1
@@ -209,7 +209,7 @@ static void do_copy_null(Copy_field *copy)
209209
static void do_outer_field_null(Copy_field *copy)
210210
{
211211
if (*copy->null_row ||
212-
copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))
212+
(copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
213213
{
214214
*copy->to_null_ptr|=copy->to_bit;
215215
copy->to_field->reset();
@@ -656,9 +656,9 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
656656
*/
657657
if (to->real_type() != from->real_type() ||
658658
!compatible_db_low_byte_first ||
659-
((to->table->in_use->variables.sql_mode &
659+
(((to->table->in_use->variables.sql_mode &
660660
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
661-
to->type() == FIELD_TYPE_DATE ||
661+
to->type() == FIELD_TYPE_DATE) ||
662662
to->type() == FIELD_TYPE_DATETIME))
663663
{
664664
if (from->real_type() == FIELD_TYPE_ENUM ||

sql/gstream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool Gis_read_stream::get_next_number(double *d)
7575
skip_space();
7676

7777
if ((m_cur >= m_limit) ||
78-
(*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
78+
((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+'))
7979
{
8080
set_error_msg("Numeric constant expected");
8181
return 1;

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,8 +1642,8 @@ int handler::update_auto_increment()
16421642
thd->prev_insert_id= thd->next_insert_id;
16431643

16441644
if ((nr= table->next_number_field->val_int()) != 0 ||
1645-
table->auto_increment_field_not_null &&
1646-
thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
1645+
(table->auto_increment_field_not_null &&
1646+
thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO))
16471647
{
16481648
/* Mark that we didn't generate a new value **/
16491649
auto_increment_column_changed=0;

sql/item.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
25872587

25882588
if (value.time.year > 9999 || value.time.month > 12 ||
25892589
value.time.day > 31 ||
2590-
time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23 ||
2590+
(time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) ||
25912591
value.time.minute > 59 || value.time.second > 59)
25922592
{
25932593
char buff[MAX_DATE_STRING_REP_LENGTH];
@@ -4728,8 +4728,8 @@ int Item::save_in_field(Field *field, bool no_conversions)
47284728
{
47294729
int error;
47304730
if (result_type() == STRING_RESULT ||
4731-
result_type() == REAL_RESULT &&
4732-
field->result_type() == STRING_RESULT)
4731+
(result_type() == REAL_RESULT &&
4732+
field->result_type() == STRING_RESULT))
47334733
{
47344734
String *result;
47354735
CHARSET_INFO *cs= collation.collation;

sql/item_cmpfunc.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,8 @@ longlong Item_func_truth::val_int()
14191419

14201420
bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
14211421
{
1422-
if (!args[0]->fixed && args[0]->fix_fields(thd, args) ||
1423-
!cache && !(cache= Item_cache::get_cache(args[0])))
1422+
if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
1423+
(!cache && !(cache= Item_cache::get_cache(args[0]))))
14241424
return 1;
14251425

14261426
cache->setup(args[0]);
@@ -2934,8 +2934,8 @@ int cmp_longlong(void *cmp_arg,
29342934
One of the args is unsigned and is too big to fit into the
29352935
positive signed range. Report no match.
29362936
*/
2937-
if (a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX ||
2938-
b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX)
2937+
if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) ||
2938+
(b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX))
29392939
return a->unsigned_flag ? 1 : -1;
29402940
/*
29412941
Although the signedness differs both args can fit into the signed

sql/item_func.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4427,8 +4427,8 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
44274427
update();
44284428

44294429
if (result_type() == STRING_RESULT ||
4430-
result_type() == REAL_RESULT &&
4431-
field->result_type() == STRING_RESULT)
4430+
(result_type() == REAL_RESULT &&
4431+
field->result_type() == STRING_RESULT))
44324432
{
44334433
String *result;
44344434
CHARSET_INFO *cs= collation.collation;

sql/item_subselect.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
12321232
Item *item_having_part2= 0;
12331233
for (uint i= 0; i < cols_num; i++)
12341234
{
1235-
DBUG_ASSERT(left_expr->fixed &&
1236-
select_lex->ref_pointer_array[i]->fixed ||
1235+
DBUG_ASSERT((left_expr->fixed &&
1236+
select_lex->ref_pointer_array[i]->fixed) ||
12371237
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
12381238
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
12391239
Item_ref::OUTER_REF));
@@ -1310,8 +1310,8 @@ Item_in_subselect::row_value_transformer(JOIN *join)
13101310
for (uint i= 0; i < cols_num; i++)
13111311
{
13121312
Item *item, *item_isnull;
1313-
DBUG_ASSERT(left_expr->fixed &&
1314-
select_lex->ref_pointer_array[i]->fixed ||
1313+
DBUG_ASSERT((left_expr->fixed &&
1314+
select_lex->ref_pointer_array[i]->fixed) ||
13151315
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
13161316
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
13171317
Item_ref::OUTER_REF));

sql/item_sum.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
652652
return TRUE;
653653

654654
// 'item' can be changed during fix_fields
655-
if (!item->fixed &&
656-
item->fix_fields(thd, args) ||
655+
if ((!item->fixed &&
656+
item->fix_fields(thd, args)) ||
657657
(item= args[0])->check_cols(1))
658658
return TRUE;
659659
decimals=item->decimals;
@@ -969,8 +969,8 @@ void Item_sum_distinct::fix_length_and_dec()
969969
integers each <= 2^32.
970970
*/
971971
if (table_field_type == MYSQL_TYPE_INT24 ||
972-
table_field_type >= MYSQL_TYPE_TINY &&
973-
table_field_type <= MYSQL_TYPE_LONG)
972+
(table_field_type >= MYSQL_TYPE_TINY &&
973+
table_field_type <= MYSQL_TYPE_LONG))
974974
{
975975
val.traits= Hybrid_type_traits_fast_decimal::instance();
976976
break;
@@ -2608,8 +2608,8 @@ bool Item_sum_count_distinct::setup(THD *thd)
26082608
enum enum_field_types f_type= f->type();
26092609
tree_key_length+= f->pack_length();
26102610
if ((f_type == MYSQL_TYPE_VARCHAR) ||
2611-
!f->binary() && (f_type == MYSQL_TYPE_STRING ||
2612-
f_type == MYSQL_TYPE_VAR_STRING))
2611+
(!f->binary() && (f_type == MYSQL_TYPE_STRING ||
2612+
f_type == MYSQL_TYPE_VAR_STRING)))
26132613
{
26142614
all_binary= FALSE;
26152615
break;

0 commit comments

Comments
 (0)