Commit 36792ff5 authored by Davi Arnaut's avatar Davi Arnaut

Fix warnings and bug spotted by gcc-4.3.

Related to operator precedence and associativity.
Make the expressions as explicit as possible.

sql/field.h:
  Silence gcc-4.3 warning: be more explicit.
sql/item.cc:
  Silence gcc-4.3 warning: be more explicit.
sql/item_sum.cc:
  Silence gcc-4.3 warning: be more explicit.
sql/log_event.cc:
  Silence gcc-4.3 warning: be more explicit.
sql/spatial.h:
  Silence gcc-4.3 warning: be more explicit.
sql/sql_lex.cc:
  Silence gcc-4.3 warning: be more explicit.
sql/table.h:
  Silence gcc-4.3 warning: be more explicit.
storage/federated/ha_federated.cc:
  Fix operator precedence bug.
storage/heap/ha_heap.cc:
  Silence gcc-4.3 warning: be more explicit.
parent 9ab3e399
...@@ -209,7 +209,7 @@ class Field ...@@ -209,7 +209,7 @@ class Field
memcpy(ptr, ptr + l_offset, pack_length()); memcpy(ptr, ptr + l_offset, pack_length());
if (null_ptr) if (null_ptr)
*null_ptr= ((*null_ptr & (uchar) ~null_bit) | *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 binary() const { return 1; }
virtual bool zero_pack() const { return 1; } virtual bool zero_pack() const { return 1; }
......
...@@ -2628,7 +2628,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type, ...@@ -2628,7 +2628,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
if (value.time.year > 9999 || value.time.month > 12 || if (value.time.year > 9999 || value.time.month > 12 ||
value.time.day > 31 || 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) value.time.minute > 59 || value.time.second > 59)
{ {
char buff[MAX_DATE_STRING_REP_LENGTH]; char buff[MAX_DATE_STRING_REP_LENGTH];
...@@ -4840,8 +4840,8 @@ int Item::save_in_field(Field *field, bool no_conversions) ...@@ -4840,8 +4840,8 @@ int Item::save_in_field(Field *field, bool no_conversions)
{ {
int error; int error;
if (result_type() == STRING_RESULT || if (result_type() == STRING_RESULT ||
result_type() == REAL_RESULT && (result_type() == REAL_RESULT &&
field->result_type() == STRING_RESULT) field->result_type() == STRING_RESULT))
{ {
String *result; String *result;
CHARSET_INFO *cs= collation.collation; CHARSET_INFO *cs= collation.collation;
......
...@@ -654,8 +654,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) ...@@ -654,8 +654,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
return TRUE; return TRUE;
// 'item' can be changed during fix_fields // 'item' can be changed during fix_fields
if (!item->fixed && if ((!item->fixed && item->fix_fields(thd, args)) ||
item->fix_fields(thd, args) ||
(item= args[0])->check_cols(1)) (item= args[0])->check_cols(1))
return TRUE; return TRUE;
decimals=item->decimals; decimals=item->decimals;
...@@ -981,8 +980,8 @@ void Item_sum_distinct::fix_length_and_dec() ...@@ -981,8 +980,8 @@ void Item_sum_distinct::fix_length_and_dec()
integers each <= 2^32. integers each <= 2^32.
*/ */
if (table_field_type == MYSQL_TYPE_INT24 || if (table_field_type == MYSQL_TYPE_INT24 ||
table_field_type >= MYSQL_TYPE_TINY && (table_field_type >= MYSQL_TYPE_TINY &&
table_field_type <= MYSQL_TYPE_LONG) table_field_type <= MYSQL_TYPE_LONG))
{ {
val.traits= Hybrid_type_traits_fast_decimal::instance(); val.traits= Hybrid_type_traits_fast_decimal::instance();
break; break;
......
...@@ -2680,7 +2680,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, ...@@ -2680,7 +2680,7 @@ void Query_log_event::print_query_header(IO_CACHE* file,
if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db) if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
{ {
if (different_db= memcmp(print_event_info->db, db, db_len + 1)) if ((different_db= memcmp(print_event_info->db, db, db_len + 1)))
memcpy(print_event_info->db, db, db_len + 1); memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db) if (db[0] && different_db)
my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter); my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
......
...@@ -117,11 +117,11 @@ struct MBR ...@@ -117,11 +117,11 @@ struct MBR
{ {
/* The following should be safe, even if we compare doubles */ /* The following should be safe, even if we compare doubles */
return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) &&
((mbr->ymin >= ymin) && (mbr->ymin <= ymax) || (((mbr->ymin >= ymin) && (mbr->ymin <= ymax)) ||
(mbr->ymax >= ymin) && (mbr->ymax <= ymax))) || ((mbr->ymax >= ymin) && (mbr->ymax <= ymax)))) ||
(((mbr->ymin == ymax) || (mbr->ymax == ymin)) && (((mbr->ymin == ymax) || (mbr->ymax == ymin)) &&
((mbr->xmin >= xmin) && (mbr->xmin <= xmax) || (((mbr->xmin >= xmin) && (mbr->xmin <= xmax)) ||
(mbr->xmax >= xmin) && (mbr->xmax <= xmax)))); ((mbr->xmax >= xmin) && (mbr->xmax <= xmax)))));
} }
int within(const MBR *mbr) int within(const MBR *mbr)
......
...@@ -2002,7 +2002,7 @@ void st_select_lex::print_limit(THD *thd, ...@@ -2002,7 +2002,7 @@ void st_select_lex::print_limit(THD *thd,
item->substype() == Item_subselect::ALL_SUBS)) item->substype() == Item_subselect::ALL_SUBS))
{ {
DBUG_ASSERT(!item->fixed || DBUG_ASSERT(!item->fixed ||
select_limit->val_int() == LL(1) && offset_limit == 0); (select_limit->val_int() == LL(1) && offset_limit == 0));
return; return;
} }
......
...@@ -1363,7 +1363,7 @@ struct TABLE_LIST ...@@ -1363,7 +1363,7 @@ struct TABLE_LIST
void cleanup_items(); void cleanup_items();
bool placeholder() bool placeholder()
{ {
return derived || view || schema_table || create && !table->db_stat || return derived || view || schema_table || (create && !table->db_stat) ||
!table; !table;
} }
void print(THD *thd, String *str, enum_query_type query_type); void print(THD *thd, String *str, enum_query_type query_type);
......
...@@ -2828,7 +2828,7 @@ int ha_federated::info(uint flag) ...@@ -2828,7 +2828,7 @@ int ha_federated::info(uint flag)
if (!(row= mysql_fetch_row(result))) if (!(row= mysql_fetch_row(result)))
goto error; goto error;
if (flag & HA_STATUS_VARIABLE | HA_STATUS_CONST) if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST))
{ {
/* /*
deleted is set in ha_federated::info deleted is set in ha_federated::info
......
...@@ -91,7 +91,7 @@ const char **ha_heap::bas_ext() const ...@@ -91,7 +91,7 @@ const char **ha_heap::bas_ext() const
int ha_heap::open(const char *name, int mode, uint test_if_locked) int ha_heap::open(const char *name, int mode, uint test_if_locked)
{ {
if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) || if ((test_if_locked & HA_OPEN_INTERNAL_TABLE) ||
!(file= heap_open(name, mode)) && my_errno == ENOENT) (!(file= heap_open(name, mode)) && my_errno == ENOENT))
{ {
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
internal_table= test(test_if_locked & HA_OPEN_INTERNAL_TABLE); internal_table= test(test_if_locked & HA_OPEN_INTERNAL_TABLE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment