Skip to content

Commit

Permalink
MDEV-6650 - LINT_INIT emits code in non-debug builds
Browse files Browse the repository at this point in the history
Replaced all references to LINT_INIT with UNINIT_VAR and LINT_INIT_STRUCT.
Removed LINT_INIT macro.
  • Loading branch information
Sergey Vojtovich committed Mar 16, 2015
1 parent 10554ca commit 18e9c31
Show file tree
Hide file tree
Showing 59 changed files with 87 additions and 214 deletions.
4 changes: 2 additions & 2 deletions BUILD/SETUP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ fi
# Set flags for various build configurations.
# Used in -valgrind builds
# Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro
# LINT_INIT(), which is only useful for silencing spurious warnings
# of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind.
# UNINIT_VAR(), which is only useful for silencing spurious warnings
# of static analysis tools. We want UNINIT_VAR() to be a no-op in Valgrind.
valgrind_flags="-DHAVE_valgrind -USAFEMALLOC"
valgrind_flags="$valgrind_flags -UFORCE_INIT_OF_VARS -Wno-uninitialized"
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
Expand Down
12 changes: 4 additions & 8 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3040,9 +3040,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
init_pager();
char last_char= 0;

int num_name= 0, num_cat= 0;
LINT_INIT(num_name);
LINT_INIT(num_cat);
int UNINIT_VAR(num_name), UNINIT_VAR(num_cat);

if (num_fields == 2)
{
Expand Down Expand Up @@ -3179,7 +3177,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
}

/* Remove garbage for nicer messages */
LINT_INIT(buff[0]);
LINT_INIT_STRUCT(buff[0]);
remove_cntrl(*buffer);

if (buffer->is_empty())
Expand Down Expand Up @@ -4698,8 +4696,7 @@ com_status(String *buffer __attribute__((unused)),
const char *status_str;
char buff[40];
ulonglong id;
MYSQL_RES *result;
LINT_INIT(result);
MYSQL_RES *UNINIT_VAR(result);

if (mysql_real_query_for_lazy(
C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
Expand Down Expand Up @@ -5258,8 +5255,7 @@ static void init_username()
my_free(full_username);
my_free(part_username);

MYSQL_RES *result;
LINT_INIT(result);
MYSQL_RES *UNINIT_VAR(result);
if (!mysql_query(&mysql,"select USER()") &&
(result=mysql_use_result(&mysql)))
{
Expand Down
6 changes: 2 additions & 4 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2617,12 +2617,11 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
{
char *end = (char*)((query_end && *query_end) ?
*query_end : query + strlen(query));
MYSQL_RES *res;
MYSQL_RES *UNINIT_VAR(res);
MYSQL_ROW row;
MYSQL* mysql = cur_con->mysql;
DYNAMIC_STRING ds_query;
DBUG_ENTER("var_query_set");
LINT_INIT(res);

if (!mysql)
{
Expand Down Expand Up @@ -2801,7 +2800,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
{
long row_no;
int col_no= -1;
MYSQL_RES* res;
MYSQL_RES* UNINIT_VAR(res);
MYSQL* mysql= cur_con->mysql;

static DYNAMIC_STRING ds_query;
Expand All @@ -2814,7 +2813,6 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
};

DBUG_ENTER("var_set_query_get_value");
LINT_INIT(res);

if (!mysql)
{
Expand Down
3 changes: 1 addition & 2 deletions client/readline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
char *batch_readline(LINE_BUFFER *line_buff, bool binary_mode)
{
char *pos;
ulong out_length;
LINT_INIT(out_length);
ulong UNINIT_VAR(out_length);

if (!(pos=intern_read_line(line_buff, &out_length)))
return 0;
Expand Down
13 changes: 0 additions & 13 deletions include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,19 +457,6 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define STDERR_FILENO 2
#endif

/*
Deprecated workaround for false-positive uninitialized variables
warnings. Those should be silenced using tool-specific heuristics.
Enabled by default for g++ due to the bug referenced below.
*/
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
(defined(__GNUC__) && defined(__cplusplus))
#define LINT_INIT(var) var= 0
#else
#define LINT_INIT(var)
#endif

#ifndef SO_EXT
#ifdef _WIN32
#define SO_EXT ".dll"
Expand Down
3 changes: 1 addition & 2 deletions libmysql/libmysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,11 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
MYSQL_RES * STDCALL
mysql_list_processes(MYSQL *mysql)
{
MYSQL_DATA *fields;
MYSQL_DATA *UNINIT_VAR(fields);
uint field_count;
uchar *pos;
DBUG_ENTER("mysql_list_processes");

LINT_INIT(fields);
if (simple_command(mysql,COM_PROCESS_INFO,0,0,0))
DBUG_RETURN(0);
free_old_query(mysql);
Expand Down
3 changes: 1 addition & 2 deletions mysys/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,11 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp)

void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack)
{
uchar** fp;
uchar** UNINIT_VAR(fp);
uint frame_count = 0, sigreturn_frame_count;
#if defined(__alpha__) && defined(__GNUC__)
uint32* pc;
#endif
LINT_INIT(fp);


#ifdef __i386__
Expand Down
2 changes: 0 additions & 2 deletions plugin/semisync/semisync_master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,6 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id,
ulong trc_level = trace_level_;
LINT_INIT_STRUCT(start_ts);

LINT_INIT_STRUCT(start_ts);

function_enter(kWho);

assert((unsigned char)event_buf[1] == kPacketMagicNum);
Expand Down
3 changes: 1 addition & 2 deletions sql-common/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
uint port, const char *unix_socket,ulong client_flag)
{
char buff[NAME_LEN+USERNAME_LENGTH+100];
int scramble_data_len, pkt_scramble_len= 0;
int scramble_data_len, UNINIT_VAR(pkt_scramble_len);
char *end,*host_info= 0, *server_version_end, *pkt_end;
char *scramble_data;
const char *scramble_plugin;
Expand All @@ -3224,7 +3224,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
struct sockaddr_un UNIXaddr;
#endif
DBUG_ENTER("mysql_real_connect");
LINT_INIT(pkt_scramble_len);

DBUG_PRINT("enter",("host: %s db: %s user: %s (client)",
host ? host : "(Null)",
Expand Down
3 changes: 1 addition & 2 deletions sql/create_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,8 @@ engine_option_value *merge_engine_table_options(engine_option_value *first,
engine_option_value *second,
MEM_ROOT *root)
{
engine_option_value *end, *opt;
engine_option_value *UNINIT_VAR(end), *opt;
DBUG_ENTER("merge_engine_table_options");
LINT_INIT(end);

/* Create copy of first list */
for (opt= first, first= 0; opt; opt= opt->next)
Expand Down
3 changes: 1 addition & 2 deletions sql/debug_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)

if (action->execute)
{
const char *old_proc_info;
LINT_INIT(old_proc_info);
const char *UNINIT_VAR(old_proc_info);

action->execute--;

Expand Down
4 changes: 1 addition & 3 deletions sql/derror.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ bool read_texts(const char *file_name, const char *language,
File file;
char name[FN_REFLEN];
char lang_path[FN_REFLEN];
uchar *buff;
uchar *UNINIT_VAR(buff);
uchar head[32],*pos;
DBUG_ENTER("read_texts");

*point= 0;

LINT_INIT(buff);
funktpos=0;
convert_dirname(lang_path, language, NullS);
(void) my_load_path(lang_path, lang_path, lc_messages_dir);
Expand Down
4 changes: 1 addition & 3 deletions sql/event_db_repository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table,
CHARSET_INFO *scs= system_charset_info;
KEY *key_info;
uint key_len;
uchar *key_buf= NULL;
LINT_INIT(key_buf);

uchar *key_buf;
DBUG_ENTER("Event_db_repository::index_read_for_db_for_i_s");

DBUG_PRINT("info", ("Using prefix scanning on PK"));
Expand Down
3 changes: 1 addition & 2 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5418,8 +5418,7 @@ int handler::index_read_idx_map(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
int error, error1;
LINT_INIT(error1);
int error, UNINIT_VAR(error1);

error= ha_index_init(index, 0);
if (!error)
Expand Down
3 changes: 1 addition & 2 deletions sql/item_cmpfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,7 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item,
my_bitmap_map *old_maps[2];
ulonglong UNINIT_VAR(orig_field_val); /* original field value if valid */

LINT_INIT(old_maps[0]);
LINT_INIT(old_maps[1]);
LINT_INIT_STRUCT(old_maps);

/* table->read_set may not be set if we come here from a CREATE TABLE */
if (table && table->read_set)
Expand Down
9 changes: 3 additions & 6 deletions sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,7 @@ String *Item_func_ltrim::val_str(String *str)
char buff[MAX_FIELD_WIDTH], *ptr, *end;
String tmp(buff,sizeof(buff),system_charset_info);
String *res, *remove_str;
uint remove_length;
LINT_INIT(remove_length);
uint UNINIT_VAR(remove_length);

res= args[0]->val_str(str);
if ((null_value=args[0]->null_value))
Expand Down Expand Up @@ -1994,8 +1993,7 @@ String *Item_func_rtrim::val_str(String *str)
char buff[MAX_FIELD_WIDTH], *ptr, *end;
String tmp(buff, sizeof(buff), system_charset_info);
String *res, *remove_str;
uint remove_length;
LINT_INIT(remove_length);
uint UNINIT_VAR(remove_length);

res= args[0]->val_str(str);
if ((null_value=args[0]->null_value))
Expand Down Expand Up @@ -2075,8 +2073,7 @@ String *Item_func_trim::val_str(String *str)
const char *r_ptr;
String tmp(buff, sizeof(buff), system_charset_info);
String *res, *remove_str;
uint remove_length;
LINT_INIT(remove_length);
uint UNINIT_VAR(remove_length);

res= args[0]->val_str(str);
if ((null_value=args[0]->null_value))
Expand Down
18 changes: 5 additions & 13 deletions sql/key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,8 @@ int key_tuple_cmp(KEY_PART_INFO *part, uchar *key1, uchar *key2,
uint tuple_length)
{
uchar *key1_end= key1 + tuple_length;
int len;
int UNINIT_VAR(len);
int res;
LINT_INIT(len);
for (;key1 < key1_end; key1 += len, key2 += len, part++)
{
len= part->store_length;
Expand Down Expand Up @@ -709,12 +708,9 @@ ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key)
for (; key_part < end_key_part; key_part++)
{
uchar *pos= (uchar*)key;
CHARSET_INFO *cs;
uint length, pack_length;
CHARSET_INFO *UNINIT_VAR(cs);
uint UNINIT_VAR(length), UNINIT_VAR(pack_length);
bool is_string= TRUE;
LINT_INIT(cs);
LINT_INIT(length);
LINT_INIT(pack_length);

key+= key_part->length;
if (key_part->null_bit)
Expand Down Expand Up @@ -816,13 +812,9 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
{
uchar *pos1= (uchar*)key1;
uchar *pos2= (uchar*)key2;
CHARSET_INFO *cs;
uint length1, length2, pack_length;
CHARSET_INFO *UNINIT_VAR(cs);
uint UNINIT_VAR(length1), UNINIT_VAR(length2), UNINIT_VAR(pack_length);
bool is_string= TRUE;
LINT_INIT(cs);
LINT_INIT(length1);
LINT_INIT(length2);
LINT_INIT(pack_length);

key1+= key_part->length;
key2+= key_part->length;
Expand Down
18 changes: 6 additions & 12 deletions sql/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1502,8 +1502,7 @@ bool LOGGER::activate_log_handler(THD* thd, uint log_type)
void LOGGER::deactivate_log_handler(THD *thd, uint log_type)
{
my_bool *tmp_opt= 0;
MYSQL_LOG *file_log;
LINT_INIT(file_log);
MYSQL_LOG *UNINIT_VAR(file_log);

switch (log_type) {
case QUERY_LOG_SLOW:
Expand Down Expand Up @@ -4878,8 +4877,7 @@ int MYSQL_BIN_LOG::new_file_impl(bool need_lock)
char new_name[FN_REFLEN], *new_name_ptr, *old_name, *file_to_open;
uint close_flag;
bool delay_close= false;
File old_file;
LINT_INIT(old_file);
File UNINIT_VAR(old_file);

DBUG_ENTER("MYSQL_BIN_LOG::new_file_impl");
if (!is_open())
Expand Down Expand Up @@ -5873,9 +5871,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
bool is_trans_cache= FALSE;
bool using_trans= event_info->use_trans_cache();
bool direct= event_info->use_direct_logging();
ulong prev_binlog_id;
ulong UNINIT_VAR(prev_binlog_id);
DBUG_ENTER("MYSQL_BIN_LOG::write(Log_event *)");
LINT_INIT(prev_binlog_id);

if (thd->variables.option_bits & OPTION_GTID_BEGIN)
{
Expand Down Expand Up @@ -7316,10 +7313,9 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
group_commit_entry *current, *last_in_queue;
group_commit_entry *queue= NULL;
bool check_purge= false;
ulong binlog_id;
ulong UNINIT_VAR(binlog_id);
uint64 commit_id;
DBUG_ENTER("MYSQL_BIN_LOG::trx_group_commit_leader");
LINT_INIT(binlog_id);

{
DBUG_EXECUTE_IF("inject_binlog_commit_before_get_LOCK_log",
Expand Down Expand Up @@ -8297,8 +8293,7 @@ int TC_LOG_MMAP::log_and_order(THD *thd, my_xid xid, bool all,
{
int cookie;
struct commit_entry entry;
bool is_group_commit_leader;
LINT_INIT(is_group_commit_leader);
bool UNINIT_VAR(is_group_commit_leader);

if (need_prepare_ordered)
{
Expand Down Expand Up @@ -9794,8 +9789,7 @@ binlog_checksum_update(MYSQL_THD thd, struct st_mysql_sys_var *var,
{
ulong value= *((ulong *)save);
bool check_purge= false;
ulong prev_binlog_id;
LINT_INIT(prev_binlog_id);
ulong UNINIT_VAR(prev_binlog_id);

mysql_mutex_lock(mysql_bin_log.get_log_lock());
if(mysql_bin_log.is_open())
Expand Down
9 changes: 3 additions & 6 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7063,8 +7063,7 @@ bool Intvar_log_event::write(IO_CACHE* file)
void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
char llbuff[22];
const char *msg;
LINT_INIT(msg);
const char *UNINIT_VAR(msg);
Write_on_release_cache cache(&print_event_info->head_cache, file,
Write_on_release_cache::FLUSH_F);

Expand Down Expand Up @@ -11709,14 +11708,12 @@ static bool record_compare(TABLE *table)
int Rows_log_event::find_key()
{
uint i, best_key_nr, last_part;
KEY *key, *best_key;
ulong best_rec_per_key, tmp;
KEY *key, *UNINIT_VAR(best_key);
ulong UNINIT_VAR(best_rec_per_key), tmp;
DBUG_ENTER("Rows_log_event::find_key");
DBUG_ASSERT(m_table);

best_key_nr= MAX_KEY;
LINT_INIT(best_key);
LINT_INIT(best_rec_per_key);

/*
Keys are sorted so that any primary key is first, followed by unique keys,
Expand Down
Loading

0 comments on commit 18e9c31

Please sign in to comment.