diff options
author | Chih-Hung Hsieh <chh@google.com> | 2016-08-02 11:19:23 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2016-08-02 11:19:23 -0700 |
commit | 906538079b8c4f08794a6fd3fd55ca1e35a24877 (patch) | |
tree | 4139cd3ffae5edbe99da48397f50b3da94006ebb /iotop | |
parent | 52e9f95751fa0d5b1e780e0899c1acf1814f8b6c (diff) | |
download | extras-906538079b8c4f08794a6fd3fd55ca1e35a24877.tar.gz |
Fix clang-tidy warnings in iotop.
* Declare explicit conversion constructors.
* Use const reference type for parameter to avoid unnecessary copy.
Bug: 28341362
Bug: 30407689
Change-Id: Ia95a041125703ecbfac128709fd6ea0591df2103
Test: build with WITH_TIDY=1
Diffstat (limited to 'iotop')
-rw-r--r-- | iotop/iotop.cpp | 2 | ||||
-rw-r--r-- | iotop/tasklist.cpp | 2 | ||||
-rw-r--r-- | iotop/taskstats.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/iotop/iotop.cpp b/iotop/iotop.cpp index 828fb32c..e2582e85 100644 --- a/iotop/iotop.cpp +++ b/iotop/iotop.cpp @@ -53,7 +53,7 @@ static void usage(char* myname) { } using Sorter = std::function<void(std::vector<TaskStatistics>&)>; -static Sorter GetSorter(const std::string field) { +static Sorter GetSorter(const std::string& field) { // Generic comparator static auto comparator = [](auto& lhs, auto& rhs, auto field, bool ascending) -> bool { auto a = (lhs.*field)(); diff --git a/iotop/tasklist.cpp b/iotop/tasklist.cpp index f81143fb..07087414 100644 --- a/iotop/tasklist.cpp +++ b/iotop/tasklist.cpp @@ -28,7 +28,7 @@ #include "tasklist.h" template<typename Func> -static bool ScanPidsInDir(std::string name, Func f) { +static bool ScanPidsInDir(const std::string& name, Func f) { std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(name.c_str()), closedir); if (!dir) { return false; diff --git a/iotop/taskstats.h b/iotop/taskstats.h index f5ad2d20..bbf7e9e2 100644 --- a/iotop/taskstats.h +++ b/iotop/taskstats.h @@ -25,7 +25,7 @@ struct taskstats; class TaskStatistics { public: - TaskStatistics(const taskstats&); + explicit TaskStatistics(const taskstats&); TaskStatistics() = default; TaskStatistics(const TaskStatistics&) = default; void AddPidToTgid(const TaskStatistics&); |