Browse Source

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.
pull/3323/head
Anson Chung 1 year ago
committed by Andrew Hutchings
parent
commit
215fab68db
  1. 2
      mysys/crc32/crc32_arm64.c
  2. 14
      mysys/my_rdtsc.c
  3. 2
      sql/sql_parse.cc
  4. 1
      storage/maria/ha_s3.cc

2
mysys/crc32/crc32_arm64.c

@ -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;
}

14
mysys/my_rdtsc.c

@ -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;
}
}

2
sql/sql_parse.cc

@ -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

1
storage/maria/ha_s3.cc

@ -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 */
{

Loading…
Cancel
Save