Skip to content

Commit

Permalink
Fix a ton of compiler warnings.
Browse files Browse the repository at this point in the history
Most of these are classes with virtual methods lacking virtual destructors
or NULL used in non-pointer context.

BUG=none
TEST=app_unittests && base_unittests
--gtest_filter=-ConditionVariableTest.LargeFastTaskTest

patch by Jacob Mandelson <jlmjlm [at] gmail>
http://codereview.chromium.org/171028/show


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24792 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
estade@chromium.org committed Aug 28, 2009
1 parent 86c008e commit be952c3
Show file tree
Hide file tree
Showing 141 changed files with 529 additions and 277 deletions.
5 changes: 4 additions & 1 deletion app/animation.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Inspired by NSAnimation
Expand Down Expand Up @@ -32,6 +32,9 @@ class AnimationDelegate {
// Called when an animation has been canceled.
virtual void AnimationCanceled(const Animation* animation) {
}

protected:
~AnimationDelegate() {}
};

// Animation
Expand Down
2 changes: 2 additions & 0 deletions app/table_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class TableModel {
void ClearCollator();

protected:
~TableModel() {}

// Returns the collator used by CompareValues.
icu::Collator* GetCollator();
};
Expand Down
3 changes: 3 additions & 0 deletions app/table_model_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class TableModelObserver {

// Invoked when a range of items has been removed.
virtual void OnItemsRemoved(int start, int length) = 0;

protected:
~TableModelObserver() {}
};

#endif // APP_TABLE_MODEL_OBSERVER_H_
11 changes: 10 additions & 1 deletion app/tree_model.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -21,6 +21,9 @@ class TreeModelNode {
public:
// Returns the title for the node.
virtual const std::wstring& GetTitle() const = 0;

protected:
~TreeModelNode() {}
};

// Observer for the TreeModel. Notified of significant events to the model.
Expand All @@ -45,6 +48,9 @@ class TreeModelObserver {

// Notification that the contents of a node has changed.
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) = 0;

protected:
~TreeModelObserver() {}
};

// TreeModel ------------------------------------------------------------------
Expand Down Expand Up @@ -83,6 +89,9 @@ class TreeModel {
// default icon. The index is relative to the list of icons returned from
// GetIcons.
virtual int GetIconIndex(TreeModelNode* node) { return -1; }

protected:
~TreeModel() {}
};

#endif // APP_TREE_TREE_MODEL_H_
4 changes: 2 additions & 2 deletions base/field_trial_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ TEST_F(FieldTrialTest, Save) {
}

TEST_F(FieldTrialTest, Restore) {
EXPECT_EQ(NULL, FieldTrialList::Find("Some_name"));
EXPECT_EQ(NULL, FieldTrialList::Find("xxx"));
EXPECT_TRUE(NULL == FieldTrialList::Find("Some_name"));
EXPECT_TRUE(NULL == FieldTrialList::Find("xxx"));

FieldTrialList::StringAugmentsState("Some_name/Winner/xxx/yyyy/");

Expand Down
3 changes: 3 additions & 0 deletions base/file_descriptor_shuffle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class InjectionDelegate {
virtual bool Move(int src, int dest) = 0;
// Delete an element of the domain.
virtual void Close(int fd) = 0;

protected:
~InjectionDelegate() {}
};

// An implementation of the InjectionDelegate interface using the file
Expand Down
10 changes: 5 additions & 5 deletions base/multiprocess_test.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_MULTIPROCESS_TEST_H__
#define BASE_MULTIPROCESS_TEST_H__
#ifndef BASE_MULTIPROCESS_TEST_H_
#define BASE_MULTIPROCESS_TEST_H_

#include "base/base_switches.h"
#include "base/command_line.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ class MultiProcessTest : public PlatformTest {
const base::file_handle_mapping_vector& fds_to_map,
bool debug_on_start) {
CommandLine cl(*CommandLine::ForCurrentProcess());
base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
base::ProcessHandle handle = 0;
cl.AppendSwitchWithValue(kRunClientProcess, procname);

if (debug_on_start)
Expand All @@ -118,4 +118,4 @@ class MultiProcessTest : public PlatformTest {
#endif
};

#endif // BASE_MULTIPROCESS_TEST_H__
#endif // BASE_MULTIPROCESS_TEST_H_
11 changes: 5 additions & 6 deletions base/process_util_linux.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -259,7 +259,6 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
int private_kb = 0;
int pss_kb = 0;
bool have_pss = false;
const int kPssAdjust = 0.5;
if (!file_util::ReadFileToString(stat_file, &smaps))
return false;

Expand All @@ -278,12 +277,12 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
return false;
}
if (StartsWithASCII(last_key_name, "Shared_", 1)) {
shared_kb += StringToInt(tokenizer.token());
shared_kb += StringToInt(tokenizer.token());
} else if (StartsWithASCII(last_key_name, "Private_", 1)) {
private_kb += StringToInt(tokenizer.token());
private_kb += StringToInt(tokenizer.token());
} else if (StartsWithASCII(last_key_name, "Pss", 1)) {
have_pss = true;
pss_kb += StringToInt(tokenizer.token()) + kPssAdjust;
have_pss = true;
pss_kb += StringToInt(tokenizer.token());
}
state = KEY_NAME;
break;
Expand Down
4 changes: 2 additions & 2 deletions base/process_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MULTIPROCESS_TEST_MAIN(SimpleChildProcess) {
TEST_F(ProcessUtilTest, SpawnChild) {
ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess");

ASSERT_NE(static_cast<ProcessHandle>(NULL), handle);
ASSERT_NE(0, handle);
EXPECT_TRUE(WaitForSingleProcess(handle, 5000));
base::CloseProcessHandle(handle);
}
Expand All @@ -62,7 +62,7 @@ MULTIPROCESS_TEST_MAIN(SlowChildProcess) {
TEST_F(ProcessUtilTest, KillSlowChild) {
remove("SlowChildProcess.die");
ProcessHandle handle = this->SpawnChild(L"SlowChildProcess");
ASSERT_NE(static_cast<ProcessHandle>(NULL), handle);
ASSERT_NE(0, handle);
FILE *fp = fopen("SlowChildProcess.die", "w");
fclose(fp);
EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000));
Expand Down
4 changes: 2 additions & 2 deletions base/stats_table_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -208,7 +208,7 @@ TEST_F(StatsTableTest, MultipleProcesses) {
// Spawn the processes.
for (int16 index = 0; index < kMaxProcs; index++) {
procs[index] = this->SpawnChild(L"StatsTableMultipleProcessMain");
EXPECT_NE(static_cast<ProcessHandle>(NULL), procs[index]);
EXPECT_NE(0, procs[index]);
}

// Wait for the processes to finish.
Expand Down
5 changes: 4 additions & 1 deletion base/system_monitor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -72,6 +72,9 @@ class SystemMonitor {

// Notification that the system is resuming.
virtual void OnResume(SystemMonitor*) = 0;

protected:
~PowerObserver() {}
};

// Add a new observer.
Expand Down
6 changes: 5 additions & 1 deletion base/task.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -678,6 +678,7 @@ template <typename ReturnValue>
struct CallbackWithReturnValue {
class Type {
public:
virtual ~Type() {}
virtual ReturnValue Run() = 0;
};
};
Expand All @@ -693,6 +694,9 @@ class CallbackWithReturnValueImpl
virtual ReturnValue Run() {
return (this->obj_->*(this->meth_))();
}

protected:
~CallbackWithReturnValueImpl() {}
};

template <class T, typename ReturnValue>
Expand Down
1 change: 1 addition & 0 deletions base/third_party/dmg_fp/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ List of changes made to original code:
- made some minor changes to allow clean compilation under g++ -Wall, see
gcc_warnings.patch.
- made some minor changes to build on 64-bit, see gcc_64_bit.patch.
- made some implicit type converisons explicit, see type_conversion.patch.
6 changes: 3 additions & 3 deletions base/third_party/dmg_fp/dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ hexnan
CONST char *s;
int c1, havedig, udx0, xshift;

if (!hexdig['0'])
if (!hexdig[static_cast<int>('0')])
hexdig_init();
x[0] = x[1] = 0;
havedig = xshift = 0;
Expand Down Expand Up @@ -3283,7 +3283,7 @@ strtod
#ifdef Avoid_Underflow
if (bc.scale && y <= 2*P*Exp_msk1) {
if (aadj <= 0x7fffffff) {
if ((z = aadj) <= 0)
if ((z = static_cast<ULong>(aadj)) <= 0)
z = 1;
aadj = z;
aadj1 = bc.dsign ? aadj : -aadj;
Expand Down Expand Up @@ -3837,7 +3837,7 @@ dtoa
*/
dval(&eps) = 0.5/tens[ilim-1] - dval(&eps);
for(i = 0;;) {
L = dval(&u);
L = static_cast<long>(dval(&u));
dval(&u) -= L;
*s++ = '0' + (int)L;
if (dval(&u) < dval(&eps))
Expand Down
9 changes: 5 additions & 4 deletions base/time.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -51,7 +51,7 @@ int64 TimeDelta::InMicroseconds() const {
Time Time::FromTimeT(time_t tt) {
if (tt == 0)
return Time(); // Preserve 0 so we can tell it doesn't exist.
return (tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset;
return Time((tt * kMicrosecondsPerSecond) + kTimeTToMicrosecondsOffset);
}

time_t Time::ToTimeT() const {
Expand All @@ -62,8 +62,9 @@ time_t Time::ToTimeT() const {

// static
Time Time::FromDoubleT(double dt) {
return (dt * static_cast<double>(kMicrosecondsPerSecond)) +
kTimeTToMicrosecondsOffset;
return Time(static_cast<int64>((dt *
static_cast<double>(kMicrosecondsPerSecond)) +
kTimeTToMicrosecondsOffset));
}

double Time::ToDoubleT() const {
Expand Down
8 changes: 4 additions & 4 deletions base/time.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -313,10 +313,10 @@ class Time {

// Return a new time modified by some delta.
Time operator+(TimeDelta delta) const {
return us_ + delta.delta_;
return Time(us_ + delta.delta_);
}
Time operator-(TimeDelta delta) const {
return us_ - delta.delta_;
return Time(us_ - delta.delta_);
}

// Comparison operators
Expand Down Expand Up @@ -350,7 +350,7 @@ class Time {
// |is_local = true| or UTC |is_local = false|.
static Time FromExploded(bool is_local, const Exploded& exploded);

Time(int64 us) : us_(us) {
explicit Time(int64 us) : us_(us) {
}

// The representation of Jan 1, 1970 UTC in microseconds since the
Expand Down
2 changes: 1 addition & 1 deletion base/time_posix.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
5 changes: 4 additions & 1 deletion base/waitable_event.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -121,6 +121,9 @@ class WaitableEvent {
// pointers match then this function is called as a final check. See the
// comments in ~Handle for why.
virtual bool Compare(void* tag) = 0;

protected:
~Waiter() {}
};

private:
Expand Down
6 changes: 3 additions & 3 deletions base/waitable_event_watcher_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -38,7 +38,7 @@ void RunTest_BasicSignal(MessageLoop::Type message_loop_type) {
WaitableEvent event(true, false);

WaitableEventWatcher watcher;
EXPECT_EQ(NULL, watcher.GetWatchedEvent());
EXPECT_TRUE(NULL == watcher.GetWatchedEvent());

QuitDelegate delegate;
watcher.StartWatching(&event, &delegate);
Expand All @@ -48,7 +48,7 @@ void RunTest_BasicSignal(MessageLoop::Type message_loop_type) {

MessageLoop::current()->Run();

EXPECT_EQ(NULL, watcher.GetWatchedEvent());
EXPECT_TRUE(NULL == watcher.GetWatchedEvent());
}

void RunTest_BasicCancel(MessageLoop::Type message_loop_type) {
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/autocomplete/autocomplete.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -466,6 +466,8 @@ class AutocompleteProvider
// them all again when this is called anyway, so such a parameter wouldn't
// actually be useful.
virtual void OnProviderUpdate(bool updated_matches) = 0;
protected:
~ACProviderListener() {}
};

AutocompleteProvider(ACProviderListener* listener,
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/autocomplete/autocomplete_edit.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -51,6 +51,8 @@ class AutocompleteEditController {

// Returns the title of the current page.
virtual std::wstring GetTitle() const = 0;
protected:
~AutocompleteEditController() {}
};

class AutocompleteEditModel {
Expand Down
Loading

0 comments on commit be952c3

Please sign in to comment.