diff options
author | Elliott Hughes <enh@google.com> | 2018-01-19 15:45:23 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2018-01-19 15:56:12 -0800 |
commit | 5cec377f49d6429b19895eb632225cd757ea611e (patch) | |
tree | bcd08fe1e6b656a5a4e235a225fbe88feb54a112 /benchmarks | |
parent | 0d63a3c233040af004cc470d5f76547f3adc0148 (diff) | |
download | android_bionic-5cec377f49d6429b19895eb632225cd757ea611e.tar.gz android_bionic-5cec377f49d6429b19895eb632225cd757ea611e.tar.bz2 android_bionic-5cec377f49d6429b19895eb632225cd757ea611e.zip |
Address a bunch of clang-tidy complaints.
There were a bunch more unreasonable/incorrect ones, but these ones
seemed legit. Nothing very interesting, though.
Bug: N/A
Test: ran tests, benchmarks
Change-Id: If66971194d4a7b4bf6d0251bedb88e8cdc88a76f
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/bionic_benchmarks.cpp | 10 | ||||
-rw-r--r-- | benchmarks/stdio_benchmark.cpp | 2 | ||||
-rw-r--r-- | benchmarks/util.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp index fe7a1b13e..d8635cda4 100644 --- a/benchmarks/bionic_benchmarks.cpp +++ b/benchmarks/bionic_benchmarks.cpp @@ -305,7 +305,7 @@ args_vector_t* ResolveArgs(args_vector_t* to_populate, std::string args, } void RegisterGoogleBenchmarks(bench_opts_t primary_opts, bench_opts_t secondary_opts, - std::string fn_name, args_vector_t* run_args) { + const std::string& fn_name, args_vector_t* run_args) { if (g_str_to_func.find(fn_name) == g_str_to_func.end()) { errx(1, "ERROR: No benchmark for function %s", fn_name.c_str()); } @@ -320,7 +320,7 @@ void RegisterGoogleBenchmarks(bench_opts_t primary_opts, bench_opts_t secondary_ } benchmark_func_t benchmark_function = g_str_to_func.at(fn_name).first; - for (std::vector<int> args : (*run_args)) { + for (const std::vector<int>& args : (*run_args)) { auto registration = benchmark::RegisterBenchmark(fn_name.c_str(), LockAndRun, benchmark_function, cpu_to_use)->Args(args); @@ -335,13 +335,13 @@ void RegisterCliBenchmarks(bench_opts_t cmdline_opts, // Register any of the extra benchmarks that were specified in the options. args_vector_t arg_vector; args_vector_t* run_args = &arg_vector; - for (std::string extra_fn : cmdline_opts.extra_benchmarks) { + for (const std::string& extra_fn : cmdline_opts.extra_benchmarks) { android::base::Trim(extra_fn); - size_t first_space_pos = extra_fn.find(" "); + size_t first_space_pos = extra_fn.find(' '); std::string fn_name = extra_fn.substr(0, first_space_pos); std::string cmd_args; if (first_space_pos != std::string::npos) { - cmd_args = extra_fn.substr(extra_fn.find(" ") + 1); + cmd_args = extra_fn.substr(extra_fn.find(' ') + 1); } else { cmd_args = ""; } diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp index 965a3ae9f..9c81e0fc0 100644 --- a/benchmarks/stdio_benchmark.cpp +++ b/benchmarks/stdio_benchmark.cpp @@ -29,7 +29,7 @@ static void FillFile(TemporaryFile& tf) { memset(line, 'x', sizeof(line)); line[sizeof(line) - 1] = '\0'; - FILE* fp = fopen(tf.path, "w"); + FILE* fp = fopen(tf.path, "we"); for (size_t i = 0; i < 4096; ++i) fputs(line, fp); fclose(fp); } diff --git a/benchmarks/util.h b/benchmarks/util.h index a54676416..3225bc298 100644 --- a/benchmarks/util.h +++ b/benchmarks/util.h @@ -29,7 +29,7 @@ extern std::mutex g_map_lock; extern std::map<std::string, std::pair<benchmark_func_t, std::string>> g_str_to_func; -static int __attribute__((unused)) EmplaceBenchmark (std::string fn_name, benchmark_func_t fn_ptr, std::string arg = "") { +static int __attribute__((unused)) EmplaceBenchmark(const std::string& fn_name, benchmark_func_t fn_ptr, const std::string& arg = "") { g_map_lock.lock(); g_str_to_func.emplace(std::string(fn_name), std::make_pair(fn_ptr, arg)); g_map_lock.unlock(); |