Skip to content
Permalink
Browse files
Fix most clang-15 -Wunused-but-set-variable
Also, refactor trx_i_s_common_fill_table() to remove dead code.

Warnings about yynerrs in Bison-generated yyparse() will remain for now.
  • Loading branch information
dr-m committed Jul 1, 2022
1 parent 6dc1bc3 commit 045771c
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 189 deletions.
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2021, MariaDB Corporation.
Copyright (c) 2009, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3591,7 +3591,6 @@ print_table_data(MYSQL_RES *result)
{
String separator(256);
MYSQL_ROW cur;
MYSQL_FIELD *field;
bool *num_flag;

num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
@@ -3603,7 +3602,7 @@ print_table_data(MYSQL_RES *result)
mysql_field_seek(result,0);
}
separator.copy("+",1,charset_info);
while ((field = mysql_fetch_field(result)))
while (MYSQL_FIELD *field= mysql_fetch_field(result))
{
uint length= column_names ? field->name_length : 0;
if (quick)
@@ -3625,7 +3624,7 @@ print_table_data(MYSQL_RES *result)
{
mysql_field_seek(result,0);
(void) tee_fputs("|", PAGER);
for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
while (MYSQL_FIELD *field= mysql_fetch_field(result))
{
size_t name_length= (uint) strlen(field->name);
size_t numcells= charset_info->cset->numcells(charset_info,
@@ -3668,7 +3667,7 @@ print_table_data(MYSQL_RES *result)
data_length= (uint) lengths[off];
}

field= mysql_fetch_field(result);
MYSQL_FIELD *field= mysql_fetch_field(result);
field_max_length= field->max_length;

/*
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB
Copyright (c) 2010, 2012, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1006,7 +1006,6 @@ static void print_result()
char prev[(NAME_LEN+9)*3+2];
char prev_alter[MAX_ALTER_STR_SIZE];
size_t length_of_db= strlen(sock->db);
uint i;
my_bool found_error=0, table_rebuild=0;
DYNAMIC_ARRAY *array4repair= &tables4repair;
DBUG_ENTER("print_result");
@@ -1015,7 +1014,7 @@ static void print_result()

prev[0] = '\0';
prev_alter[0]= 0;
for (i = 0; (row = mysql_fetch_row(res)); i++)
while ((row = mysql_fetch_row(res)))
{
int changed = strcmp(prev, row[0]);
my_bool status = !strcmp(row[2], "status");
@@ -1,6 +1,6 @@
/*
Copyright (c) 2005, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB
Copyright (c) 2010, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1846,12 +1846,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)

pthread_handler_t run_task(void *p)
{
ulonglong counter= 0, queries;
ulonglong queries;
ulonglong detach_counter;
unsigned int commit_counter;
MYSQL *mysql;
MYSQL_RES *result;
MYSQL_ROW row;
statement *ptr;
thread_context *con= (thread_context *)p;

@@ -1972,8 +1971,7 @@ pthread_handler_t run_task(void *p)
my_progname, mysql_errno(mysql), mysql_error(mysql));
else
{
while ((row= mysql_fetch_row(result)))
counter++;
while (mysql_fetch_row(result)) {}
mysql_free_result(result);
}
}
@@ -1983,7 +1981,7 @@ pthread_handler_t run_task(void *p)
if (commit_rate && (++commit_counter == commit_rate))
{
commit_counter= 0;
run_query(mysql, "COMMIT", strlen("COMMIT"));
run_query(mysql, C_STRING_WITH_LEN("COMMIT"));
}

if (con->limit && queries == con->limit)
@@ -1995,7 +1993,7 @@ pthread_handler_t run_task(void *p)

end:
if (commit_rate)
run_query(mysql, "COMMIT", strlen("COMMIT"));
run_query(mysql, C_STRING_WITH_LEN("COMMIT"));

mysql_close(mysql);

@@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates.
Copyright (c) 2012, 2014, Monty Program Ab
Copyright (c) 2012, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -77,7 +77,6 @@ char *fgets_fn(char *buffer, size_t size, fgets_input_t input, int *error)
static void print_query(FILE *out, const char *query)
{
const char *ptr= query;
int column= 0;

fprintf(out, "\"");
while (*ptr)
@@ -90,21 +89,18 @@ static void print_query(FILE *out, const char *query)
and wrap to the next line, tabulated.
*/
fprintf(out, "\\n\"\n \"");
column= 2;
break;
case '\r':
/* Skipped */
break;
case '\"':
fprintf(out, "\\\"");
column++;
break;
case '\\':
fprintf(out, "\\\\");
break;
default:
putc(*ptr, out);
column++;
break;
}
ptr++;
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2008, 2021, MariaDB
Copyright (c) 2008, 2022, MariaDB

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -9990,7 +9990,7 @@ int Field_bit::cmp_prefix(const uchar *a, const uchar *b, size_t prefix_len)
}


int Field_bit::key_cmp(const uchar *str, uint length)
int Field_bit::key_cmp(const uchar *str, uint)
{
if (bit_len)
{
@@ -9999,7 +9999,6 @@ int Field_bit::key_cmp(const uchar *str, uint length)
if ((flag= (int) (bits - *str)))
return flag;
str++;
length--;
}
return memcmp(ptr, str, bytes_in_rec);
}
@@ -2353,7 +2353,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
char *name_buffer_ptr;
const char *from_path;
const char *to_path= NULL;
uint i;
handler **file, **abort_file;
DBUG_ENTER("ha_partition::del_ren_table");

@@ -2382,7 +2381,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
from_path= get_canonical_filename(*file, from, from_lc_buff);
if (to != NULL)
to_path= get_canonical_filename(*file, to, to_lc_buff);
i= 0;
do
{
if (unlikely((error= create_partition_name(from_buff, sizeof(from_buff),
@@ -2407,7 +2405,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
name_buffer_ptr= strend(name_buffer_ptr) + 1;
if (unlikely(error))
save_error= error;
i++;
} while (*(++file));
if (to != NULL)
{
@@ -1,5 +1,5 @@
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB Corporation.
Copyright (c) 2010, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1583,7 +1583,6 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
uchar **char_ptrs;
unsigned i;
size_t size;
uint tot_fields= 0;
uint tot_part_fields= 0;
uint tot_subpart_fields= 0;
DBUG_ENTER("set_up_charset_field_preps");
@@ -1595,13 +1594,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
ptr= part_field_array;
/* Set up arrays and buffers for those fields */
while ((field= *(ptr++)))
{
if (field_is_partition_charset(field))
{
tot_part_fields++;
tot_fields++;
}
}
size= tot_part_fields * sizeof(char*);
if (!(char_ptrs= (uchar**)thd->calloc(size)))
goto error;
@@ -1635,13 +1629,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
/* Set up arrays and buffers for those fields */
ptr= subpart_field_array;
while ((field= *(ptr++)))
{
if (field_is_partition_charset(field))
{
tot_subpart_fields++;
tot_fields++;
}
}
size= tot_subpart_fields * sizeof(char*);
if (!(char_ptrs= (uchar**) thd->calloc(size)))
goto error;
@@ -2191,7 +2191,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
Lex_ident_cli_st *str)
{
CHARSET_INFO *const cs= thd->charset();
uint double_quotes= 0;
uchar c, quote_char= m_tok_start[0];
DBUG_ASSERT(m_ptr == m_tok_start + 1);

@@ -2216,7 +2215,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
if (yyPeek() != quote_char)
break;
c= yyGet();
double_quotes++;
continue;
}
}
@@ -1,5 +1,5 @@
/* Copyright (C) 2009 MySQL AB
Copyright (c) 2019, 2020, MariaDB Corporation.
Copyright (c) 2019, 2022, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2483,7 +2483,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
{
int rc= 0;
KEY *key_info= &table->key_info[index];
ha_rows rows= 0;

DBUG_ENTER("collect_statistics_for_index");

@@ -2518,7 +2517,6 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)

if (rc)
break;
rows++;
index_prefix_calc.add();
rc= table->file->ha_index_next(table->record[0]);
}
@@ -3633,7 +3633,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,

List_iterator<Key> key_iterator(alter_info->key_list);
List_iterator<Key> key_iterator2(alter_info->key_list);
uint key_parts=0, fk_key_count=0;
uint key_parts=0;
bool primary_key=0,unique_key=0;
Key *key, *key2;
uint tmp, key_number;
@@ -3649,7 +3649,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
"(none)" , key->type));
if (key->type == Key::FOREIGN_KEY)
{
fk_key_count++;
Foreign_key *fk_key= (Foreign_key*) key;
if (fk_key->validate(alter_info->create_list))
DBUG_RETURN(TRUE);
@@ -301,15 +301,13 @@ PageBulk::finish()
#endif

ulint count = 0;
ulint n_recs = 0;
ulint slot_index = 0;
rec_t* insert_rec = page_rec_get_next(page_get_infimum_rec(m_page));
page_dir_slot_t* slot = NULL;

/* Set owner & dir. */
while (!page_rec_is_supremum(insert_rec)) {
count++;
n_recs++;

if (count == (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2) {

0 comments on commit 045771c

Please sign in to comment.