Skip to content

Commit

Permalink
update_engine: fixed warnings from cpplint
Browse files Browse the repository at this point in the history
Fixed all the cpplint warnings in update engine.

BUG=None
TEST=Unit tests still pass.

Change-Id: I285ae858eec8abe0b26ff203b99a42a200ceb71c
Reviewed-on: https://chromium-review.googlesource.com/204027
Reviewed-by: Alex Vakulenko <[email protected]>
Tested-by: Alex Vakulenko <[email protected]>
Commit-Queue: Alex Vakulenko <[email protected]>
  • Loading branch information
Alex Vakulenko authored and chrome-internal-fetch committed Jun 18, 2014
1 parent b683327 commit d2779df
Show file tree
Hide file tree
Showing 95 changed files with 541 additions and 540 deletions.
8 changes: 4 additions & 4 deletions action.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <stdio.h>

#include <iostream>
#include <memory>
#include <string>

#include <base/basictypes.h>
#include <base/logging.h>
Expand Down Expand Up @@ -58,10 +58,10 @@
// DownloadAction::InputObjectType.
//
// Each concrete Action class derives from Action<T>. This means that during
// template instatiation of Action<T>, T is declared but not defined, which
// template instantiation of Action<T>, T is declared but not defined, which
// means that T::InputObjectType (and OutputObjectType) is not defined.
// However, the traits class is constructed in such a way that it will be
// template instatiated first, so Action<T> *can* find the types it needs by
// template instantiated first, so Action<T> *can* find the types it needs by
// consulting ActionTraits<T>::InputObjectType (and OutputObjectType).
// This is why the ActionTraits classes are needed.

Expand Down Expand Up @@ -109,7 +109,7 @@ class AbstractAction {
// ActionProcessor::ActionComplete() because the processor knows this
// action is terminating.
// Only the ActionProcessor should call this.
virtual void TerminateProcessing() {};
virtual void TerminateProcessing() {}

// These methods are useful for debugging. TODO(adlr): consider using
// std::type_info for this?
Expand Down
2 changes: 2 additions & 0 deletions action_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_MOCK_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_MOCK_H_

#include <string>

#include <gmock/gmock.h>

#include "update_engine/action.h"
Expand Down
1 change: 0 additions & 1 deletion action_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <stdio.h>

#include <iostream>
#include <map>
#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion action_processor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MyActionProcessorDelegate : public ActionProcessorDelegate {
bool action_completed_called_;
ErrorCode action_exit_code_;
};
} // namespace {}
} // namespace

TEST(ActionProcessorTest, DelegateTest) {
ActionProcessorTestAction action;
Expand Down
12 changes: 6 additions & 6 deletions bzip.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 The Chromium OS 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 @@ -59,7 +59,7 @@ bool BzipData(const char* const in,
// Try increasing buffer size until it works
size_t buf_size = in_size;
out->resize(buf_size);

for (;;) {
uint32_t data_size = buf_size;
int rc = F(&(*out)[0], &data_size, in, in_size);
Expand All @@ -69,14 +69,14 @@ bool BzipData(const char* const in,
out->resize(data_size);
return true;
}

// Data didn't fit; double the buffer size.
buf_size *= 2;
out->resize(buf_size);
}
}

} // namespace {}
} // namespace

bool BzipDecompress(const std::vector<char>& in, std::vector<char>* out) {
return BzipData<BzipBuffToBuffDecompress>(&in[0],
Expand All @@ -103,7 +103,7 @@ bool BzipString(const std::string& str,
out->insert(out->end(), temp.begin(), temp.end());
return true;
}
} // namespace {}
} // namespace

bool BzipCompressString(const std::string& str,
std::vector<char>* out) {
Expand All @@ -115,4 +115,4 @@ bool BzipDecompressString(const std::string& str,
return BzipString<BzipData<BzipBuffToBuffDecompress> >(str, out);
}

} // namespace chromeos_update_engine
} // namespace chromeos_update_engine
6 changes: 3 additions & 3 deletions bzip_extent_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ bool BzipExtentWriter::Init(int fd,
uint32_t block_size) {
// Init bzip2 stream
int rc = BZ2_bzDecompressInit(&stream_,
0, // verbosity. (0 == silent)
0 // 0 = faster algo, more memory
);
0, // verbosity. (0 == silent)
0); // 0 = faster algo, more memory

TEST_AND_RETURN_FALSE(rc == BZ_OK);

return next_->Init(fd, extents, block_size);
Expand Down
2 changes: 1 addition & 1 deletion bzip_extent_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace chromeos_update_engine {

class BzipExtentWriter : public ExtentWriter {
public:
BzipExtentWriter(ExtentWriter* next) : next_(next) {
explicit BzipExtentWriter(ExtentWriter* next) : next_(next) {
memset(&stream_, 0, sizeof(stream_));
}
~BzipExtentWriter() {}
Expand Down
2 changes: 1 addition & 1 deletion certificate_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
static const char* kReportToSendKey[2] =
{kPrefsCertificateReportToSendUpdate,
kPrefsCertificateReportToSendDownload};
} // namespace {}
} // namespace

bool OpenSSLWrapper::GetCertificateDigest(X509_STORE_CTX* x509_ctx,
int* out_depth,
Expand Down
8 changes: 4 additions & 4 deletions certificate_checker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CertificateCheckerTest : public testing::Test {
virtual void TearDown() {}

FakeSystemState fake_system_state_;
PrefsMock* prefs_; // shortcut to fake_system_state_.mock_prefs()
PrefsMock* prefs_; // shortcut to fake_system_state_.mock_prefs()
OpenSSLWrapperMock openssl_wrapper_;
// Parameters of our mock certificate digest.
int depth_;
Expand Down Expand Up @@ -129,8 +129,8 @@ TEST_F(CertificateCheckerTest, FailedCertificate) {
EXPECT_CALL(*prefs_, SetString(kPrefsCertificateReportToSendUpdate,
kCertFailed))
.WillOnce(Return(true));
EXPECT_CALL(*prefs_, GetString(_,_)).Times(0);
EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(_,_,_,_)).Times(0);
EXPECT_CALL(*prefs_, GetString(_, _)).Times(0);
EXPECT_CALL(openssl_wrapper_, GetCertificateDigest(_, _, _, _)).Times(0);
ASSERT_FALSE(CertificateChecker::CheckCertificateChange(
server_to_check_, 0, NULL));
}
Expand Down Expand Up @@ -164,7 +164,7 @@ TEST_F(CertificateCheckerTest, FlushNothingToReport) {
.WillOnce(Return(false));
EXPECT_CALL(*fake_system_state_.mock_metrics_lib(),
SendUserActionToUMA(_)).Times(0);
EXPECT_CALL(*prefs_, SetString(_,_)).Times(0);
EXPECT_CALL(*prefs_, SetString(_, _)).Times(0);
CertificateChecker::FlushReport();
}

Expand Down
5 changes: 3 additions & 2 deletions chrome_browser_proxy_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#include "update_engine/chrome_browser_proxy_resolver.h"

#include <deque>
#include <map>
#include <string>
#include <utility>

#include <base/strings/string_tokenizer.h>
#include <base/strings/string_util.h>
Expand Down Expand Up @@ -48,7 +50,7 @@ namespace {

const int kTimeout = 5; // seconds

} // namespace {}
} // namespace

ChromeBrowserProxyResolver::ChromeBrowserProxyResolver(
DBusWrapperInterface* dbus)
Expand Down Expand Up @@ -123,7 +125,6 @@ bool ChromeBrowserProxyResolver::GetProxiesForUrl(const string& url,
url.c_str(),
kLibCrosProxyResolveSignalInterface,
kLibCrosProxyResolveName)) {

if (error) {
LOG(WARNING) << "dbus_g_proxy_call failed, continuing with no proxy: "
<< utils::GetAndFreeGError(&error);
Expand Down
6 changes: 4 additions & 2 deletions chrome_browser_proxy_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_BROWSER_PROXY_RESOLVER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_CHROME_BROWSER_PROXY_RESOLVER_H_

#include <deque>
#include <map>
#include <string>
#include <utility>

#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
Expand Down Expand Up @@ -60,11 +62,11 @@ class ChromeBrowserProxyResolver : public ProxyResolver {
DBusMessage* message);
// Handle no reply:
void HandleTimeout(std::string source_url);

// Parses a string-encoded list of proxies and returns a deque
// of individual proxies. The last one will always be kNoProxy.
static std::deque<std::string> ParseProxyString(const std::string& input);

// Deletes internal state for the first instance of url in the state.
// If delete_timer is set, calls g_source_destroy on the timer source.
// Returns the callback in an out parameter. Returns true on success.
Expand Down
4 changes: 2 additions & 2 deletions chrome_browser_proxy_resolver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ gboolean SendReply(gpointer data) {
// chrome. If there's no reply, the resolver should time out.
// If chrome_alive is false, assume that sending to chrome fails.
void RunTest(bool chrome_replies, bool chrome_alive) {
long number = 1;
intptr_t number = 1;
DBusGConnection* kMockSystemGBus =
reinterpret_cast<DBusGConnection*>(number++);
DBusConnection* kMockSystemBus =
Expand Down Expand Up @@ -188,7 +188,7 @@ void RunTest(bool chrome_replies, bool chrome_alive) {
g_main_loop_run(loop);
g_main_loop_unref(loop);
}
} // namespace {}
} // namespace

TEST(ChromeBrowserProxyResolverTest, SuccessTest) {
RunTest(true, true);
Expand Down
1 change: 0 additions & 1 deletion clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Clock : public ClockInterface {
virtual base::Time GetBootTime();

private:

DISALLOW_COPY_AND_ASSIGN(Clock);
};

Expand Down
16 changes: 9 additions & 7 deletions connection_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "update_engine/connection_manager.h"

#include <set>
#include <string>

#include <base/stl_util.h>
Expand Down Expand Up @@ -136,8 +137,9 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface,
&hash_table));

// Populate the out_tethering.
GValue* value = (GValue*)g_hash_table_lookup(hash_table,
shill::kTetheringProperty);
GValue* value =
reinterpret_cast<GValue*>(g_hash_table_lookup(hash_table,
shill::kTetheringProperty));
const char* tethering_str = NULL;

if (value != NULL)
Expand All @@ -150,15 +152,15 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface,
}

// Populate the out_type property.
value = (GValue*)g_hash_table_lookup(hash_table,
shill::kTypeProperty);
value = reinterpret_cast<GValue*>(g_hash_table_lookup(hash_table,
shill::kTypeProperty));
const char* type_str = NULL;
bool success = false;
if (value != NULL && (type_str = g_value_get_string(value)) != NULL) {
success = true;
if (!strcmp(type_str, shill::kTypeVPN)) {
value = (GValue*)g_hash_table_lookup(hash_table,
shill::kPhysicalTechnologyProperty);
value = reinterpret_cast<GValue*>(
g_hash_table_lookup(hash_table, shill::kPhysicalTechnologyProperty));
if (value != NULL && (type_str = g_value_get_string(value)) != NULL) {
*out_type = ParseConnectionType(type_str);
} else {
Expand All @@ -175,7 +177,7 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface,
return success;
}

} // namespace {}
} // namespace

ConnectionManager::ConnectionManager(SystemState *system_state)
: system_state_(system_state) {}
Expand Down
4 changes: 3 additions & 1 deletion connection_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <set>
#include <string>

#include <base/logging.h>
#include <chromeos/dbus/service_constants.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>

#include "update_engine/connection_manager.h"
#include "update_engine/fake_system_state.h"
Expand Down
2 changes: 1 addition & 1 deletion constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ const char kPrefsUpdateTimestampStart[] = "update-timestamp-start";
const char kPrefsUrlSwitchCount[] = "url-switch-count";
const char kPrefsWallClockWaitPeriod[] = "wall-clock-wait-period";

}
} // namespace chromeos_update_engine
6 changes: 3 additions & 3 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ extern const char kPrefsWallClockWaitPeriod[];
// interest to us when looking at UMA metrics) using which we may download
// the payload.
typedef enum {
kDownloadSourceHttpsServer, // UMA Binary representation: 0001
kDownloadSourceHttpServer, // UMA Binary representation: 0010
kDownloadSourceHttpPeer, // UMA Binary representation: 0100
kDownloadSourceHttpsServer, // UMA Binary representation: 0001
kDownloadSourceHttpServer, // UMA Binary representation: 0010
kDownloadSourceHttpPeer, // UMA Binary representation: 0100

// Note: Add new sources only above this line.
kNumDownloadSources
Expand Down
20 changes: 9 additions & 11 deletions dbus_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
#define UPDATE_ENGINE_SERVICE_TYPE_ERROR \
(update_engine_service_error_get_type())

typedef enum
{
enum UpdateEngineServiceError {
UPDATE_ENGINE_SERVICE_ERROR_FAILED,
UPDATE_ENGINE_SERVICE_NUM_ERRORS
} UpdateEngineServiceError;
};

static GQuark update_engine_service_error_quark(void) {
static GQuark ret = 0;
Expand All @@ -56,7 +55,7 @@ static GType update_engine_service_error_get_type(void) {
{ 0, 0, 0 }
};
G_STATIC_ASSERT(UPDATE_ENGINE_SERVICE_NUM_ERRORS ==
G_N_ELEMENTS (values) - 1);
G_N_ELEMENTS(values) - 1);
etype = g_enum_register_static("UpdateEngineServiceError", values);
}

Expand Down Expand Up @@ -111,9 +110,9 @@ static void update_engine_service_class_init(UpdateEngineServiceClass* klass) {
}

static void update_engine_service_init(UpdateEngineService* object) {
dbus_g_error_domain_register (UPDATE_ENGINE_SERVICE_ERROR,
"org.chromium.UpdateEngine.Error",
UPDATE_ENGINE_SERVICE_TYPE_ERROR);
dbus_g_error_domain_register(UPDATE_ENGINE_SERVICE_ERROR,
"org.chromium.UpdateEngine.Error",
UPDATE_ENGINE_SERVICE_TYPE_ERROR);
}

UpdateEngineService* update_engine_service_new(void) {
Expand All @@ -128,7 +127,7 @@ gboolean update_engine_service_attempt_update(UpdateEngineService* self,
return update_engine_service_attempt_update_with_flags(self,
app_version,
omaha_url,
0, // No flags set.
0, // No flags set.
error);
}

Expand Down Expand Up @@ -195,8 +194,7 @@ gboolean update_engine_service_attempt_rollback(UpdateEngineService* self,

gboolean update_engine_service_can_rollback(UpdateEngineService* self,
gboolean* out_can_rollback,
GError **error)
{
GError **error) {
bool can_rollback = self->system_state_->update_attempter()->CanRollback();
LOG(INFO) << "Checking to see if we can rollback . Result: " << can_rollback;
*out_can_rollback = can_rollback;
Expand All @@ -218,7 +216,7 @@ gboolean update_engine_service_get_kernel_devices(UpdateEngineService* self,
GError **error) {
auto devices = self->system_state_->update_attempter()->GetKernelDevices();
std::string info;
for (auto&& device : devices) {
for (const auto& device : devices) {
base::StringAppendF(&info, "%d:%s\n",
device.second ? 1 : 0, device.first.c_str());
}
Expand Down
Loading

0 comments on commit d2779df

Please sign in to comment.