Skip to content

Commit 215fab6

Browse files
anson1014LinuxJedi
authored andcommitted
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.
1 parent 72ceae7 commit 215fab6

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

mysys/crc32/crc32_arm64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ my_crc32_t crc32c_aarch64_available(void)
3737
static unsigned long getauxval(unsigned int key)
3838
{
3939
unsigned long val;
40-
if (elf_aux_info(key, (void *)&val, (int)sizeof(val) != 0)
40+
if (elf_aux_info(key, (void *)&val, (int)sizeof(val) != 0))
4141
return 0ul;
4242
return val;
4343
}

mysys/my_rdtsc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ static ulonglong my_timer_init_frequency(MY_TIMER_INFO *mti)
349349
}
350350
time4= my_timer_cycles() - mti->cycles.overhead;
351351
time4-= mti->microseconds.overhead;
352-
return (mti->microseconds.frequency * (time4 - time1)) / (time3 - time2);
352+
ulonglong denominator = time3 - time2;
353+
if (denominator == 0) denominator = 1;
354+
return (mti->microseconds.frequency * (time4 - time1)) / denominator;
353355
}
354356

355357
/*
@@ -612,8 +614,10 @@ void my_timer_init(MY_TIMER_INFO *mti)
612614
if (time3 - time2 > 10) break;
613615
}
614616
time4= my_timer_cycles();
617+
ulonglong denominator = time4 - time1;
618+
if (denominator == 0) denominator = 1;
615619
mti->milliseconds.frequency=
616-
(mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
620+
(mti->cycles.frequency * (time3 - time2)) / denominator;
617621
}
618622

619623
/*
@@ -641,8 +645,12 @@ void my_timer_init(MY_TIMER_INFO *mti)
641645
if (time3 - time2 > 10) break;
642646
}
643647
time4= my_timer_cycles();
648+
ulonglong denominator = time4 - time1;
649+
if (denominator == 0) {
650+
denominator = 1;
651+
}
644652
mti->ticks.frequency=
645-
(mti->cycles.frequency * (time3 - time2)) / (time4 - time1);
653+
(mti->cycles.frequency * (time3 - time2)) / denominator;
646654
}
647655
}
648656

sql/sql_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2737,8 +2737,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
27372737
DBUG_RETURN(1);
27382738
lex->query_tables_last= query_tables_last;
27392739
break;
2740-
#endif
27412740
}
2741+
#endif
27422742
case SCH_PROFILES:
27432743
/*
27442744
Mark this current profiling record to be discarded. We don't

storage/maria/ha_s3.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ int ha_s3::create(const char *name, TABLE *table_arg,
549549
s3_deinit(s3_client);
550550
if (error)
551551
maria_delete_table_files(name, 1, 0);
552+
}
552553
else
553554
#endif /* MOVE_TABLE_TO_S3 */
554555
{

0 commit comments

Comments
 (0)