Re: [Maria-developers] Compiler warning about assigned but not used variables fixed
![](https://secure.gravatar.com/avatar/3c2329333dd5898f2e72818af773243d.jpg?s=120&d=mm&r=g)
Hi, Sanja! On Oct 17, sanja@askmonty.org wrote:
message: Compiler warning about assigned but not used variables fixed.
Pretty much ok. But please change ifdef's to __attribute__((unused)), as discussed. And see below about the commented out code, looks like you forgot to fix or uncomment it.
=== modified file 'client/mysqltest.cc' --- a/client/mysqltest.cc 2011-05-28 02:11:32 +0000 +++ b/client/mysqltest.cc 2011-10-17 19:38:32 +0000 @@ -5238,7 +5238,10 @@ void do_connect(struct st_command *comma int con_port= opt_port; char *con_options; my_bool con_ssl= 0, con_compress= 0; - my_bool con_pipe= 0, con_shm= 0; + my_bool con_pipe= 0; +#ifdef HAVE_SMEM + my_bool con_shm= 0; +#endif
try not to overuse #ifdef's, (*) prefer __attribute__((unused)) instead. it is less error-prone and results in a more maintainable and readable code.
struct st_connection* con_slot;
static DYNAMIC_STRING ds_connection_name; === modified file 'mysys/ma_dyncol.c' --- a/mysys/ma_dyncol.c 2011-09-22 09:04:00 +0000 +++ b/mysys/ma_dyncol.c 2011-10-17 19:38:32 +0000 @@ -1916,16 +1915,18 @@ dynamic_column_update_many(DYNAMIC_COLUM }
/* if (new_offset_size != offset_size) then we have to rewrite header */ + /* + Now we only copy. TODO: fix + header_delta_sign= new_offset_size - offset_size; data_delta_sign= 0; - copy= FALSE; for (i= 0; i < add_column_count; i++) { - /* This is the check for increasing/decreasing */ + // This is the check for increasing/decreasing DELTA_CHECK(header_delta_sign, plan[i].hdelta, copy); DELTA_CHECK(data_delta_sign, plan[i].ddelta, copy); } - + */
why did you comment this out?
calc_param(&new_entry_size, &new_header_size, new_offset_size, new_column_count);
=== modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2011-10-11 10:55:42 +0000 +++ b/sql/sql_show.cc 2011-10-17 19:38:32 +0000 @@ -1274,7 +1274,9 @@ int store_create_info(THD *thd, TABLE_LI handler *file= table->file; TABLE_SHARE *share= table->s; HA_CREATE_INFO create_info; +#ifdef WITH_PARTITION_STORAGE_ENGINE bool show_table_options= FALSE; +#endif
same here, and below.
bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL | MODE_ORACLE | MODE_MSSQL | @@ -1507,7 +1509,9 @@ int store_create_info(THD *thd, TABLE_LI packet->append(STRING_WITH_LEN("\n)")); if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode) { +#ifdef WITH_PARTITION_STORAGE_ENGINE show_table_options= TRUE; +#endif /* Get possible table space definitions and append them to the CREATE TABLE statement
=== modified file 'sql/table.cc' --- a/sql/table.cc 2011-09-02 12:10:10 +0000 +++ b/sql/table.cc 2011-10-17 19:38:32 +0000 @@ -5689,7 +5689,8 @@ int update_virtual_fields(THD *thd, TABL { DBUG_ENTER("update_virtual_fields"); Field **vfield_ptr, *vfield; - int error= 0; + int error __attribute__ ((unused)); + error= 0;
FYI, you can still use initializer and __attribute__ together: int error __attribute__ ((unused)) = 0; there is no need to change the above, either way is ok.
if (!table || !table->vfield) DBUG_RETURN(0);
=== modified file 'storage/xtradb/buf/buf0buf.c' --- a/storage/xtradb/buf/buf0buf.c 2011-05-10 15:17:43 +0000 +++ b/storage/xtradb/buf/buf0buf.c 2011-10-17 19:38:32 +0000 @@ -3895,7 +3895,7 @@ buf_page_io_complete( enum buf_io_fix io_type; const ibool uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); - enum buf_flush flush_type; + //enum buf_flush flush_type;
please send all your XtraDB changes to Percona
mutex_t* block_mutex;
Regards, Sergei (*) see for example http://www.google.com/search?q=ifdef+considered+harmful
![](https://secure.gravatar.com/avatar/6b1cecb6596aaa9fe497d5bd2bb2f5c1.jpg?s=120&d=mm&r=g)
-----Original Message----- From: maria-developers- bounces+wlad=montyprogram.com@lists.launchpad.net [mailto:maria- developers-bounces+wlad=montyprogram.com@lists.launchpad.net] On Behalf Of Sergei Golubchik Sent: Dienstag, 18. Oktober 2011 10:15 To: maria-developers@lists.launchpad.net Subject: Re: [Maria-developers] Compiler warning about assigned but not used variables fixed
try not to overuse #ifdef's, (*) prefer __attribute__((unused)) instead.
it is less error-prone and results in a more maintainable and readable code.
This really depends on what you're used:) With anything but gcc, __attribute__((unused)) is a lengthy zero-effect macro. I did not find double-underscore macros really readable, but it must be just me.
![](https://secure.gravatar.com/avatar/3c2329333dd5898f2e72818af773243d.jpg?s=120&d=mm&r=g)
Hi, Vladislav! On Oct 18, Vladislav Vaintroub wrote:
-----Original Message----- From: maria-developers- bounces+wlad=montyprogram.com@lists.launchpad.net [mailto:maria- developers-bounces+wlad=montyprogram.com@lists.launchpad.net] On Behalf Of Sergei Golubchik Sent: Dienstag, 18. Oktober 2011 10:15 To: maria-developers@lists.launchpad.net Subject: Re: [Maria-developers] Compiler warning about assigned but not used variables fixed
try not to overuse #ifdef's, (*) prefer __attribute__((unused)) instead.
it is less error-prone and results in a more maintainable and readable code.
This really depends on what you're used:) With anything but gcc, __attribute__((unused)) is a lengthy zero-effect macro. I did not find double-underscore macros really readable, but it must be just me.
That's not what I meant :) They aren't exactly readable, but one can ignore them when reading the code. As for the ifdef, there are two readability issues: 1. It interrupts the normal code flow by using constructs with a zero indentation. function if loop another if whatever whoops. full stop. matrix reloaded. continue at where we've stopped. tell your brain to load the saved context. 2. when reading ifdefs one needs to consider the ifdef condition, and keep it in mind, matching different code lines to each other . o O (hmm.. ifdef'ed block. will it be enabled together with the ifdef'ed definition two screens above? Or was it a different ifdef condition?.. Oh, that one is a subset of this one. Damn!..) Regards, Sergei
participants (2)
-
Sergei Golubchik
-
Vladislav Vaintroub