Skip to content

Commit 8b98434

Browse files
author
Staale Smedseng
committed
Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2 Cleaning up warnings not present in 5.0.
1 parent 613297f commit 8b98434

30 files changed

+75
-76
lines changed

client/mysql.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3561,7 +3561,7 @@ static void print_warnings()
35613561
messages. To be safe, skip printing the duplicate only if it is the only
35623562
warning.
35633563
*/
3564-
if (!cur || num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10))
3564+
if (!cur || (num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10)))
35653565
goto end;
35663566

35673567
/* Print the warnings */

client/mysqlslap.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
423423
stats *sptr;
424424
conclusions conclusion;
425425
unsigned long long client_limit;
426+
int sysret;
426427

427428
head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
428429
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
@@ -463,7 +464,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
463464
run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
464465

465466
if (pre_system)
466-
system(pre_system);
467+
if ((sysret= system(pre_system)) != 0)
468+
fprintf(stderr, "Warning: Execution of pre_system option returned %d.\n",
469+
sysret);
467470

468471
/*
469472
Pre statements are always run after all other logic so they can
@@ -478,7 +481,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
478481
run_statements(mysql, post_statements);
479482

480483
if (post_system)
481-
system(post_system);
484+
if ((sysret= system(post_system)) != 0)
485+
fprintf(stderr, "Warning: Execution of post_system option returned %d.\n",
486+
sysret);
482487

483488
/* We are finished with this run */
484489
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)

cmd-line-utils/readline/display.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ rl_redisplay ()
465465
int newlines, lpos, temp, modmark;
466466
const char *prompt_this_line;
467467
#if defined (HANDLE_MULTIBYTE)
468-
int num, n0;
468+
int num, n0= 0;
469469
wchar_t wc;
470470
size_t wc_bytes;
471-
int wc_width;
471+
int wc_width= 0;
472472
mbstate_t ps;
473473
int _rl_wrapped_multicolumn = 0;
474474
#endif
@@ -828,7 +828,7 @@ rl_redisplay ()
828828
cpos_buffer_position = out;
829829
lb_linenum = newlines;
830830
}
831-
for (i = in; i < in+wc_bytes; i++)
831+
for (i = in; i < in+(int)wc_bytes; i++)
832832
line[out++] = rl_line_buffer[i];
833833
for (i = 0; i < wc_width; i++)
834834
CHECK_LPOS();

extra/yassl/include/yassl_int.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class SSL_CTX {
441441
const Ciphers& GetCiphers() const;
442442
const DH_Parms& GetDH_Parms() const;
443443
const Stats& GetStats() const;
444-
const VerifyCallback getVerifyCallback() const;
444+
VerifyCallback getVerifyCallback() const;
445445
pem_password_cb GetPasswordCb() const;
446446
void* GetUserData() const;
447447
bool GetSessionCacheOff() const;

extra/yassl/src/yassl_int.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ SSL_CTX::GetCA_List() const
18331833
}
18341834

18351835

1836-
const VerifyCallback SSL_CTX::getVerifyCallback() const
1836+
VerifyCallback SSL_CTX::getVerifyCallback() const
18371837
{
18381838
return verifyCallback_;
18391839
}

include/my_dbug.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ extern FILE *_db_fp_(void);
137137
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
138138
#define DBUG_PRINT(keyword,arglist) do { } while(0)
139139
#define DBUG_PUSH(a1)
140-
#define DBUG_SET(a1)
141-
#define DBUG_SET_INITIAL(a1)
140+
#define DBUG_SET(a1) do { } while(0)
141+
#define DBUG_SET_INITIAL(a1) do { } while(0)
142142
#define DBUG_POP()
143143
#define DBUG_PROCESS(a1)
144144
#define DBUG_SETJMP(a1) setjmp(a1)
145145
#define DBUG_LONGJMP(a1) longjmp(a1)
146-
#define DBUG_DUMP(keyword,a1,a2)
146+
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
147147
#define DBUG_END()
148148
#define DBUG_ASSERT(A) do { } while(0)
149149
#define DBUG_LOCK_FILE

sql/event_db_repository.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
711711
DBUG_ENTER("Event_db_repository::update_event");
712712

713713
/* None or both must be set */
714-
DBUG_ASSERT(new_dbname && new_name || new_dbname == new_name);
714+
DBUG_ASSERT((new_dbname && new_name) || new_dbname == new_name);
715715

716716
/* Reset sql_mode during data dictionary operations. */
717717
thd->variables.sql_mode= 0;

sql/ha_partition.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type,
10011001

10021002
if (!thd->vio_ok())
10031003
{
1004-
sql_print_error(msgbuf);
1004+
sql_print_error("%s", msgbuf);
10051005
return TRUE;
10061006
}
10071007

sql/ha_partition.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,10 @@ class ha_partition :public handler
773773
if (m_handler_status < handler_initialized ||
774774
m_handler_status >= handler_closed)
775775
DBUG_RETURN(PARTITION_ENABLED_TABLE_FLAGS);
776-
else
777-
DBUG_RETURN((m_file[0]->ha_table_flags() &
778-
~(PARTITION_DISABLED_TABLE_FLAGS)) |
779-
(PARTITION_ENABLED_TABLE_FLAGS));
776+
777+
DBUG_RETURN((m_file[0]->ha_table_flags() &
778+
~(PARTITION_DISABLED_TABLE_FLAGS)) |
779+
(PARTITION_ENABLED_TABLE_FLAGS));
780780
}
781781

782782
/*

sql/handler.cc

+4-8
Original file line numberDiff line numberDiff line change
@@ -3501,14 +3501,10 @@ int handler::index_next_same(uchar *buf, const uchar *key, uint keylen)
35013501
if (!(error=index_next(buf)))
35023502
{
35033503
my_ptrdiff_t ptrdiff= buf - table->record[0];
3504-
uchar *save_record_0;
3505-
KEY *key_info;
3506-
KEY_PART_INFO *key_part;
3507-
KEY_PART_INFO *key_part_end;
3508-
LINT_INIT(save_record_0);
3509-
LINT_INIT(key_info);
3510-
LINT_INIT(key_part);
3511-
LINT_INIT(key_part_end);
3504+
uchar *UNINIT_VAR(save_record_0);
3505+
KEY *UNINIT_VAR(key_info);
3506+
KEY_PART_INFO *UNINIT_VAR(key_part);
3507+
KEY_PART_INFO *UNINIT_VAR(key_part_end);
35123508

35133509
/*
35143510
key_cmp_if_same() compares table->record[0] against 'key'.

sql/item_timefunc.cc

+3-7
Original file line numberDiff line numberDiff line change
@@ -1344,15 +1344,11 @@ bool get_interval_value(Item *args,interval_type int_type,
13441344
String *str_value, INTERVAL *interval)
13451345
{
13461346
ulonglong array[5];
1347-
longlong value;
1348-
const char *str;
1349-
size_t length;
1347+
longlong UNINIT_VAR(value);
1348+
const char *UNINIT_VAR(str);
1349+
size_t UNINIT_VAR(length);
13501350
CHARSET_INFO *cs=str_value->charset();
13511351

1352-
LINT_INIT(value);
1353-
LINT_INIT(str);
1354-
LINT_INIT(length);
1355-
13561352
bzero((char*) interval,sizeof(*interval));
13571353
if ((int) int_type <= INTERVAL_MICROSECOND)
13581354
{

sql/item_xmlfunc.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ my_xpath_lex_scan(MY_XPATH *xpath,
13541354
MY_XPATH_LEX *lex, const char *beg, const char *end)
13551355
{
13561356
int ch, ctype, length;
1357-
for ( ; beg < end && *beg == ' ' ; beg++); // skip leading spaces
1357+
for ( ; beg < end && *beg == ' ' ; beg++) ; // skip leading spaces
13581358
lex->beg= beg;
13591359

13601360
if (beg >= end)
@@ -1423,15 +1423,15 @@ my_xpath_lex_scan(MY_XPATH *xpath,
14231423

14241424
if (my_xdigit(ch)) // a sequence of digits
14251425
{
1426-
for ( ; beg < end && my_xdigit(*beg) ; beg++);
1426+
for ( ; beg < end && my_xdigit(*beg) ; beg++) ;
14271427
lex->end= beg;
14281428
lex->term= MY_XPATH_LEX_DIGITS;
14291429
return;
14301430
}
14311431

14321432
if (ch == '"' || ch == '\'') // a string: either '...' or "..."
14331433
{
1434-
for ( ; beg < end && *beg != ch ; beg++);
1434+
for ( ; beg < end && *beg != ch ; beg++) ;
14351435
if (beg < end)
14361436
{
14371437
lex->end= beg+1;

sql/log_event_old.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,8 @@ Old_rows_log_event::Old_rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
12451245
solution, to be able to terminate a started statement in the
12461246
binary log: the extraneous events will be removed in the future.
12471247
*/
1248-
DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ~0UL ||
1249-
!tbl_arg && !cols && tid == ~0UL);
1248+
DBUG_ASSERT((tbl_arg && tbl_arg->s && tid != ~0UL) ||
1249+
(!tbl_arg && !cols && tid == ~0UL));
12501250

12511251
if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS)
12521252
set_flags(NO_FOREIGN_KEY_CHECKS_F);
@@ -1409,7 +1409,7 @@ int Old_rows_log_event::do_add_row_data(uchar *row_data, size_t length)
14091409
#endif
14101410

14111411
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
1412-
DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end);
1412+
DBUG_ASSERT(!m_rows_buf || (m_rows_end && m_rows_buf < m_rows_end));
14131413
DBUG_ASSERT(m_rows_cur <= m_rows_end);
14141414

14151415
/* The cast will always work since m_rows_cur <= m_rows_end */

sql/mysqld.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3719,6 +3719,7 @@ static void end_ssl()
37193719

37203720
static int init_server_components()
37213721
{
3722+
FILE* reopen;
37223723
DBUG_ENTER("init_server_components");
37233724
/*
37243725
We need to call each of these following functions to ensure that
@@ -3761,7 +3762,7 @@ static int init_server_components()
37613762
if (freopen(log_error_file, "a+", stdout))
37623763
#endif
37633764
{
3764-
freopen(log_error_file, "a+", stderr);
3765+
reopen= freopen(log_error_file, "a+", stderr);
37653766
setbuf(stderr, NULL);
37663767
}
37673768
}

sql/partition_info.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,8 @@ static bool check_engine_condition(partition_element *p_elem,
483483
{
484484
DBUG_RETURN(TRUE);
485485
}
486-
else
487-
{
488-
DBUG_RETURN(FALSE);
489-
}
486+
487+
DBUG_RETURN(FALSE);
490488
}
491489

492490

sql/rpl_rli.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ Relay_log_info::Relay_log_info()
3333
:Slave_reporting_capability("SQL"),
3434
no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id),
3535
info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
36+
cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
3637
#if HAVE_purify
3738
is_fake(FALSE),
3839
#endif
39-
cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
4040
group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
4141
last_master_timestamp(0), slave_skip_counter(0),
4242
abort_pos_wait(0), slave_run_id(0), sql_thd(0),
@@ -300,7 +300,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
300300
DBUG_RETURN(error);
301301

302302
err:
303-
sql_print_error(msg);
303+
sql_print_error("%s", msg);
304304
end_io_cache(&rli->info_file);
305305
if (info_fd >= 0)
306306
my_close(info_fd, MYF(0));

sql/set_var.cc

+6-3
Original file line numberDiff line numberDiff line change
@@ -3349,7 +3349,7 @@ int set_var_init()
33493349
uint count= 0;
33503350
DBUG_ENTER("set_var_init");
33513351

3352-
for (sys_var *var=vars.first; var; var= var->next, count++);
3352+
for (sys_var *var=vars.first; var; var= var->next, count++) ;
33533353

33543354
if (hash_init(&system_variable_hash, system_charset_info, count, 0,
33553355
0, (hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
@@ -4184,10 +4184,10 @@ bool sys_var_opt_readonly::update(THD *thd, set_var *var)
41844184
can cause to wait on a read lock, it's required for the client application
41854185
to unlock everything, and acceptable for the server to wait on all locks.
41864186
*/
4187-
if (result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE))
4187+
if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE)))
41884188
goto end_with_read_lock;
41894189

4190-
if (result= make_global_read_lock_block_commit(thd))
4190+
if ((result= make_global_read_lock_block_commit(thd)))
41914191
goto end_with_read_lock;
41924192

41934193
/* Change the opt_readonly system variable, safe because the lock is held */
@@ -4200,6 +4200,7 @@ bool sys_var_opt_readonly::update(THD *thd, set_var *var)
42004200
}
42014201

42024202

4203+
#ifndef DBUG_OFF
42034204
/* even session variable here requires SUPER, because of -#o,file */
42044205
bool sys_var_thd_dbug::check(THD *thd, set_var *var)
42054206
{
@@ -4226,6 +4227,8 @@ uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
42264227
DBUG_EXPLAIN(buf, sizeof(buf));
42274228
return (uchar*) thd->strdup(buf);
42284229
}
4230+
#endif /* DBUG_OFF */
4231+
42294232

42304233
#ifdef HAVE_EVENT_SCHEDULER
42314234
bool sys_var_event_scheduler::check(THD *thd, set_var *var)

sql/set_var.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ class sys_var_thd_bit :public sys_var_thd
621621
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
622622
};
623623

624+
#ifndef DBUG_OFF
624625
class sys_var_thd_dbug :public sys_var_thd
625626
{
626627
public:
@@ -634,7 +635,7 @@ class sys_var_thd_dbug :public sys_var_thd
634635
void set_default(THD *thd, enum_var_type type) { DBUG_POP(); }
635636
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
636637
};
637-
638+
#endif /* DBUG_OFF */
638639

639640

640641
/* some variables that require special handling */

sql/slave.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ when it try to get the value of TIME_ZONE global variable from master.";
11951195
if (master_res)
11961196
mysql_free_result(master_res);
11971197
DBUG_ASSERT(err_code != 0);
1198-
mi->report(ERROR_LEVEL, err_code, err_buff);
1198+
mi->report(ERROR_LEVEL, err_code, "%s", err_buff);
11991199
DBUG_RETURN(1);
12001200
}
12011201

@@ -2386,7 +2386,7 @@ static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info)
23862386
if (io_slave_killed(thd, mi))
23872387
{
23882388
if (info && global_system_variables.log_warnings)
2389-
sql_print_information(info);
2389+
sql_print_information("%s", info);
23902390
return TRUE;
23912391
}
23922392
return FALSE;
@@ -2456,13 +2456,13 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi,
24562456
}
24572457
else
24582458
{
2459-
sql_print_information(buf);
2459+
sql_print_information("%s", buf);
24602460
}
24612461
}
24622462
if (safe_reconnect(thd, mysql, mi, 1) || io_slave_killed(thd, mi))
24632463
{
24642464
if (global_system_variables.log_warnings)
2465-
sql_print_information(messages[SLAVE_RECON_MSG_KILLED_AFTER]);
2465+
sql_print_information("%s", messages[SLAVE_RECON_MSG_KILLED_AFTER]);
24662466
return 1;
24672467
}
24682468
return 0;
@@ -2679,7 +2679,7 @@ slave. If the entry is correct, restart the server with a higher value of \
26792679
max_allowed_packet",
26802680
thd->variables.max_allowed_packet);
26812681
mi->report(ERROR_LEVEL, ER_NET_PACKET_TOO_LARGE,
2682-
ER(ER_NET_PACKET_TOO_LARGE));
2682+
"%s", ER(ER_NET_PACKET_TOO_LARGE));
26832683
goto err;
26842684
case ER_MASTER_FATAL_ERROR_READING_BINLOG:
26852685
mi->report(ERROR_LEVEL, ER_MASTER_FATAL_ERROR_READING_BINLOG,
@@ -2690,7 +2690,7 @@ max_allowed_packet",
26902690
sql_print_error("\
26912691
Stopping slave I/O thread due to out-of-memory error from master");
26922692
mi->report(ERROR_LEVEL, ER_OUT_OF_RESOURCES,
2693-
ER(ER_OUT_OF_RESOURCES));
2693+
"%s", ER(ER_OUT_OF_RESOURCES));
26942694
goto err;
26952695
}
26962696
if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,
@@ -3050,7 +3050,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
30503050
This function is reporting an error which was not reported
30513051
while executing exec_relay_log_event().
30523052
*/
3053-
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg);
3053+
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), "%s", errmsg);
30543054
}
30553055
else if (last_errno != thd->main_da.sql_errno())
30563056
{

sql/sql_cache.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void debug_wait_for_kill(const char *info)
383383
thd= current_thd;
384384
prev_info= thd->proc_info;
385385
thd->proc_info= info;
386-
sql_print_information(info);
386+
sql_print_information("%s", info);
387387
while(!thd->killed)
388388
my_sleep(1000);
389389
thd->killed= THD::NOT_KILLED;

sql/sql_connect.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static void end_connection(THD *thd)
985985
if (thd->user_connect)
986986
decrease_user_connections(thd->user_connect);
987987

988-
if (thd->killed || net->error && net->vio != 0)
988+
if (thd->killed || (net->error && net->vio != 0))
989989
{
990990
statistic_increment(aborted_threads,&LOCK_status);
991991
}

0 commit comments

Comments
 (0)