Skip to content

Commit 3bde139

Browse files
committed
Minor cleanups, fix compiler warnings
1 parent d87ffeb commit 3bde139

File tree

10 files changed

+25
-19
lines changed

10 files changed

+25
-19
lines changed

extra/my_print_defaults.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ static struct my_option my_long_options[] =
9898
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
9999
};
100100

101+
void cleanup_and_exit(int exit_code)
102+
{
103+
my_end(0);
104+
exit(exit_code);
105+
}
101106

102107
static void usage(my_bool version)
103108
{
@@ -112,7 +117,7 @@ static void usage(my_bool version)
112117
my_print_default_files(config_file);
113118
my_print_variables(my_long_options);
114119
printf("\nExample usage:\n%s --defaults-file=example.cnf client client-server mysql\n", my_progname);
115-
exit(0);
120+
cleanup_and_exit(0);
116121
}
117122

118123

@@ -125,7 +130,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
125130
opt_defaults_file_used= 1;
126131
break;
127132
case 'n':
128-
exit(0);
133+
cleanup_and_exit(0);
129134
case 'I':
130135
case '?':
131136
usage(0);
@@ -174,7 +179,7 @@ int main(int argc, char **argv)
174179

175180
/* Check out the args */
176181
if (get_options(&argc,&argv))
177-
exit(1);
182+
cleanup_and_exit(1);
178183

179184
nargs= argc + 1;
180185
if (opt_mysqld)

sql/events.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ Events::reconstruct_interval_expression(String *buf, interval_type interval,
270270
static int
271271
create_query_string(THD *thd, String *buf)
272272
{
273+
buf->length(0);
273274
/* Append the "CREATE" part of the query */
274275
if (buf->append(STRING_WITH_LEN("CREATE ")))
275276
return 1;
@@ -380,7 +381,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
380381
{
381382
/* Binlog the create event. */
382383
DBUG_ASSERT(thd->query() && thd->query_length());
383-
String log_query;
384+
char buffer[1024];
385+
String log_query(buffer, sizeof(buffer), &my_charset_bin);
384386
if (create_query_string(thd, &log_query))
385387
{
386388
sql_print_error("Event Error: An error occurred while creating query "

sql/handler.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,11 +1414,10 @@ int ha_commit_trans(THD *thd, bool all)
14141414
err= ht->prepare(ht, thd, all);
14151415
status_var_increment(thd->status_var.ha_prepare_count);
14161416
if (err)
1417+
{
14171418
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
1418-
1419-
if (err)
14201419
goto err;
1421-
1420+
}
14221421
need_prepare_ordered|= (ht->prepare_ordered != NULL);
14231422
need_commit_ordered|= (ht->commit_ordered != NULL);
14241423
}

sql/sql_class.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,8 +1355,8 @@ void THD::init(void)
13551355
mysql_mutex_lock(&LOCK_global_system_variables);
13561356
plugin_thdvar_init(this);
13571357
/*
1358-
variables= global_system_variables above has reset
1359-
variables.pseudo_thread_id to 0. We need to correct it here to
1358+
plugin_thd_var_init() sets variables= global_system_variables, which
1359+
has reset variables.pseudo_thread_id to 0. We need to correct it here to
13601360
avoid temporary tables replication failure.
13611361
*/
13621362
variables.pseudo_thread_id= thread_id;

storage/innobase/include/dict0dict.ic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ dict_tf_is_valid(
647647

648648
if (atomic_writes) {
649649

650-
if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
650+
if(atomic_writes > ATOMIC_WRITES_OFF) {
651651

652652
fprintf(stderr,
653653
"InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n"
@@ -689,7 +689,7 @@ dict_sys_tables_type_validate(
689689
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type);
690690
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type);
691691

692-
ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF);
692+
ut_a(atomic_writes <= ATOMIC_WRITES_OFF);
693693

694694
/* The low order bit of SYS_TABLES.TYPE is always set to 1.
695695
If the format is UNIV_FORMAT_B or higher, this field is the same
@@ -768,7 +768,7 @@ dict_sys_tables_type_validate(
768768
}
769769

770770
/* Validate that the atomic writes number is within allowed range. */
771-
if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
771+
if (atomic_writes > ATOMIC_WRITES_OFF) {
772772
fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n",
773773
type, atomic_writes);
774774
return(ULINT_UNDEFINED);

storage/innobase/include/dict0pagecompress.ic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ dict_tf_get_page_compression_level(
122122
{
123123
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags);
124124

125-
ut_ad(page_compression_level >= 0 && page_compression_level <= 9);
125+
ut_ad(page_compression_level <= 9);
126126

127127
return(page_compression_level);
128128
}

storage/innobase/include/fsp0fsp.ic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fsp_flags_is_valid(
131131
}
132132
}
133133

134-
if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
134+
if (atomic_writes > ATOMIC_WRITES_OFF) {
135135
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n",
136136
flags, atomic_writes);
137137
return (false);

storage/xtradb/include/dict0dict.ic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ dict_tf_is_valid(
651651

652652
if (atomic_writes) {
653653

654-
if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
654+
if(atomic_writes > ATOMIC_WRITES_OFF) {
655655

656656
fprintf(stderr,
657657
"InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n"
@@ -693,7 +693,7 @@ dict_sys_tables_type_validate(
693693
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type);
694694
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type);
695695

696-
ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF);
696+
ut_a(atomic_writes <= ATOMIC_WRITES_OFF);
697697

698698
/* The low order bit of SYS_TABLES.TYPE is always set to 1.
699699
If the format is UNIV_FORMAT_B or higher, this field is the same
@@ -772,7 +772,7 @@ dict_sys_tables_type_validate(
772772
}
773773

774774
/* Validate that the atomic writes number is within allowed range. */
775-
if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
775+
if (atomic_writes > ATOMIC_WRITES_OFF) {
776776
fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n",
777777
type, atomic_writes);
778778
return(ULINT_UNDEFINED);

storage/xtradb/include/dict0pagecompress.ic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ dict_tf_get_page_compression_level(
122122
{
123123
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags);
124124

125-
ut_ad(page_compression_level >= 0 && page_compression_level <= 9);
125+
ut_ad(page_compression_level <= 9);
126126

127127
return(page_compression_level);
128128
}

storage/xtradb/include/fsp0fsp.ic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fsp_flags_is_valid(
135135
}
136136
}
137137

138-
if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) {
138+
if (atomic_writes > ATOMIC_WRITES_OFF) {
139139
fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n",
140140
flags, atomic_writes);
141141
return (false);

0 commit comments

Comments
 (0)