diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 01:03:05 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 01:03:05 +0000 |
commit | 2e58cbde90c00896dcfdf2b553624a50eb7d808b (patch) | |
tree | ed936dea01bcbffe92cb0d37844d3743f4038370 /base | |
parent | d5067663db522660f8148ccdccc13f9ddaa77389 (diff) | |
download | chromium_src-2e58cbde90c00896dcfdf2b553624a50eb7d808b.zip chromium_src-2e58cbde90c00896dcfdf2b553624a50eb7d808b.tar.gz chromium_src-2e58cbde90c00896dcfdf2b553624a50eb7d808b.tar.bz2 |
base: Fix minor warnings reported by cppcheck.
Found with:
$ cppcheck --enable=all -j4 --force base 2> base-errors
R=jar@chromium.org
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/10827112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/json/json_value_converter_unittest.cc | 2 | ||||
-rw-r--r-- | base/memory/scoped_ptr_unittest.cc | 16 | ||||
-rw-r--r-- | base/observer_list_unittest.cc | 3 | ||||
-rw-r--r-- | base/process_util_posix.cc | 7 | ||||
-rw-r--r-- | base/system_monitor/system_monitor_unittest.cc | 5 |
5 files changed, 16 insertions, 17 deletions
diff --git a/base/json/json_value_converter_unittest.cc b/base/json/json_value_converter_unittest.cc index 925fd5c..e5ad289 100644 --- a/base/json/json_value_converter_unittest.cc +++ b/base/json/json_value_converter_unittest.cc @@ -29,7 +29,7 @@ struct SimpleMessage { SimpleEnum simple_enum; ScopedVector<int> ints; ScopedVector<std::string> string_values; - SimpleMessage() : foo(0), baz(false), bstruct(false) {} + SimpleMessage() : foo(0), baz(false), bstruct(false), simple_enum(FOO) {} static bool ParseSimpleEnum(const StringPiece& value, SimpleEnum* field) { if (value == "foo") { diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc index 06c6a50..3da6f15 100644 --- a/base/memory/scoped_ptr_unittest.cc +++ b/base/memory/scoped_ptr_unittest.cc @@ -12,7 +12,8 @@ namespace { class ConDecLoggerParent { public: virtual ~ConDecLoggerParent() {} - virtual void set_ptr(int* ptr) = 0; + + virtual void SetPtr(int* ptr) = 0; virtual int SomeMeth(int x) const = 0; }; @@ -20,15 +21,16 @@ class ConDecLoggerParent { class ConDecLogger : public ConDecLoggerParent { public: ConDecLogger() : ptr_(NULL) { } - explicit ConDecLogger(int* ptr) { set_ptr(ptr); } + explicit ConDecLogger(int* ptr) { SetPtr(ptr); } virtual ~ConDecLogger() { --*ptr_; } - virtual void set_ptr(int* ptr) OVERRIDE { ptr_ = ptr; ++*ptr_; } + virtual void SetPtr(int* ptr) OVERRIDE { ptr_ = ptr; ++*ptr_; } virtual int SomeMeth(int x) const OVERRIDE { return x; } private: int* ptr_; + DISALLOW_COPY_AND_ASSIGN(ConDecLogger); }; @@ -195,7 +197,7 @@ TEST(ScopedPtrTest, ScopedArray) { EXPECT_TRUE(scoper.get()); EXPECT_EQ(&scoper[0], scoper.get()); for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].set_ptr(&constructed); + scoper[i].SetPtr(&constructed); } EXPECT_EQ(12, constructed); @@ -215,7 +217,7 @@ TEST(ScopedPtrTest, ScopedArray) { scoper.reset(new ConDecLogger[kNumLoggers]); for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].set_ptr(&constructed); + scoper[i].SetPtr(&constructed); } EXPECT_EQ(12, constructed); scoper.reset(); @@ -223,7 +225,7 @@ TEST(ScopedPtrTest, ScopedArray) { scoper.reset(new ConDecLogger[kNumLoggers]); for (int i = 0; i < kNumLoggers; ++i) { - scoper[i].set_ptr(&constructed); + scoper[i].SetPtr(&constructed); } EXPECT_EQ(12, constructed); ConDecLogger* ptr = scoper.release(); @@ -242,7 +244,7 @@ TEST(ScopedPtrTest, ScopedArray) { ConDecLogger* loggers = new ConDecLogger[kNumLoggers]; for (int i = 0; i < kNumLoggers; ++i) { - loggers[i].set_ptr(&constructed); + loggers[i].SetPtr(&constructed); } scoper1.reset(loggers); EXPECT_EQ(loggers, scoper1.get()); diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc index f8aff5a..8a85215 100644 --- a/base/observer_list_unittest.cc +++ b/base/observer_list_unittest.cc @@ -101,6 +101,7 @@ class AddRemoveThread : public PlatformThread::Delegate, public: AddRemoveThread(ObserverListThreadSafe<Foo>* list, bool notify) : list_(list), + loop_(NULL), in_list_(false), start_(Time::Now()), count_observes_(0), @@ -529,7 +530,7 @@ class ListDestructor : public Foo { virtual void Observe(int x) OVERRIDE { delete list_; } - int total; + private: ObserverList<Foo>* list_; }; diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index a6e816a..9ea0e41e 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -253,11 +253,7 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { DCHECK_GT(process_id, 1) << " tried to kill invalid process_id"; if (process_id <= 1) return false; - static unsigned kMaxSleepMs = 1000; - unsigned sleep_ms = 4; - bool result = kill(process_id, SIGTERM) == 0; - if (result && wait) { int tries = 60; @@ -267,6 +263,8 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { tries *= 2; } + unsigned sleep_ms = 4; + // The process may not end immediately due to pending I/O bool exited = false; while (tries-- > 0) { @@ -286,6 +284,7 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { } usleep(sleep_ms * 1000); + const unsigned kMaxSleepMs = 1000; if (sleep_ms < kMaxSleepMs) sleep_ms *= 2; } diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc index e724e83..2f6ddb5f 100644 --- a/base/system_monitor/system_monitor_unittest.cc +++ b/base/system_monitor/system_monitor_unittest.cc @@ -18,8 +18,7 @@ namespace { class PowerTest : public SystemMonitor::PowerObserver { public: PowerTest() - : battery_(false), - power_state_changes_(0), + : power_state_changes_(0), suspends_(0), resumes_(0) { } @@ -38,13 +37,11 @@ class PowerTest : public SystemMonitor::PowerObserver { } // Test status counts. - bool battery() { return battery_; } int power_state_changes() { return power_state_changes_; } int suspends() { return suspends_; } int resumes() { return resumes_; } private: - bool battery_; // Do we currently think we're on battery power. int power_state_changes_; // Count of OnPowerStateChange notifications. int suspends_; // Count of OnSuspend notifications. int resumes_; // Count of OnResume notifications. |