Commit b050354f authored by Sergei Golubchik's avatar Sergei Golubchik

compiler warnings

parent f299da89
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Common warning flags for GCC, G++, Clang and Clang++ # Common warning flags for GCC, G++, Clang and Clang++
SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security") SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self")
MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang
IF(HAVE_WVLA) IF(HAVE_WVLA)
SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla")
......
...@@ -1426,7 +1426,7 @@ void my_print_help(const struct my_option *options) ...@@ -1426,7 +1426,7 @@ void my_print_help(const struct my_option *options)
if (typelib_help && if (typelib_help &&
strstr(optp->comment, optp->typelib->type_names[0]) == NULL) strstr(optp->comment, optp->typelib->type_names[0]) == NULL)
{ {
int i; uint i;
col= print_comment(typelib_help, col, name_space, comment_space); col= print_comment(typelib_help, col, name_space, comment_space);
col= print_comment(optp->typelib->type_names[0], col, name_space, comment_space); col= print_comment(optp->typelib->type_names[0], col, name_space, comment_space);
for (i= 1; i < count; i++) for (i= 1; i < count; i++)
......
...@@ -2462,7 +2462,7 @@ void Item_func_between::print(String *str, enum_query_type query_type) ...@@ -2462,7 +2462,7 @@ void Item_func_between::print(String *str, enum_query_type query_type)
void void
Item_func_case_abbreviation2::fix_length_and_dec(Item **args) Item_func_case_abbreviation2::fix_length_and_dec2(Item **args)
{ {
uint32 char_length; uint32 char_length;
agg_result_type(&cached_result_type, args, 2); agg_result_type(&cached_result_type, args, 2);
...@@ -2505,7 +2505,7 @@ Item_func_case_abbreviation2::fix_length_and_dec(Item **args) ...@@ -2505,7 +2505,7 @@ Item_func_case_abbreviation2::fix_length_and_dec(Item **args)
uint Item_func_case_abbreviation2::decimal_precision(Item **args) const uint Item_func_case_abbreviation2::decimal_precision2(Item **args) const
{ {
int arg0_int_part= args[0]->decimal_int_part(); int arg0_int_part= args[0]->decimal_int_part();
int arg1_int_part= args[1]->decimal_int_part(); int arg1_int_part= args[1]->decimal_int_part();
...@@ -2692,7 +2692,7 @@ Item_func_if::fix_length_and_dec() ...@@ -2692,7 +2692,7 @@ Item_func_if::fix_length_and_dec()
maybe_null= true; maybe_null= true;
return; return;
} }
Item_func_case_abbreviation2::fix_length_and_dec(args + 1); Item_func_case_abbreviation2::fix_length_and_dec2(args + 1);
} }
......
...@@ -765,8 +765,8 @@ class Item_func_case_abbreviation2 :public Item_func_hybrid_field_type ...@@ -765,8 +765,8 @@ class Item_func_case_abbreviation2 :public Item_func_hybrid_field_type
:Item_func_hybrid_field_type(a, b) { } :Item_func_hybrid_field_type(a, b) { }
Item_func_case_abbreviation2(Item *a, Item *b, Item *c) Item_func_case_abbreviation2(Item *a, Item *b, Item *c)
:Item_func_hybrid_field_type(a, b, c) { } :Item_func_hybrid_field_type(a, b, c) { }
void fix_length_and_dec(Item **args); void fix_length_and_dec2(Item **args);
uint decimal_precision(Item **args) const; uint decimal_precision2(Item **args) const;
}; };
...@@ -781,7 +781,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2 ...@@ -781,7 +781,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2
bool date_op(MYSQL_TIME *ltime,uint fuzzydate); bool date_op(MYSQL_TIME *ltime,uint fuzzydate);
void fix_length_and_dec() void fix_length_and_dec()
{ {
Item_func_case_abbreviation2::fix_length_and_dec(args); Item_func_case_abbreviation2::fix_length_and_dec2(args);
maybe_null= args[1]->maybe_null; maybe_null= args[1]->maybe_null;
} }
const char *func_name() const { return "ifnull"; } const char *func_name() const { return "ifnull"; }
...@@ -789,7 +789,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2 ...@@ -789,7 +789,7 @@ class Item_func_ifnull :public Item_func_case_abbreviation2
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
uint decimal_precision() const uint decimal_precision() const
{ {
return Item_func_case_abbreviation2::decimal_precision(args); return Item_func_case_abbreviation2::decimal_precision2(args);
} }
}; };
...@@ -809,7 +809,7 @@ class Item_func_if :public Item_func_case_abbreviation2 ...@@ -809,7 +809,7 @@ class Item_func_if :public Item_func_case_abbreviation2
void fix_length_and_dec(); void fix_length_and_dec();
uint decimal_precision() const uint decimal_precision() const
{ {
return Item_func_case_abbreviation2::decimal_precision(args + 1); return Item_func_case_abbreviation2::decimal_precision2(args + 1);
} }
const char *func_name() const { return "if"; } const char *func_name() const { return "if"; }
bool eval_not_null_tables(uchar *opt_arg); bool eval_not_null_tables(uchar *opt_arg);
......
...@@ -460,8 +460,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -460,8 +460,7 @@ static ssize_t sst_prepare_other (const char* method,
const char* addr_in, const char* addr_in,
const char** addr_out) const char** addr_out)
{ {
ssize_t cmd_len= 1024; char cmd_str[1024];
char cmd_str[cmd_len];
const char* sst_dir= mysql_real_data_home; const char* sst_dir= mysql_real_data_home;
const char* binlog_opt= ""; const char* binlog_opt= "";
char* binlog_opt_val= NULL; char* binlog_opt_val= NULL;
...@@ -477,7 +476,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -477,7 +476,7 @@ static ssize_t sst_prepare_other (const char* method,
make_wsrep_defaults_file(); make_wsrep_defaults_file();
ret= snprintf (cmd_str, cmd_len, ret= snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_%s " "wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'joiner' " WSREP_SST_OPT_ROLE" 'joiner' "
WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_ADDR" '%s' "
...@@ -491,7 +490,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -491,7 +490,7 @@ static ssize_t sst_prepare_other (const char* method,
binlog_opt, binlog_opt_val); binlog_opt, binlog_opt_val);
my_free(binlog_opt_val); my_free(binlog_opt_val);
if (ret < 0 || ret >= cmd_len) if (ret < 0 || ret >= (int)sizeof(cmd_str))
{ {
WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret); WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE); return (ret < 0 ? ret : -EMSGSIZE);
...@@ -742,7 +741,7 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -742,7 +741,7 @@ static int sst_donate_mysqldump (const char* addr,
host_len = strlen (addr) + 1; host_len = strlen (addr) + 1;
} }
char host[host_len]; char *host=(char*)alloca(host_len);
strncpy (host, addr, host_len - 1); strncpy (host, addr, host_len - 1);
host[host_len - 1] = '\0'; host[host_len - 1] = '\0';
...@@ -762,7 +761,7 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -762,7 +761,7 @@ static int sst_donate_mysqldump (const char* addr,
user_len = (auth) ? strlen (auth) + 1 : 1; user_len = (auth) ? strlen (auth) + 1 : 1;
} }
char user[user_len]; char *user=(char*)alloca(user_len);
strncpy (user, (auth) ? auth : "", user_len - 1); strncpy (user, (auth) ? auth : "", user_len - 1);
user[user_len - 1] = '\0'; user[user_len - 1] = '\0';
...@@ -770,14 +769,13 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -770,14 +769,13 @@ static int sst_donate_mysqldump (const char* addr,
int ret = sst_mysqldump_check_addr (user, pswd, host, port); int ret = sst_mysqldump_check_addr (user, pswd, host, port);
if (!ret) if (!ret)
{ {
size_t cmd_len= 1024; char cmd_str[1024];
char cmd_str[cmd_len];
if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE); if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE);
make_wsrep_defaults_file(); make_wsrep_defaults_file();
snprintf (cmd_str, cmd_len, snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_mysqldump " "wsrep_sst_mysqldump "
WSREP_SST_OPT_USER" '%s' " WSREP_SST_OPT_USER" '%s' "
WSREP_SST_OPT_PSWD" '%s' " WSREP_SST_OPT_PSWD" '%s' "
...@@ -874,9 +872,9 @@ static int sst_flush_tables(THD* thd) ...@@ -874,9 +872,9 @@ static int sst_flush_tables(THD* thd)
WSREP_INFO("Tables flushed."); WSREP_INFO("Tables flushed.");
const char base_name[]= "tables_flushed"; const char base_name[]= "tables_flushed";
ssize_t const full_len= strlen(mysql_real_data_home) + strlen(base_name)+2; ssize_t const full_len= strlen(mysql_real_data_home) + strlen(base_name)+2;
char real_name[full_len]; char *real_name=(char*)alloca(full_len);
sprintf(real_name, "%s/%s", mysql_real_data_home, base_name); sprintf(real_name, "%s/%s", mysql_real_data_home, base_name);
char tmp_name[full_len + 4]; char *tmp_name=(char*)alloca(full_len + 4);
sprintf(tmp_name, "%s.tmp", real_name); sprintf(tmp_name, "%s.tmp", real_name);
FILE* file= fopen(tmp_name, "w+"); FILE* file= fopen(tmp_name, "w+");
...@@ -1037,8 +1035,7 @@ static int sst_donate_other (const char* method, ...@@ -1037,8 +1035,7 @@ static int sst_donate_other (const char* method,
wsrep_seqno_t seqno, wsrep_seqno_t seqno,
bool bypass) bool bypass)
{ {
ssize_t cmd_len = 4096; char cmd_str[4096];
char cmd_str[cmd_len];
const char* binlog_opt= ""; const char* binlog_opt= "";
char* binlog_opt_val= NULL; char* binlog_opt_val= NULL;
...@@ -1052,7 +1049,7 @@ static int sst_donate_other (const char* method, ...@@ -1052,7 +1049,7 @@ static int sst_donate_other (const char* method,
make_wsrep_defaults_file(); make_wsrep_defaults_file();
ret= snprintf (cmd_str, cmd_len, ret= snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_%s " "wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'donor' " WSREP_SST_OPT_ROLE" 'donor' "
WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_ADDR" '%s' "
...@@ -1070,7 +1067,7 @@ static int sst_donate_other (const char* method, ...@@ -1070,7 +1067,7 @@ static int sst_donate_other (const char* method,
bypass ? " "WSREP_SST_OPT_BYPASS : ""); bypass ? " "WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val); my_free(binlog_opt_val);
if (ret < 0 || ret >= cmd_len) if (ret < 0 || ret >= (int)sizeof(cmd_str))
{ {
WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret); WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE); return (ret < 0 ? ret : -EMSGSIZE);
......
...@@ -23,6 +23,7 @@ New index creation routines using a merge sort ...@@ -23,6 +23,7 @@ New index creation routines using a merge sort
Created 12/4/2005 Jan Lindstrom Created 12/4/2005 Jan Lindstrom
Completed by Sunny Bains and Marko Makela Completed by Sunny Bains and Marko Makela
*******************************************************/ *******************************************************/
#include <my_config.h>
#include <log.h> #include <log.h>
#include "row0merge.h" #include "row0merge.h"
......
...@@ -39,11 +39,10 @@ static wsrep_log_cb_t logger = default_logger; ...@@ -39,11 +39,10 @@ static wsrep_log_cb_t logger = default_logger;
static int verify(const wsrep_t *wh, const char *iface_ver) static int verify(const wsrep_t *wh, const char *iface_ver)
{ {
const size_t msg_len = 128; char msg[128];
char msg[msg_len];
#define VERIFY(_p) if (!(_p)) { \ #define VERIFY(_p) if (!(_p)) { \
snprintf(msg, msg_len, "wsrep_load(): verify(): %s\n", # _p); \ snprintf(msg, sizeof(msg), "wsrep_load(): verify(): %s\n", # _p); \
logger (WSREP_LOG_ERROR, msg); \ logger (WSREP_LOG_ERROR, msg); \
return EINVAL; \ return EINVAL; \
} }
...@@ -52,7 +51,7 @@ static int verify(const wsrep_t *wh, const char *iface_ver) ...@@ -52,7 +51,7 @@ static int verify(const wsrep_t *wh, const char *iface_ver)
VERIFY(wh->version); VERIFY(wh->version);
if (strcmp(wh->version, iface_ver)) { if (strcmp(wh->version, iface_ver)) {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg),
"provider interface version mismatch: need '%s', found '%s'", "provider interface version mismatch: need '%s', found '%s'",
iface_ver, wh->version); iface_ver, wh->version);
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
...@@ -115,9 +114,8 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -115,9 +114,8 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
int ret = 0; int ret = 0;
void *dlh = NULL; void *dlh = NULL;
wsrep_loader_fun dlfun; wsrep_loader_fun dlfun;
const size_t msg_len = 1024; char msg[1025];
char msg[msg_len + 1]; msg[sizeof(msg)-1] = 0;
msg[msg_len] = 0;
if (NULL != log_cb) if (NULL != log_cb)
logger = log_cb; logger = log_cb;
...@@ -125,7 +123,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -125,7 +123,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
if (!(spec && hptr)) if (!(spec && hptr))
return EINVAL; return EINVAL;
snprintf (msg, msg_len, snprintf (msg, sizeof(msg)-1,
"wsrep_load(): loading provider library '%s'", spec); "wsrep_load(): loading provider library '%s'", spec);
logger (WSREP_LOG_INFO, msg); logger (WSREP_LOG_INFO, msg);
...@@ -143,7 +141,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -143,7 +141,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
} }
if (!(dlh = dlopen(spec, RTLD_NOW | RTLD_LOCAL))) { if (!(dlh = dlopen(spec, RTLD_NOW | RTLD_LOCAL))) {
snprintf(msg, msg_len, "wsrep_load(): dlopen(): %s", dlerror()); snprintf(msg, sizeof(msg)-1, "wsrep_load(): dlopen(): %s", dlerror());
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
ret = EINVAL; ret = EINVAL;
goto out; goto out;
...@@ -155,14 +153,14 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -155,14 +153,14 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
} }
if ((ret = (*dlfun)(*hptr)) != 0) { if ((ret = (*dlfun)(*hptr)) != 0) {
snprintf(msg, msg_len, "wsrep_load(): loader failed: %s", snprintf(msg, sizeof(msg)-1, "wsrep_load(): loader failed: %s",
strerror(ret)); strerror(ret));
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
goto out; goto out;
} }
if ((ret = verify(*hptr, WSREP_INTERFACE_VERSION)) != 0) { if ((ret = verify(*hptr, WSREP_INTERFACE_VERSION)) != 0) {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg)-1,
"wsrep_load(): interface version mismatch: my version %s, " "wsrep_load(): interface version mismatch: my version %s, "
"provider version %s", WSREP_INTERFACE_VERSION, "provider version %s", WSREP_INTERFACE_VERSION,
(*hptr)->version); (*hptr)->version);
...@@ -178,7 +176,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -178,7 +176,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
free(*hptr); free(*hptr);
*hptr = NULL; *hptr = NULL;
} else { } else {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg)-1,
"wsrep_load(): %s %s by %s loaded successfully.", "wsrep_load(): %s %s by %s loaded successfully.",
(*hptr)->provider_name, (*hptr)->provider_version, (*hptr)->provider_name, (*hptr)->provider_version,
(*hptr)->provider_vendor); (*hptr)->provider_vendor);
......
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