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