Skip to content

Commit ef9cdac

Browse files
MDEV-33220 Fix -wmaybe-uninitialized warnings for g++-13
1 parent 2250b42 commit ef9cdac

File tree

7 files changed

+72
-88
lines changed

7 files changed

+72
-88
lines changed

sql/item_strfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ String *Item_func_regexp_replace::val_str_internal(String *str,
13831383
char buff2[MAX_FIELD_WIDTH];
13841384
String tmp0(buff0,sizeof(buff0),&my_charset_bin);
13851385
String tmp2(buff2,sizeof(buff2),&my_charset_bin);
1386-
String *source, *replace;
1386+
String *source, *replace= 0;
13871387
LEX_CSTRING src, rpl;
13881388
int startoffset= 0;
13891389

@@ -1584,7 +1584,7 @@ String *Item_str_conv::val_str(String *str)
15841584
{
15851585
DBUG_ASSERT(fixed == 1);
15861586
String *res;
1587-
size_t alloced_length, len;
1587+
size_t alloced_length= 0, len;
15881588

15891589
if ((null_value= (!(res= args[0]->val_str(&tmp_value)) ||
15901590
str->alloc((alloced_length= res->length() * multiply)))))

sql/mysqld.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6390,7 +6390,7 @@ void create_new_thread(CONNECT *connect)
63906390
void handle_accepted_socket(MYSQL_SOCKET new_sock, MYSQL_SOCKET sock)
63916391
{
63926392
CONNECT *connect;
6393-
bool is_unix_sock;
6393+
bool is_unix_sock= false;
63946394

63956395
#ifdef FD_CLOEXEC
63966396
(void) fcntl(mysql_socket_getfd(new_sock), F_SETFD, FD_CLOEXEC);

storage/spider/ha_spider.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,23 @@ int ha_spider::open(
509509
result_list.last = NULL;
510510
result_list.current = NULL;
511511
result_list.record_num = 0;
512-
if (
513-
!(result_list.sqls = new spider_string[share->link_count]) ||
514-
!(result_list.insert_sqls = new spider_string[share->link_count]) ||
515-
!(result_list.update_sqls = new spider_string[share->link_count]) ||
516-
!(result_list.tmp_sqls = new spider_string[share->link_count])
517-
) {
512+
if (!(result_list.sqls = new spider_string[share->link_count]))
513+
{
514+
error_num = HA_ERR_OUT_OF_MEM;
515+
goto error_init_result_list;
516+
}
517+
if (!(result_list.insert_sqls = new spider_string[share->link_count]))
518+
{
519+
error_num = HA_ERR_OUT_OF_MEM;
520+
goto error_init_result_list;
521+
}
522+
if (!(result_list.update_sqls = new spider_string[share->link_count]))
523+
{
524+
error_num = HA_ERR_OUT_OF_MEM;
525+
goto error_init_result_list;
526+
}
527+
if (!(result_list.tmp_sqls = new spider_string[share->link_count]))
528+
{
518529
error_num = HA_ERR_OUT_OF_MEM;
519530
goto error_init_result_list;
520531
}

storage/spider/hs_client/config.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,22 @@ config::operator =(const config& x)
228228
conf_param *param, *new_param;
229229
for(ulong i = 0; i < x.conf_hash.records; i++)
230230
{
231-
if (
232-
(param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)) &&
233-
(new_param = new conf_param())
234-
) {
235-
if (
236-
!new_param->key.copy(param->key) &&
237-
!new_param->val.copy(param->val)
238-
) {
239-
new_param->key.c_ptr_safe();
240-
new_param->val.c_ptr_safe();
241-
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
242-
new_param->key.ptr(), new_param->val.ptr()));
243-
if (my_hash_insert(&conf_hash, (uchar*) new_param))
231+
if ((param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)))
232+
if ((new_param = new conf_param()))
233+
{
234+
if (
235+
!new_param->key.copy(param->key) &&
236+
!new_param->val.copy(param->val)
237+
) {
238+
new_param->key.c_ptr_safe();
239+
new_param->val.c_ptr_safe();
240+
DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n",
241+
new_param->key.ptr(), new_param->val.ptr()));
242+
if (my_hash_insert(&conf_hash, (uchar*) new_param))
243+
delete new_param;
244+
} else
244245
delete new_param;
245-
} else
246-
delete new_param;
247-
}
246+
}
248247
}
249248
}
250249
DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this));

storage/spider/spd_copy_tables.cc

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,12 @@ long long spider_copy_tables_body(
10021002
all_link_cnt =
10031003
copy_tables->link_idx_count[0] + copy_tables->link_idx_count[1];
10041004
if (
1005-
!(tmp_sql = new spider_string[all_link_cnt]) ||
1005+
!(tmp_sql = new spider_string[all_link_cnt])
1006+
) {
1007+
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
1008+
goto error;
1009+
}
1010+
if (
10061011
!(spider = new ha_spider[all_link_cnt])
10071012
) {
10081013
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
@@ -1029,13 +1034,6 @@ long long spider_copy_tables_body(
10291034
}
10301035
tmp_spider->share = table_conn->share;
10311036
tmp_spider->trx = copy_tables->trx;
1032-
/*
1033-
if (spider_db_append_set_names(table_conn->share))
1034-
{
1035-
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
1036-
goto error_append_set_names;
1037-
}
1038-
*/
10391037
tmp_spider->conns = &table_conn->conn;
10401038
tmp_sql[roop_count].init_calc_mem(SPD_MID_COPY_TABLES_BODY_3);
10411039
tmp_sql[roop_count].set_charset(copy_tables->access_charset);
@@ -1073,13 +1071,6 @@ long long spider_copy_tables_body(
10731071
}
10741072
tmp_spider->share = table_conn->share;
10751073
tmp_spider->trx = copy_tables->trx;
1076-
/*
1077-
if (spider_db_append_set_names(table_conn->share))
1078-
{
1079-
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
1080-
goto error_append_set_names;
1081-
}
1082-
*/
10831074
tmp_spider->conns = &table_conn->conn;
10841075
tmp_sql[roop_count].init_calc_mem(SPD_MID_COPY_TABLES_BODY_5);
10851076
tmp_sql[roop_count].set_charset(copy_tables->access_charset);
@@ -1106,14 +1097,6 @@ long long spider_copy_tables_body(
11061097
bulk_insert_rows)))
11071098
goto error_db_udf_copy_tables;
11081099

1109-
/*
1110-
for (table_conn = copy_tables->table_conn[0];
1111-
table_conn; table_conn = table_conn->next)
1112-
spider_db_free_set_names(table_conn->share);
1113-
for (table_conn = copy_tables->table_conn[1];
1114-
table_conn; table_conn = table_conn->next)
1115-
spider_db_free_set_names(table_conn->share);
1116-
*/
11171100
if (table_list->table)
11181101
{
11191102
#if MYSQL_VERSION_ID < 50500
@@ -1138,26 +1121,14 @@ long long spider_copy_tables_body(
11381121
}
11391122
delete [] spider;
11401123
}
1141-
if (tmp_sql)
1142-
delete [] tmp_sql;
1124+
delete [] tmp_sql;
11431125
spider_udf_free_copy_tables_alloc(copy_tables);
11441126

11451127
DBUG_RETURN(1);
11461128

11471129
error_db_udf_copy_tables:
11481130
error_create_dbton_handler:
11491131
error_init_dbton_handler:
1150-
/*
1151-
error_append_set_names:
1152-
*/
1153-
/*
1154-
for (table_conn = copy_tables->table_conn[0];
1155-
table_conn; table_conn = table_conn->next)
1156-
spider_db_free_set_names(table_conn->share);
1157-
for (table_conn = copy_tables->table_conn[1];
1158-
table_conn; table_conn = table_conn->next)
1159-
spider_db_free_set_names(table_conn->share);
1160-
*/
11611132
error:
11621133
if (spider)
11631134
{

storage/spider/spd_db_mysql.cc

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7218,24 +7218,22 @@ int spider_mbase_share::init()
72187218
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
72197219
}
72207220

7221-
if (keys > 0 &&
7222-
!(key_hint = new spider_string[keys])
7223-
) {
7224-
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
7225-
}
7221+
if (keys > 0)
7222+
if (!(key_hint = new spider_string[keys]))
7223+
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
72267224
for (roop_count = 0; roop_count < keys; roop_count++)
72277225
{
72287226
key_hint[roop_count].init_calc_mem(SPD_MID_MBASE_SHARE_INIT_2);
72297227
key_hint[roop_count].set_charset(spider_share->access_charset);
72307228
}
72317229
DBUG_PRINT("info",("spider key_hint=%p", key_hint));
72327230

7233-
if (
7234-
!(table_select = new spider_string[1]) ||
7235-
(keys > 0 &&
7236-
!(key_select = new spider_string[keys])
7237-
) ||
7238-
(error_num = create_table_names_str()) ||
7231+
if (!(table_select = new spider_string[1]))
7232+
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
7233+
if (keys > 0)
7234+
if (!(key_select = new spider_string[keys]))
7235+
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
7236+
if ((error_num = create_table_names_str()) ||
72397237
(table_share &&
72407238
(
72417239
(error_num = create_column_name_str()) ||
@@ -7386,11 +7384,18 @@ int spider_mbase_share::create_table_names_str()
73867384
table_names_str = NULL;
73877385
db_names_str = NULL;
73887386
db_table_str = NULL;
7389-
if (
7390-
!(table_names_str = new spider_string[spider_share->all_link_count]) ||
7391-
!(db_names_str = new spider_string[spider_share->all_link_count]) ||
7392-
!(db_table_str = new spider_string[spider_share->all_link_count])
7393-
) {
7387+
if (!(table_names_str = new spider_string[spider_share->all_link_count]))
7388+
{
7389+
error_num = HA_ERR_OUT_OF_MEM;
7390+
goto error;
7391+
}
7392+
if (!(db_names_str = new spider_string[spider_share->all_link_count]))
7393+
{
7394+
error_num = HA_ERR_OUT_OF_MEM;
7395+
goto error;
7396+
}
7397+
if (!(db_table_str = new spider_string[spider_share->all_link_count]))
7398+
{
73947399
error_num = HA_ERR_OUT_OF_MEM;
73957400
goto error;
73967401
}
@@ -7541,11 +7546,9 @@ int spider_mbase_share::create_column_name_str()
75417546
Field **field;
75427547
TABLE_SHARE *table_share = spider_share->table_share;
75437548
DBUG_ENTER("spider_mbase_share::create_column_name_str");
7544-
if (
7545-
table_share->fields &&
7546-
!(column_name_str = new spider_string[table_share->fields])
7547-
)
7548-
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
7549+
if (table_share->fields)
7550+
if (!(column_name_str = new spider_string[table_share->fields]))
7551+
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
75497552
for (field = table_share->field, str = column_name_str;
75507553
*field; field++, str++)
75517554
{

storage/spider/spd_table.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,12 +4217,12 @@ SPIDER_SHARE *spider_create_share(
42174217
share->table.read_set = &table_share->all_set;
42184218
#endif
42194219

4220-
if (table_share->keys > 0 &&
4221-
!(share->key_hint = new spider_string[table_share->keys])
4222-
) {
4223-
*error_num = HA_ERR_OUT_OF_MEM;
4224-
goto error_init_hint_string;
4225-
}
4220+
if (table_share->keys > 0)
4221+
if (!(share->key_hint = new spider_string[table_share->keys]))
4222+
{
4223+
*error_num = HA_ERR_OUT_OF_MEM;
4224+
goto error_init_hint_string;
4225+
}
42264226
for (roop_count = 0; roop_count < (int) table_share->keys; roop_count++)
42274227
share->key_hint[roop_count].init_calc_mem(SPD_MID_CREATE_SHARE_2);
42284228
DBUG_PRINT("info",("spider share->key_hint=%p", share->key_hint));

0 commit comments

Comments
 (0)