1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Perform simple fixes for cppcheck findings

Rectify cases of mismatched brackets and address
possible cases of division by zero by checking if
the denominator is zero before dividing.

No functional changes were made.

All new code of the whole pull request, including one or several
files that are either new files or modified ones, are contributed
under the BSD-new license. I am contributing on behalf of my
employer Amazon Web Services, Inc.
This commit is contained in:
Anson Chung
2024-05-13 22:19:38 +00:00
committed by Andrew Hutchings
parent 72ceae7314
commit 215fab68db
4 changed files with 14 additions and 5 deletions

View File

@@ -37,7 +37,7 @@ my_crc32_t crc32c_aarch64_available(void)
static unsigned long getauxval(unsigned int key)
{
unsigned long val;
if (elf_aux_info(key, (void *)&val, (int)sizeof(val) != 0)
if (elf_aux_info(key, (void *)&val, (int)sizeof(val) != 0))
return 0ul;
return val;
}

View File

@@ -349,7 +349,9 @@ static ulonglong my_timer_init_frequency(MY_TIMER_INFO *mti)
}
time4= my_timer_cycles() - mti->cycles.overhead;
time4-= mti->microseconds.overhead;
return (mti->microseconds.frequency * (time4 - time1)) / (time3 - time2);
ulonglong denominator = time3 - time2;
if (denominator == 0) denominator = 1;
return (mti->microseconds.frequency * (time4 - time1)) / denominator;
}
/*
@@ -612,8 +614,10 @@ void my_timer_init(MY_TIMER_INFO *mti)
if (time3 - time2 > 10) break;
}
time4= my_timer_cycles();
ulonglong denominator = time4 - time1;
if (denominator == 0) denominator = 1;
mti->milliseconds.frequency=
(mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
(mti->cycles.frequency * (time3 - time2)) / denominator;
}
/*
@@ -641,8 +645,12 @@ void my_timer_init(MY_TIMER_INFO *mti)
if (time3 - time2 > 10) break;
}
time4= my_timer_cycles();
ulonglong denominator = time4 - time1;
if (denominator == 0) {
denominator = 1;
}
mti->ticks.frequency=
(mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
(mti->cycles.frequency * (time3 - time2)) / denominator;
}
}

View File

@@ -2737,8 +2737,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
DBUG_RETURN(1);
lex->query_tables_last= query_tables_last;
break;
#endif
}
#endif
case SCH_PROFILES:
/*
Mark this current profiling record to be discarded. We don't

View File

@@ -549,6 +549,7 @@ int ha_s3::create(const char *name, TABLE *table_arg,
s3_deinit(s3_client);
if (error)
maria_delete_table_files(name, 1, 0);
}
else
#endif /* MOVE_TABLE_TO_S3 */
{