Fix code triggering -Wsign-conversion (#1596)

* Fix code triggering -Wsign-conversion

* more test
This commit is contained in:
Vy Nguyen 2023-05-11 03:40:05 -04:00 committed by GitHub
parent 318dd44225
commit fec77322b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -46,7 +46,7 @@ BENCHMARK(BM_MyBench);
int main(int argc, char** argv) { int main(int argc, char** argv) {
// Make a fake argv and append the new --benchmark_min_time=<foo> to it. // Make a fake argv and append the new --benchmark_min_time=<foo> to it.
int fake_argc = argc + 1; int fake_argc = argc + 1;
const char** fake_argv = new const char*[fake_argc]; const char** fake_argv = new const char*[static_cast<size_t>(fake_argc)];
for (int i = 0; i < argc; ++i) fake_argv[i] = argv[i]; for (int i = 0; i < argc; ++i) fake_argv[i] = argv[i];
fake_argv[argc] = "--benchmark_min_time=4x"; fake_argv[argc] = "--benchmark_min_time=4x";

View File

@ -71,7 +71,7 @@ BENCHMARK(BM_MyBench);
int main(int argc, char** argv) { int main(int argc, char** argv) {
// Make a fake argv and append the new --benchmark_min_time=<foo> to it. // Make a fake argv and append the new --benchmark_min_time=<foo> to it.
int fake_argc = argc + 1; int fake_argc = argc + 1;
const char** fake_argv = new const char*[fake_argc]; const char** fake_argv = new const char*[static_cast<size_t>(fake_argc)];
for (int i = 0; i < argc; ++i) fake_argv[i] = argv[i]; for (int i = 0; i < argc; ++i) fake_argv[i] = argv[i];

View File

@ -169,8 +169,8 @@ TEST(PerfCountersTest, CreateExistingMeasurements) {
std::vector<std::pair<std::string, double>> measurements; std::vector<std::pair<std::string, double>> measurements;
// Start all counters together to see if they hold // Start all counters together to see if they hold
int max_counters = kMaxCounters; size_t max_counters = kMaxCounters;
for (int i = 0; i < kMaxCounters; ++i) { for (size_t i = 0; i < kMaxCounters; ++i) {
auto& counter(*perf_counter_measurements[i]); auto& counter(*perf_counter_measurements[i]);
EXPECT_EQ(counter.num_counters(), 1); EXPECT_EQ(counter.num_counters(), 1);
if (!counter.Start()) { if (!counter.Start()) {
@ -182,13 +182,13 @@ TEST(PerfCountersTest, CreateExistingMeasurements) {
ASSERT_GE(max_counters, kMinValidCounters); ASSERT_GE(max_counters, kMinValidCounters);
// Start all together // Start all together
for (int i = 0; i < max_counters; ++i) { for (size_t i = 0; i < max_counters; ++i) {
auto& counter(*perf_counter_measurements[i]); auto& counter(*perf_counter_measurements[i]);
EXPECT_TRUE(counter.Stop(measurements) || (i >= kMinValidCounters)); EXPECT_TRUE(counter.Stop(measurements) || (i >= kMinValidCounters));
} }
// Start/stop individually // Start/stop individually
for (int i = 0; i < max_counters; ++i) { for (size_t i = 0; i < max_counters; ++i) {
auto& counter(*perf_counter_measurements[i]); auto& counter(*perf_counter_measurements[i]);
measurements.clear(); measurements.clear();
counter.Start(); counter.Start();