Skip to content

Commit 045771c

Browse files
committed
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.
1 parent 6dc1bc3 commit 045771c

File tree

14 files changed

+98
-189
lines changed

14 files changed

+98
-189
lines changed

client/mysql.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
3-
Copyright (c) 2009, 2021, MariaDB Corporation.
3+
Copyright (c) 2009, 2022, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -3591,7 +3591,6 @@ print_table_data(MYSQL_RES *result)
35913591
{
35923592
String separator(256);
35933593
MYSQL_ROW cur;
3594-
MYSQL_FIELD *field;
35953594
bool *num_flag;
35963595

35973596
num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
@@ -3603,7 +3602,7 @@ print_table_data(MYSQL_RES *result)
36033602
mysql_field_seek(result,0);
36043603
}
36053604
separator.copy("+",1,charset_info);
3606-
while ((field = mysql_fetch_field(result)))
3605+
while (MYSQL_FIELD *field= mysql_fetch_field(result))
36073606
{
36083607
uint length= column_names ? field->name_length : 0;
36093608
if (quick)
@@ -3625,7 +3624,7 @@ print_table_data(MYSQL_RES *result)
36253624
{
36263625
mysql_field_seek(result,0);
36273626
(void) tee_fputs("|", PAGER);
3628-
for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
3627+
while (MYSQL_FIELD *field= mysql_fetch_field(result))
36293628
{
36303629
size_t name_length= (uint) strlen(field->name);
36313630
size_t numcells= charset_info->cset->numcells(charset_info,
@@ -3668,7 +3667,7 @@ print_table_data(MYSQL_RES *result)
36683667
data_length= (uint) lengths[off];
36693668
}
36703669

3671-
field= mysql_fetch_field(result);
3670+
MYSQL_FIELD *field= mysql_fetch_field(result);
36723671
field_max_length= field->max_length;
36733672

36743673
/*

client/mysqlcheck.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2017, MariaDB
3+
Copyright (c) 2010, 2012, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -1006,7 +1006,6 @@ static void print_result()
10061006
char prev[(NAME_LEN+9)*3+2];
10071007
char prev_alter[MAX_ALTER_STR_SIZE];
10081008
size_t length_of_db= strlen(sock->db);
1009-
uint i;
10101009
my_bool found_error=0, table_rebuild=0;
10111010
DYNAMIC_ARRAY *array4repair= &tables4repair;
10121011
DBUG_ENTER("print_result");
@@ -1015,7 +1014,7 @@ static void print_result()
10151014

10161015
prev[0] = '\0';
10171016
prev_alter[0]= 0;
1018-
for (i = 0; (row = mysql_fetch_row(res)); i++)
1017+
while ((row = mysql_fetch_row(res)))
10191018
{
10201019
int changed = strcmp(prev, row[0]);
10211020
my_bool status = !strcmp(row[2], "status");

client/mysqlslap.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2005, 2015, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2017, MariaDB
3+
Copyright (c) 2010, 2022, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
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)
18461846

18471847
pthread_handler_t run_task(void *p)
18481848
{
1849-
ulonglong counter= 0, queries;
1849+
ulonglong queries;
18501850
ulonglong detach_counter;
18511851
unsigned int commit_counter;
18521852
MYSQL *mysql;
18531853
MYSQL_RES *result;
1854-
MYSQL_ROW row;
18551854
statement *ptr;
18561855
thread_context *con= (thread_context *)p;
18571856

@@ -1972,8 +1971,7 @@ pthread_handler_t run_task(void *p)
19721971
my_progname, mysql_errno(mysql), mysql_error(mysql));
19731972
else
19741973
{
1975-
while ((row= mysql_fetch_row(result)))
1976-
counter++;
1974+
while (mysql_fetch_row(result)) {}
19771975
mysql_free_result(result);
19781976
}
19791977
}
@@ -1983,7 +1981,7 @@ pthread_handler_t run_task(void *p)
19831981
if (commit_rate && (++commit_counter == commit_rate))
19841982
{
19851983
commit_counter= 0;
1986-
run_query(mysql, "COMMIT", strlen("COMMIT"));
1984+
run_query(mysql, C_STRING_WITH_LEN("COMMIT"));
19871985
}
19881986

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

19961994
end:
19971995
if (commit_rate)
1998-
run_query(mysql, "COMMIT", strlen("COMMIT"));
1996+
run_query(mysql, C_STRING_WITH_LEN("COMMIT"));
19991997

20001998
mysql_close(mysql);
20011999

libmariadb

scripts/comp_sql.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates.
2-
Copyright (c) 2012, 2014, Monty Program Ab
2+
Copyright (c) 2012, 2022, MariaDB Corporation.
33
44
This program is free software; you can redistribute it and/or modify
55
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)
7777
static void print_query(FILE *out, const char *query)
7878
{
7979
const char *ptr= query;
80-
int column= 0;
8180

8281
fprintf(out, "\"");
8382
while (*ptr)
@@ -90,21 +89,18 @@ static void print_query(FILE *out, const char *query)
9089
and wrap to the next line, tabulated.
9190
*/
9291
fprintf(out, "\\n\"\n \"");
93-
column= 2;
9492
break;
9593
case '\r':
9694
/* Skipped */
9795
break;
9896
case '\"':
9997
fprintf(out, "\\\"");
100-
column++;
10198
break;
10299
case '\\':
103100
fprintf(out, "\\\\");
104101
break;
105102
default:
106103
putc(*ptr, out);
107-
column++;
108104
break;
109105
}
110106
ptr++;

sql/field.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2017, Oracle and/or its affiliates.
3-
Copyright (c) 2008, 2021, MariaDB
3+
Copyright (c) 2008, 2022, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
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)
99909990
}
99919991

99929992

9993-
int Field_bit::key_cmp(const uchar *str, uint length)
9993+
int Field_bit::key_cmp(const uchar *str, uint)
99949994
{
99959995
if (bit_len)
99969996
{
@@ -9999,7 +9999,6 @@ int Field_bit::key_cmp(const uchar *str, uint length)
99999999
if ((flag= (int) (bits - *str)))
1000010000
return flag;
1000110001
str++;
10002-
length--;
1000310002
}
1000410003
return memcmp(ptr, str, bytes_in_rec);
1000510004
}

sql/ha_partition.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
23532353
char *name_buffer_ptr;
23542354
const char *from_path;
23552355
const char *to_path= NULL;
2356-
uint i;
23572356
handler **file, **abort_file;
23582357
DBUG_ENTER("ha_partition::del_ren_table");
23592358

@@ -2382,7 +2381,6 @@ uint ha_partition::del_ren_table(const char *from, const char *to)
23822381
from_path= get_canonical_filename(*file, from, from_lc_buff);
23832382
if (to != NULL)
23842383
to_path= get_canonical_filename(*file, to, to_lc_buff);
2385-
i= 0;
23862384
do
23872385
{
23882386
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)
24072405
name_buffer_ptr= strend(name_buffer_ptr) + 1;
24082406
if (unlikely(error))
24092407
save_error= error;
2410-
i++;
24112408
} while (*(++file));
24122409
if (to != NULL)
24132410
{

sql/partition_info.cc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
2-
Copyright (c) 2010, 2018, MariaDB Corporation.
2+
Copyright (c) 2010, 2022, MariaDB Corporation.
33
44
This program is free software; you can redistribute it and/or modify
55
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)
15831583
uchar **char_ptrs;
15841584
unsigned i;
15851585
size_t size;
1586-
uint tot_fields= 0;
15871586
uint tot_part_fields= 0;
15881587
uint tot_subpart_fields= 0;
15891588
DBUG_ENTER("set_up_charset_field_preps");
@@ -1595,13 +1594,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
15951594
ptr= part_field_array;
15961595
/* Set up arrays and buffers for those fields */
15971596
while ((field= *(ptr++)))
1598-
{
15991597
if (field_is_partition_charset(field))
1600-
{
16011598
tot_part_fields++;
1602-
tot_fields++;
1603-
}
1604-
}
16051599
size= tot_part_fields * sizeof(char*);
16061600
if (!(char_ptrs= (uchar**)thd->calloc(size)))
16071601
goto error;
@@ -1635,13 +1629,8 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
16351629
/* Set up arrays and buffers for those fields */
16361630
ptr= subpart_field_array;
16371631
while ((field= *(ptr++)))
1638-
{
16391632
if (field_is_partition_charset(field))
1640-
{
16411633
tot_subpart_fields++;
1642-
tot_fields++;
1643-
}
1644-
}
16451634
size= tot_subpart_fields * sizeof(char*);
16461635
if (!(char_ptrs= (uchar**) thd->calloc(size)))
16471636
goto error;

sql/sql_lex.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
21912191
Lex_ident_cli_st *str)
21922192
{
21932193
CHARSET_INFO *const cs= thd->charset();
2194-
uint double_quotes= 0;
21952194
uchar c, quote_char= m_tok_start[0];
21962195
DBUG_ASSERT(m_ptr == m_tok_start + 1);
21972196

@@ -2216,7 +2215,6 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
22162215
if (yyPeek() != quote_char)
22172216
break;
22182217
c= yyGet();
2219-
double_quotes++;
22202218
continue;
22212219
}
22222220
}

sql/sql_statistics.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (C) 2009 MySQL AB
2-
Copyright (c) 2019, 2020, MariaDB Corporation.
2+
Copyright (c) 2019, 2022, MariaDB Corporation.
33
44
This program is free software; you can redistribute it and/or modify
55
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)
24832483
{
24842484
int rc= 0;
24852485
KEY *key_info= &table->key_info[index];
2486-
ha_rows rows= 0;
24872486

24882487
DBUG_ENTER("collect_statistics_for_index");
24892488

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

25192518
if (rc)
25202519
break;
2521-
rows++;
25222520
index_prefix_calc.add();
25232521
rc= table->file->ha_index_next(table->record[0]);
25242522
}

0 commit comments

Comments
 (0)