summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--action.h8
-rw-r--r--action_mock.h2
-rw-r--r--action_pipe.h1
-rw-r--r--action_processor_unittest.cc2
-rw-r--r--bzip.cc12
-rw-r--r--bzip_extent_writer.cc6
-rw-r--r--bzip_extent_writer.h2
-rw-r--r--certificate_checker.cc2
-rw-r--r--certificate_checker_unittest.cc8
-rw-r--r--chrome_browser_proxy_resolver.cc5
-rw-r--r--chrome_browser_proxy_resolver.h6
-rw-r--r--chrome_browser_proxy_resolver_unittest.cc4
-rw-r--r--clock.h1
-rw-r--r--connection_manager.cc16
-rw-r--r--connection_manager_unittest.cc4
-rw-r--r--constants.cc2
-rw-r--r--constants.h6
-rw-r--r--dbus_service.cc20
-rw-r--r--dbus_wrapper_interface.h4
-rw-r--r--delta_performer.cc4
-rw-r--r--delta_performer.h1
-rw-r--r--delta_performer_unittest.cc21
-rw-r--r--download_action.cc18
-rw-r--r--download_action.h2
-rw-r--r--download_action_unittest.cc26
-rw-r--r--error_code.h2
-rw-r--r--extent_ranges.cc5
-rw-r--r--extent_ranges_unittest.cc2
-rw-r--r--extent_writer.h2
-rw-r--r--fake_p2p_manager.h6
-rw-r--r--fake_p2p_manager_configuration.h9
-rw-r--r--fake_prefs.cc4
-rw-r--r--file_descriptor.h2
-rw-r--r--filesystem_copier_action.cc2
-rw-r--r--filesystem_copier_action_unittest.cc3
-rw-r--r--http_common.cc2
-rw-r--r--http_fetcher_unittest.cc37
-rw-r--r--install_plan.h4
-rw-r--r--libcurl_http_fetcher.cc4
-rw-r--r--libcurl_http_fetcher.h3
-rw-r--r--main.cc8
-rw-r--r--mock_connection_manager.h2
-rw-r--r--mock_file_writer.h3
-rw-r--r--mock_http_fetcher.cc1
-rw-r--r--mock_http_fetcher.h1
-rw-r--r--mock_p2p_manager.h6
-rw-r--r--mock_payload_state.h2
-rw-r--r--multi_range_http_fetcher.cc5
-rw-r--r--multi_range_http_fetcher.h3
-rw-r--r--omaha_hash_calculator.cc10
-rw-r--r--omaha_hash_calculator_unittest.cc2
-rw-r--r--omaha_request_action.cc17
-rw-r--r--omaha_request_action.h2
-rw-r--r--omaha_request_action_unittest.cc400
-rw-r--r--omaha_request_params.cc8
-rw-r--r--omaha_request_params.h4
-rw-r--r--omaha_request_params_unittest.cc2
-rw-r--r--omaha_response_handler_action_unittest.cc8
-rw-r--r--p2p_manager.cc48
-rw-r--r--p2p_manager.h4
-rw-r--r--p2p_manager_unittest.cc10
-rw-r--r--payload_generator/cycle_breaker_unittest.cc4
-rw-r--r--payload_generator/delta_diff_generator.cc8
-rw-r--r--payload_generator/delta_diff_generator_unittest.cc4
-rw-r--r--payload_generator/full_update_generator_unittest.cc2
-rw-r--r--payload_generator/generate_delta_main.cc2
-rw-r--r--payload_generator/graph_utils.cc2
-rw-r--r--payload_generator/metadata.cc2
-rw-r--r--payload_generator/metadata_unittest.cc4
-rw-r--r--payload_generator/topological_sort.cc2
-rw-r--r--payload_generator/topological_sort_unittest.cc2
-rw-r--r--payload_signer.cc3
-rw-r--r--payload_signer_unittest.cc4
-rw-r--r--payload_state.cc29
-rw-r--r--payload_state.h3
-rw-r--r--payload_state_unittest.cc30
-rw-r--r--postinstall_runner_action.cc2
-rw-r--r--postinstall_runner_action.h2
-rw-r--r--prefs.h2
-rw-r--r--prefs_mock.h2
-rw-r--r--subprocess.cc4
-rw-r--r--subprocess_unittest.cc7
-rw-r--r--terminator_unittest.cc3
-rw-r--r--test_http_server.cc16
-rw-r--r--test_utils.cc2
-rw-r--r--test_utils.h6
-rw-r--r--update_attempter.cc16
-rw-r--r--update_attempter.h1
-rw-r--r--update_attempter_mock.h2
-rw-r--r--update_attempter_unittest.cc10
-rw-r--r--update_check_scheduler_unittest.cc2
-rw-r--r--update_engine_client.cc17
-rw-r--r--utils.cc37
-rw-r--r--utils.h15
-rw-r--r--utils_unittest.cc18
95 files changed, 541 insertions, 540 deletions
diff --git a/action.h b/action.h
index 27a22976..ce59158d 100644
--- a/action.h
+++ b/action.h
@@ -7,8 +7,8 @@
#include <stdio.h>
-#include <iostream>
#include <memory>
+#include <string>
#include <base/basictypes.h>
#include <base/logging.h>
@@ -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.
@@ -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?
diff --git a/action_mock.h b/action_mock.h
index 07f435e2..505fbf57 100644
--- a/action_mock.h
+++ b/action_mock.h
@@ -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"
diff --git a/action_pipe.h b/action_pipe.h
index 99f98cfe..3361ccd0 100644
--- a/action_pipe.h
+++ b/action_pipe.h
@@ -7,7 +7,6 @@
#include <stdio.h>
-#include <iostream>
#include <map>
#include <memory>
#include <string>
diff --git a/action_processor_unittest.cc b/action_processor_unittest.cc
index a55f0d39..78968ef3 100644
--- a/action_processor_unittest.cc
+++ b/action_processor_unittest.cc
@@ -94,7 +94,7 @@ class MyActionProcessorDelegate : public ActionProcessorDelegate {
bool action_completed_called_;
ErrorCode action_exit_code_;
};
-} // namespace {}
+} // namespace
TEST(ActionProcessorTest, DelegateTest) {
ActionProcessorTestAction action;
diff --git a/bzip.cc b/bzip.cc
index 833d2735..eb1655c0 100644
--- a/bzip.cc
+++ b/bzip.cc
@@ -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.
@@ -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);
@@ -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],
@@ -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) {
@@ -115,4 +115,4 @@ bool BzipDecompressString(const std::string& str,
return BzipString<BzipData<BzipBuffToBuffDecompress> >(str, out);
}
-} // namespace chromeos_update_engine
+} // namespace chromeos_update_engine
diff --git a/bzip_extent_writer.cc b/bzip_extent_writer.cc
index b4f864fa..008e64ab 100644
--- a/bzip_extent_writer.cc
+++ b/bzip_extent_writer.cc
@@ -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);
diff --git a/bzip_extent_writer.h b/bzip_extent_writer.h
index cf9f2cb2..f3121a90 100644
--- a/bzip_extent_writer.h
+++ b/bzip_extent_writer.h
@@ -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() {}
diff --git a/certificate_checker.cc b/certificate_checker.cc
index 02b56612..a774900b 100644
--- a/certificate_checker.cc
+++ b/certificate_checker.cc
@@ -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,
diff --git a/certificate_checker_unittest.cc b/certificate_checker_unittest.cc
index 44c2d74d..4469c0ff 100644
--- a/certificate_checker_unittest.cc
+++ b/certificate_checker_unittest.cc
@@ -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_;
@@ -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));
}
@@ -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();
}
diff --git a/chrome_browser_proxy_resolver.cc b/chrome_browser_proxy_resolver.cc
index 4f7b8bd6..fbeb71fa 100644
--- a/chrome_browser_proxy_resolver.cc
+++ b/chrome_browser_proxy_resolver.cc
@@ -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>
@@ -48,7 +50,7 @@ namespace {
const int kTimeout = 5; // seconds
-} // namespace {}
+} // namespace
ChromeBrowserProxyResolver::ChromeBrowserProxyResolver(
DBusWrapperInterface* dbus)
@@ -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);
diff --git a/chrome_browser_proxy_resolver.h b/chrome_browser_proxy_resolver.h
index 6ec88a2b..48a10498 100644
--- a/chrome_browser_proxy_resolver.h
+++ b/chrome_browser_proxy_resolver.h
@@ -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>
@@ -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.
diff --git a/chrome_browser_proxy_resolver_unittest.cc b/chrome_browser_proxy_resolver_unittest.cc
index 9fa168e9..557fc2e2 100644
--- a/chrome_browser_proxy_resolver_unittest.cc
+++ b/chrome_browser_proxy_resolver_unittest.cc
@@ -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 =
@@ -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);
diff --git a/clock.h b/clock.h
index 7d989d09..95eeda98 100644
--- a/clock.h
+++ b/clock.h
@@ -21,7 +21,6 @@ class Clock : public ClockInterface {
virtual base::Time GetBootTime();
private:
-
DISALLOW_COPY_AND_ASSIGN(Clock);
};
diff --git a/connection_manager.cc b/connection_manager.cc
index 9e3ac1ef..b5daa141 100644
--- a/connection_manager.cc
+++ b/connection_manager.cc
@@ -4,6 +4,7 @@
#include "update_engine/connection_manager.h"
+#include <set>
#include <string>
#include <base/stl_util.h>
@@ -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)
@@ -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 {
@@ -175,7 +177,7 @@ bool GetServicePathProperties(DBusWrapperInterface* dbus_iface,
return success;
}
-} // namespace {}
+} // namespace
ConnectionManager::ConnectionManager(SystemState *system_state)
: system_state_(system_state) {}
diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc
index c495fbfb..ca6e2569 100644
--- a/connection_manager_unittest.cc
+++ b/connection_manager_unittest.cc
@@ -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"
diff --git a/constants.cc b/constants.cc
index eec91449..b68bd04c 100644
--- a/constants.cc
+++ b/constants.cc
@@ -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
diff --git a/constants.h b/constants.h
index 3a741569..826c5ff9 100644
--- a/constants.h
+++ b/constants.h
@@ -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
diff --git a/dbus_service.cc b/dbus_service.cc
index 230e6d5f..a8e1dcd5 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -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;
@@ -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);
}
@@ -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) {
@@ -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);
}
@@ -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;
@@ -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());
}
diff --git a/dbus_wrapper_interface.h b/dbus_wrapper_interface.h
index 51a268bb..360657d1 100644
--- a/dbus_wrapper_interface.h
+++ b/dbus_wrapper_interface.h
@@ -12,12 +12,12 @@
#ifndef DBUS_TYPE_G_OBJECT_PATH_ARRAY
#define DBUS_TYPE_G_OBJECT_PATH_ARRAY \
- (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
+ (dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
#endif
#ifndef DBUS_TYPE_G_STRING_ARRAY
#define DBUS_TYPE_G_STRING_ARRAY \
- (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
+ (dbus_g_type_get_collection("GPtrArray", G_TYPE_STRING))
#endif
namespace chromeos_update_engine {
diff --git a/delta_performer.cc b/delta_performer.cc
index ef66af06..20085361 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -73,7 +73,7 @@ bool OpenFile(const char* path, int* fd, int* err) {
return true;
}
-} // namespace {}
+} // namespace
// Computes the ratio of |part| and |total|, scaled to |norm|, using integer
@@ -278,7 +278,7 @@ void LogPartitionInfo(const DeltaArchiveManifest& manifest) {
LogPartitionInfoHash(manifest.new_rootfs_info(), "new_rootfs_info");
}
-} // namespace {}
+} // namespace
uint64_t DeltaPerformer::GetVersionOffset() {
// Manifest size is stored right after the magic string and the version.
diff --git a/delta_performer.h b/delta_performer.h
index 8fffffb2..15c8af3e 100644
--- a/delta_performer.h
+++ b/delta_performer.h
@@ -7,6 +7,7 @@
#include <inttypes.h>
+#include <string>
#include <vector>
#include <base/time/time.h>
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index a063fa2d..8d4eacdf 100644
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -51,7 +51,7 @@ static const char* kBogusMetadataSignature1 =
"fjoTeLYZpt+WN65Vu7jJ0cQN8e1y+2yka5112wpRf/LLtPgiAjEZnsoYpLUd7CoV"
"pLRtClp97kN2+tXGNBQqkA==";
-static const int kDefaultKernelSize = 4096; // Something small for a test
+static const int kDefaultKernelSize = 4096; // Something small for a test
static const char* kNewDataString = "This is new data.";
namespace {
@@ -82,7 +82,7 @@ enum SignatureTest {
kSignatureGenerator, // Sign the payload at generation time.
kSignatureGenerated, // Sign the payload after it's generated.
kSignatureGeneratedPlaceholder, // Insert placeholder signatures, then real.
- kSignatureGeneratedPlaceholderMismatch, // Insert a wrong sized placeholder.
+ kSignatureGeneratedPlaceholderMismatch, // Insert a wrong sized placeholder.
kSignatureGeneratedShell, // Sign the generated payload through shell cmds.
kSignatureGeneratedShellBadKey, // Sign with a bad key through shell cmds.
kSignatureGeneratedShellRotateCl1, // Rotate key, test client v1
@@ -103,7 +103,7 @@ enum OperationHashTest {
kValidOperationData,
};
-} // namespace {}
+} // namespace
static void CompareFilesByBlock(const string& a_file, const string& b_file) {
vector<char> a_data, b_data;
@@ -438,7 +438,7 @@ static void GenerateDeltaFile(bool full_kernel,
FillWithData(&state->new_kernel_data);
// change the new kernel data
- strcpy(&state->new_kernel_data[0], kNewDataString);
+ strcpy(&state->new_kernel_data[0], kNewDataString); // NOLINT(runtime/printf)
if (noop) {
state->old_kernel_data = state->new_kernel_data;
@@ -481,7 +481,6 @@ static void GenerateDeltaFile(bool full_kernel,
if (signature_test == kSignatureGeneratedPlaceholder ||
signature_test == kSignatureGeneratedPlaceholderMismatch) {
-
int signature_size = GetSignatureSize(kUnittestPrivateKeyPath);
LOG(INFO) << "Inserting placeholder signature.";
ASSERT_TRUE(InsertSignaturePlaceholder(signature_size, state->delta_path,
@@ -547,7 +546,7 @@ static void ApplyDeltaFile(bool full_kernel, bool full_rootfs, bool noop,
EXPECT_EQ(1, signature.version());
uint64_t expected_sig_data_length = 0;
- vector<string> key_paths (1, kUnittestPrivateKeyPath);
+ vector<string> key_paths{kUnittestPrivateKeyPath};
if (signature_test == kSignatureGeneratedShellRotateCl1 ||
signature_test == kSignatureGeneratedShellRotateCl2) {
key_paths.push_back(kUnittestPrivateKey2Path);
@@ -580,7 +579,6 @@ static void ApplyDeltaFile(bool full_kernel, bool full_rootfs, bool noop,
EXPECT_EQ(manifest.new_image_info().build_version(), "test-build-version");
if (!full_rootfs) {
-
if (noop) {
EXPECT_EQ(manifest.old_image_info().channel(), "test-channel");
EXPECT_EQ(manifest.old_image_info().board(), "test-board");
@@ -672,7 +670,7 @@ static void ApplyDeltaFile(bool full_kernel, bool full_rootfs, bool noop,
ErrorCode expected_error, actual_error;
bool continue_writing;
- switch(op_hash_test) {
+ switch (op_hash_test) {
case kInvalidOperationData: {
// Muck with some random offset post the metadata size so that
// some operation hash will result in a mismatch.
@@ -964,10 +962,9 @@ void DoOperationHashMismatchTest(OperationHashTest op_hash_test,
class DeltaPerformerTest : public ::testing::Test {
-
public:
// Test helper placed where it can easily be friended from DeltaPerformer.
- static void RunManifestValidation(DeltaArchiveManifest& manifest,
+ static void RunManifestValidation(const DeltaArchiveManifest& manifest,
bool full_payload,
ErrorCode expected) {
PrefsMock prefs;
@@ -1287,7 +1284,7 @@ TEST(DeltaPerformerTest, UsePublicKeyFromResponse) {
// Non-official build, non-existing public-key, key in response -> true
fake_hardware->SetIsOfficialBuild(false);
performer->public_key_path_ = non_existing_file;
- install_plan.public_key_rsa = "VGVzdAo="; // result of 'echo "Test" | base64'
+ install_plan.public_key_rsa = "VGVzdAo="; // result of 'echo "Test" | base64'
EXPECT_TRUE(performer->GetPublicKeyFromResponse(&key_path));
EXPECT_FALSE(key_path.empty());
EXPECT_EQ(unlink(key_path.value().c_str()), 0);
@@ -1298,7 +1295,7 @@ TEST(DeltaPerformerTest, UsePublicKeyFromResponse) {
// Non-official build, existing public-key, key in response -> false
fake_hardware->SetIsOfficialBuild(false);
performer->public_key_path_ = existing_file;
- install_plan.public_key_rsa = "VGVzdAo="; // result of 'echo "Test" | base64'
+ install_plan.public_key_rsa = "VGVzdAo="; // result of 'echo "Test" | base64'
EXPECT_FALSE(performer->GetPublicKeyFromResponse(&key_path));
// Same with official build -> false
fake_hardware->SetIsOfficialBuild(true);
diff --git a/download_action.cc b/download_action.cc
index 6f4811aa..0d4354b6 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -68,7 +68,7 @@ bool DownloadAction::SetupP2PSharingFd() {
if (!p2p_manager->FileShare(p2p_file_id_, install_plan_.payload_size)) {
LOG(ERROR) << "Unable to share file via p2p";
- CloseP2PSharingFd(true); // delete p2p file
+ CloseP2PSharingFd(true); // delete p2p file
return false;
}
@@ -78,7 +78,7 @@ bool DownloadAction::SetupP2PSharingFd() {
p2p_sharing_fd_ = open(path.value().c_str(), O_WRONLY);
if (p2p_sharing_fd_ == -1) {
PLOG(ERROR) << "Error opening file " << path.value();
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
return false;
}
@@ -89,7 +89,7 @@ bool DownloadAction::SetupP2PSharingFd() {
// the process-wide umask is set to 0700 in main.cc.)
if (fchmod(p2p_sharing_fd_, 0644) != 0) {
PLOG(ERROR) << "Error setting mode 0644 on " << path.value();
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
return false;
}
@@ -120,14 +120,14 @@ void DownloadAction::WriteToP2PFile(const char *data,
struct stat statbuf;
if (fstat(p2p_sharing_fd_, &statbuf) != 0) {
PLOG(ERROR) << "Error getting file status for p2p file";
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
return;
}
if (statbuf.st_size < file_offset) {
LOG(ERROR) << "Wanting to write to file offset " << file_offset
<< " but existing p2p file is only " << statbuf.st_size
<< " bytes.";
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
return;
}
@@ -135,7 +135,7 @@ void DownloadAction::WriteToP2PFile(const char *data,
if (cur_file_offset != static_cast<off_t>(file_offset)) {
PLOG(ERROR) << "Error seeking to position "
<< file_offset << " in p2p file";
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
} else {
// OK, seeking worked, now write the data
ssize_t bytes_written = write(p2p_sharing_fd_, data, length);
@@ -143,7 +143,7 @@ void DownloadAction::WriteToP2PFile(const char *data,
PLOG(ERROR) << "Error writing "
<< length << " bytes at file offset "
<< file_offset << " in p2p file";
- CloseP2PSharingFd(true); // Delete p2p file.
+ CloseP2PSharingFd(true); // Delete p2p file.
}
}
}
@@ -238,7 +238,7 @@ void DownloadAction::TerminateProcessing() {
if (delegate_) {
delegate_->SetDownloadStatus(false); // Set to inactive.
}
- CloseP2PSharingFd(false); // Keep p2p file.
+ CloseP2PSharingFd(false); // Keep p2p file.
// Terminates the transfer. The action is terminated, if necessary, when the
// TransferTerminated callback is received.
http_fetcher_->TerminateTransfer();
@@ -323,4 +323,4 @@ void DownloadAction::TransferTerminated(HttpFetcher *fetcher) {
}
}
-}; // namespace {}
+} // namespace chromeos_update_engine
diff --git a/download_action.h b/download_action.h
index f77f6bc3..d2f20047 100644
--- a/download_action.h
+++ b/download_action.h
@@ -83,7 +83,7 @@ class DownloadAction : public InstallPlanAction,
// Returns the p2p file id for the file being written or the empty
// string if we're not writing to a p2p file.
- std::string p2p_file_id() { return p2p_file_id_; };
+ std::string p2p_file_id() { return p2p_file_id_; }
private:
// Closes the file descriptor for the p2p file being written and
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 7bf25309..e0617824 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -191,7 +191,7 @@ void TestWithData(const vector<char>& data,
g_main_loop_run(loop);
g_main_loop_unref(loop);
}
-} // namespace {}
+} // namespace
TEST(DownloadActionTest, SimpleTest) {
vector<char> small;
@@ -301,7 +301,7 @@ void TestTerminateEarly(bool use_download_delegate) {
EXPECT_EQ(kMockHttpFetcherChunkSize, resulting_file_size);
}
-} // namespace {}
+} // namespace
TEST(DownloadActionTest, TerminateEarlyTest) {
TestTerminateEarly(true);
@@ -359,7 +359,7 @@ gboolean PassObjectOutTestStarter(gpointer data) {
processor->StartProcessing();
return FALSE;
}
-}
+} // namespace
TEST(DownloadActionTest, PassObjectOutTest) {
GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -438,7 +438,7 @@ gboolean StartProcessorInRunLoopForP2P(gpointer user_data) {
// Test fixture for P2P tests.
class P2PDownloadActionTest : public testing::Test {
-protected:
+ protected:
P2PDownloadActionTest()
: loop_(NULL),
start_at_offset_(0) {}
@@ -532,7 +532,7 @@ protected:
// The data being downloaded.
string data_;
-private:
+ private:
// Callback used in StartDownload() method.
static gboolean StartProcessorInRunLoopForP2P(gpointer user_data) {
class P2PDownloadActionTest *test =
@@ -556,8 +556,8 @@ TEST_F(P2PDownloadActionTest, IsWrittenTo) {
return;
}
- SetupDownload(0); // starting_offset
- StartDownload(true); // use_p2p_to_share
+ SetupDownload(0); // starting_offset
+ StartDownload(true); // use_p2p_to_share
// Check the p2p file and its content matches what was sent.
string file_id = download_action_->p2p_file_id();
@@ -577,8 +577,8 @@ TEST_F(P2PDownloadActionTest, DeleteIfHoleExists) {
return;
}
- SetupDownload(1000); // starting_offset
- StartDownload(true); // use_p2p_to_share
+ SetupDownload(1000); // starting_offset
+ StartDownload(true); // use_p2p_to_share
// DownloadAction should convey that the file is not being shared.
// and that we don't have any p2p files.
@@ -593,7 +593,7 @@ TEST_F(P2PDownloadActionTest, CanAppend) {
return;
}
- SetupDownload(1000); // starting_offset
+ SetupDownload(1000); // starting_offset
// Prepare the file with existing data before starting to write to
// it via DownloadAction.
@@ -605,7 +605,7 @@ TEST_F(P2PDownloadActionTest, CanAppend) {
ASSERT_EQ(WriteFile(p2p_manager_->FileGetPath(file_id), existing_data.c_str(),
1000), 1000);
- StartDownload(true); // use_p2p_to_share
+ StartDownload(true); // use_p2p_to_share
// DownloadAction should convey the same file_id and the file should
// have the expected size.
@@ -628,7 +628,7 @@ TEST_F(P2PDownloadActionTest, DeletePartialP2PFileIfResumingWithoutP2P) {
return;
}
- SetupDownload(1000); // starting_offset
+ SetupDownload(1000); // starting_offset
// Prepare the file with all existing data before starting to write
// to it via DownloadAction.
@@ -644,7 +644,7 @@ TEST_F(P2PDownloadActionTest, DeletePartialP2PFileIfResumingWithoutP2P) {
EXPECT_EQ(p2p_manager_->FileGetSize(file_id), 1000);
EXPECT_EQ(p2p_manager_->CountSharedFiles(), 1);
- StartDownload(false); // use_p2p_to_share
+ StartDownload(false); // use_p2p_to_share
// DownloadAction should have deleted the p2p file. Check that it's gone.
EXPECT_EQ(p2p_manager_->FileGetSize(file_id), -1);
diff --git a/error_code.h b/error_code.h
index 5f3a2cb2..a9bfc2db 100644
--- a/error_code.h
+++ b/error_code.h
@@ -5,7 +5,7 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
-#include <ostream>
+#include <ostream> // NOLINT(readability/streams)
namespace chromeos_update_engine {
diff --git a/extent_ranges.cc b/extent_ranges.cc
index 1089de11..7cdce41a 100644
--- a/extent_ranges.cc
+++ b/extent_ranges.cc
@@ -4,6 +4,7 @@
#include "update_engine/extent_ranges.h"
+#include <algorithm>
#include <set>
#include <utility>
#include <vector>
@@ -62,7 +63,7 @@ Extent UnionOverlappingExtents(const Extent& first, const Extent& second) {
return ExtentForRange(start, end - start);
}
-} // namespace {}
+} // namespace
void ExtentRanges::AddExtent(Extent extent) {
if (extent.start_block() == kSparseHole || extent.num_blocks() == 0)
@@ -105,7 +106,7 @@ ExtentRanges::ExtentSet SubtractOverlappingExtents(const Extent& base,
}
return ret;
}
-} // namespace {}
+} // namespace
void ExtentRanges::SubtractExtent(const Extent& extent) {
if (extent.start_block() == kSparseHole || extent.num_blocks() == 0)
diff --git a/extent_ranges_unittest.cc b/extent_ranges_unittest.cc
index ba00d0de..11b17edf 100644
--- a/extent_ranges_unittest.cc
+++ b/extent_ranges_unittest.cc
@@ -106,7 +106,7 @@ void ExpectFalseRangesOverlap(uint64_t a_start, uint64_t a_num,
a_num)));
}
-} // namespace {}
+} // namespace
TEST(ExtentRangesTest, ExtentsOverlapTest) {
ExpectRangesOverlapOrTouch(10, 20, 30, 10);
diff --git a/extent_writer.h b/extent_writer.h
index 1b38ae66..7f319799 100644
--- a/extent_writer.h
+++ b/extent_writer.h
@@ -82,7 +82,7 @@ class DirectExtentWriter : public ExtentWriter {
class ZeroPadExtentWriter : public ExtentWriter {
public:
- ZeroPadExtentWriter(ExtentWriter* underlying_extent_writer)
+ explicit ZeroPadExtentWriter(ExtentWriter* underlying_extent_writer)
: underlying_extent_writer_(underlying_extent_writer),
block_size_(0),
bytes_written_mod_block_size_(0) {}
diff --git a/fake_p2p_manager.h b/fake_p2p_manager.h
index 50de8d69..cbc063e3 100644
--- a/fake_p2p_manager.h
+++ b/fake_p2p_manager.h
@@ -5,13 +5,15 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_P2P_MANAGER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_P2P_MANAGER_H_
+#include <string>
+
#include "update_engine/p2p_manager.h"
namespace chromeos_update_engine {
// A fake implementation of P2PManager.
class FakeP2PManager : public P2PManager {
-public:
+ public:
FakeP2PManager() :
is_p2p_enabled_(false),
ensure_p2p_running_result_(false),
@@ -102,7 +104,7 @@ public:
lookup_url_for_file_result_ = url;
}
-private:
+ private:
bool is_p2p_enabled_;
bool ensure_p2p_running_result_;
bool ensure_p2p_not_running_result_;
diff --git a/fake_p2p_manager_configuration.h b/fake_p2p_manager_configuration.h
index 52c9248c..58a740e2 100644
--- a/fake_p2p_manager_configuration.h
+++ b/fake_p2p_manager_configuration.h
@@ -8,6 +8,9 @@
#include "update_engine/p2p_manager.h"
#include "update_engine/utils.h"
+#include <string>
+#include <vector>
+
#include <glib.h>
#include <base/logging.h>
@@ -18,7 +21,7 @@ namespace chromeos_update_engine {
// Configuration for P2PManager for use in unit tests. Instead of
// /var/cache/p2p, a temporary directory is used.
class FakeP2PManagerConfiguration : public P2PManager::Configuration {
-public:
+ public:
FakeP2PManagerConfiguration()
: p2p_client_cmdline_format_("p2p-client --get-url=%s --minimum-size=%zu") {
EXPECT_TRUE(utils::MakeTempDirectory("/tmp/p2p-tc.XXXXXX", &p2p_dir_));
@@ -35,7 +38,7 @@ public:
// P2PManager::Configuration override
virtual base::FilePath GetP2PDir() {
return base::FilePath(p2p_dir_);
- };
+ }
// P2PManager::Configuration override
virtual std::vector<std::string> GetInitctlArgs(bool is_start) {
@@ -75,7 +78,7 @@ public:
p2p_client_cmdline_format_ = command_line_format;
}
-private:
+ private:
// Helper for parsing and splitting |command_line| into an argument
// vector in much the same way a shell would except for not
// supporting wildcards, globs, operators etc. See
diff --git a/fake_prefs.cc b/fake_prefs.cc
index 1df4e30e..e26b8655 100644
--- a/fake_prefs.cc
+++ b/fake_prefs.cc
@@ -27,8 +27,8 @@ template<>
FakePrefs::PrefType const FakePrefs::PrefConsts<string>::type =
FakePrefs::PrefType::kString;
template<>
-string FakePrefs::PrefValue::* const FakePrefs::PrefConsts<string>::member =
- &FakePrefs::PrefValue::as_str;
+string FakePrefs::PrefValue::* const // NOLINT(runtime/string), not static str.
+ FakePrefs::PrefConsts<string>::member = &FakePrefs::PrefValue::as_str;
template<>
FakePrefs::PrefType const FakePrefs::PrefConsts<int64_t>::type =
diff --git a/file_descriptor.h b/file_descriptor.h
index 8a31180b..391a6508 100644
--- a/file_descriptor.h
+++ b/file_descriptor.h
@@ -82,7 +82,7 @@ class FileDescriptor {
class EintrSafeFileDescriptor : public FileDescriptor {
public:
EintrSafeFileDescriptor() : fd_(-1) {}
- virtual ~EintrSafeFileDescriptor() {};
+ virtual ~EintrSafeFileDescriptor() {}
// Interface methods.
virtual bool Open(const char* path, int flags, mode_t mode);
diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc
index 4bfde99e..23d3b0eb 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -34,7 +34,7 @@ namespace chromeos_update_engine {
namespace {
const off_t kCopyFileBufferSize = 128 * 1024;
-} // namespace {}
+} // namespace
FilesystemCopierAction::FilesystemCopierAction(
SystemState* system_state,
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index 3e5f1b93..4d67b5e2 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -78,6 +78,7 @@ class FilesystemCopierActionTestDelegate : public ActionProcessorDelegate {
}
bool ran() const { return ran_; }
ErrorCode code() const { return code_; }
+
private:
GMainLoop* loop_;
FilesystemCopierAction* action_;
@@ -420,7 +421,7 @@ TEST_F(FilesystemCopierActionTest, RunAsRootDetermineFilesystemSizeTest) {
EXPECT_EQ(kint64max, action.filesystem_size_);
{
int fd = HANDLE_EINTR(open(img.c_str(), O_RDONLY));
- EXPECT_TRUE(fd > 0);
+ EXPECT_GT(fd, 0);
ScopedFdCloser fd_closer(&fd);
action.DetermineFilesystemSize(fd);
}
diff --git a/http_common.cc b/http_common.cc
index c2306203..a3bd7f8a 100644
--- a/http_common.cc
+++ b/http_common.cc
@@ -71,4 +71,4 @@ const char *GetHttpContentTypeString(HttpContentType type) {
return (is_found ? http_content_type_table[i].str : NULL);
}
-} // namespace chromeos_update_engine
+} // namespace chromeos_update_engine
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index b2848f3f..3879bc45 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -128,7 +128,8 @@ class PythonHttpServer : public HttpServer {
CHECK_EQ(strstr(line, kServerListeningMsgPrefix), line);
const char* listening_port_str = line + listening_msg_prefix_len;
char* end_ptr;
- long raw_port = strtol(listening_port_str, &end_ptr, 10);
+ long raw_port = strtol(listening_port_str, // NOLINT(runtime/int)
+ &end_ptr, 10);
CHECK(!*end_ptr || *end_ptr == '\n');
port_ = static_cast<in_port_t>(raw_port);
CHECK_GT(port_, 0);
@@ -228,7 +229,7 @@ class MockHttpFetcherTest : public AnyHttpFetcherTest {
using AnyHttpFetcherTest::NewLargeFetcher;
virtual HttpFetcher* NewLargeFetcher(size_t num_proxies) {
vector<char> big_data(1000000);
- CHECK(num_proxies > 0);
+ CHECK_GT(num_proxies, 0u);
proxy_resolver_.set_num_proxies(num_proxies);
return new MockHttpFetcher(
big_data.data(),
@@ -239,7 +240,7 @@ class MockHttpFetcherTest : public AnyHttpFetcherTest {
// Necessary to unhide the definition in the base class.
using AnyHttpFetcherTest::NewSmallFetcher;
virtual HttpFetcher* NewSmallFetcher(size_t num_proxies) {
- CHECK(num_proxies > 0);
+ CHECK_GT(num_proxies, 0u);
proxy_resolver_.set_num_proxies(num_proxies);
return new MockHttpFetcher(
"x",
@@ -260,7 +261,7 @@ class LibcurlHttpFetcherTest : public AnyHttpFetcherTest {
// Necessary to unhide the definition in the base class.
using AnyHttpFetcherTest::NewLargeFetcher;
virtual HttpFetcher* NewLargeFetcher(size_t num_proxies) {
- CHECK(num_proxies > 0);
+ CHECK_GT(num_proxies, 0u);
proxy_resolver_.set_num_proxies(num_proxies);
LibcurlHttpFetcher *ret = new
LibcurlHttpFetcher(reinterpret_cast<ProxyResolver*>(&proxy_resolver_),
@@ -307,7 +308,7 @@ class MultiRangeHttpFetcherTest : public LibcurlHttpFetcherTest {
// Necessary to unhide the definition in the base class.
using AnyHttpFetcherTest::NewLargeFetcher;
virtual HttpFetcher* NewLargeFetcher(size_t num_proxies) {
- CHECK(num_proxies > 0);
+ CHECK_GT(num_proxies, 0u);
proxy_resolver_.set_num_proxies(num_proxies);
ProxyResolver* resolver =
reinterpret_cast<ProxyResolver*>(&proxy_resolver_);
@@ -349,7 +350,7 @@ class HttpFetcherTest : public ::testing::Test {
private:
static void TypeConstraint(T *a) {
AnyHttpFetcherTest *b = a;
- if (b == 0) // Silence compiler warning of unused variable.
+ if (b == 0) // Silence compiler warning of unused variable.
*b = a;
}
};
@@ -411,7 +412,7 @@ gboolean StartTransfer(gpointer data) {
args->http_fetcher->BeginTransfer(args->url);
return FALSE;
}
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, SimpleTest) {
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -524,7 +525,7 @@ gboolean UnpausingTimeoutCallback(gpointer data) {
delegate->Unpause();
return TRUE;
}
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, PauseTest) {
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -592,7 +593,7 @@ gboolean AbortingTimeoutCallback(gpointer data) {
return FALSE;
}
}
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, AbortTest) {
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -641,7 +642,7 @@ class FlakyHttpFetcherTestDelegate : public HttpFetcherDelegate {
string data;
GMainLoop* loop_;
};
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, FlakyTest) {
if (this->test_.IsMock())
@@ -684,7 +685,7 @@ namespace {
// the server dies.
class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
- FailureHttpFetcherTestDelegate(PythonHttpServer* server)
+ explicit FailureHttpFetcherTestDelegate(PythonHttpServer* server)
: loop_(NULL),
server_(server) {}
@@ -716,7 +717,7 @@ class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate {
GMainLoop* loop_;
PythonHttpServer* server_;
};
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, FailureTest) {
@@ -786,7 +787,7 @@ const HttpResponseCode kRedirectCodes[] = {
class RedirectHttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
- RedirectHttpFetcherTestDelegate(bool expected_successful)
+ explicit RedirectHttpFetcherTestDelegate(bool expected_successful)
: expected_successful_(expected_successful) {}
virtual void ReceivedBytes(HttpFetcher* fetcher,
const char* bytes, int length) {
@@ -794,9 +795,9 @@ class RedirectHttpFetcherTestDelegate : public HttpFetcherDelegate {
}
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
EXPECT_EQ(expected_successful_, successful);
- if (expected_successful_)
+ if (expected_successful_) {
EXPECT_EQ(kHttpResponseOk, fetcher->http_response_code());
- else {
+ } else {
EXPECT_GE(fetcher->http_response_code(), kHttpResponseMovedPermanently);
EXPECT_LE(fetcher->http_response_code(), kHttpResponseTempRedirect);
}
@@ -838,7 +839,7 @@ void RedirectTest(const HttpServer* server,
}
g_main_loop_unref(loop);
}
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, SimpleRedirectTest) {
if (this->test_.IsMock())
@@ -890,7 +891,7 @@ TYPED_TEST(HttpFetcherTest, BeyondMaxRedirectTest) {
namespace {
class MultiHttpFetcherTestDelegate : public HttpFetcherDelegate {
public:
- MultiHttpFetcherTestDelegate(int expected_response_code)
+ explicit MultiHttpFetcherTestDelegate(int expected_response_code)
: expected_response_code_(expected_response_code) {}
virtual void ReceivedBytes(HttpFetcher* fetcher,
@@ -962,7 +963,7 @@ void MultiTest(HttpFetcher* fetcher_in,
}
g_main_loop_unref(loop);
}
-} // namespace {}
+} // namespace
TYPED_TEST(HttpFetcherTest, MultiHttpFetcherSimpleTest) {
if (!this->test_.IsMulti())
diff --git a/install_plan.h b/install_plan.h
index b6bf293f..b30170ee 100644
--- a/install_plan.h
+++ b/install_plan.h
@@ -95,7 +95,7 @@ class ActionTraits<InstallPlanAction> {
class InstallPlanAction : public Action<InstallPlanAction> {
public:
InstallPlanAction() {}
- InstallPlanAction(const InstallPlan& install_plan):
+ explicit InstallPlanAction(const InstallPlan& install_plan):
install_plan_(install_plan) {}
virtual void PerformAction() {
@@ -116,7 +116,7 @@ class InstallPlanAction : public Action<InstallPlanAction> {
private:
InstallPlan install_plan_;
- DISALLOW_COPY_AND_ASSIGN (InstallPlanAction);
+ DISALLOW_COPY_AND_ASSIGN(InstallPlanAction);
};
} // namespace chromeos_update_engine
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index 1919466f..e2167cdb 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -28,7 +28,7 @@ namespace chromeos_update_engine {
namespace {
const int kNoNetworkRetrySeconds = 10;
const char kCACertificatesPath[] = "/usr/share/chromeos-ca-certificates";
-} // namespace {}
+} // namespace
LibcurlHttpFetcher::~LibcurlHttpFetcher() {
LOG_IF(ERROR, transfer_in_progress_)
@@ -542,7 +542,7 @@ void LibcurlHttpFetcher::CleanUp() {
}
void LibcurlHttpFetcher::GetHttpResponseCode() {
- long http_response_code = 0;
+ long http_response_code = 0; // NOLINT(runtime/int) - curl needs long.
if (curl_easy_getinfo(curl_handle_,
CURLINFO_RESPONSE_CODE,
&http_response_code) == CURLE_OK) {
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 60081834..d835b9c2 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -7,6 +7,7 @@
#include <map>
#include <string>
+#include <utility>
#include <base/basictypes.h>
#include <base/logging.h>
@@ -214,7 +215,7 @@ class LibcurlHttpFetcher : public HttpFetcher {
// the glib main loop. libcurl may open/close descriptors and switch their
// directions so maintain two separate lists so that watch conditions can be
// set appropriately.
- typedef std::map<int, std::pair<GIOChannel*, guint> > IOChannels;
+ typedef std::map<int, std::pair<GIOChannel*, guint>> IOChannels;
IOChannels io_channels_[2];
// if non-NULL, a timer we're waiting on. glib main loop will call us back
diff --git a/main.cc b/main.cc
index 95cf911b..83b9a4b1 100644
--- a/main.cc
+++ b/main.cc
@@ -54,7 +54,7 @@ gboolean BroadcastStatus(void* arg) {
gboolean UpdateEngineStarted(gpointer user_data) {
reinterpret_cast<UpdateAttempter*>(user_data)->UpdateEngineStarted();
- return FALSE; // Remove idle source (e.g. don't do the callback again)
+ return FALSE; // Remove idle source (e.g. don't do the callback again)
}
namespace {
@@ -110,9 +110,9 @@ void SetupLogSymlink(const string& symlink_path, const string& log_path) {
string GetTimeAsString(time_t utime) {
struct tm tm;
- CHECK(localtime_r(&utime, &tm) == &tm);
+ CHECK_EQ(localtime_r(&utime, &tm), &tm);
char str[16];
- CHECK(strftime(str, sizeof(str), "%Y%m%d-%H%M%S", &tm) == 15);
+ CHECK_EQ(strftime(str, sizeof(str), "%Y%m%d-%H%M%S", &tm), 15u);
return str;
}
@@ -146,7 +146,7 @@ void SetupLogging() {
logging::InitLogging(log_settings);
}
-} // namespace {}
+} // namespace
} // namespace chromeos_update_engine
int main(int argc, char** argv) {
diff --git a/mock_connection_manager.h b/mock_connection_manager.h
index 71b3019d..ffb695ab 100644
--- a/mock_connection_manager.h
+++ b/mock_connection_manager.h
@@ -16,7 +16,7 @@ namespace chromeos_update_engine {
// logic in update_engine.
class MockConnectionManager : public ConnectionManager {
public:
- MockConnectionManager(SystemState* system_state)
+ explicit MockConnectionManager(SystemState* system_state)
: ConnectionManager(system_state) {}
MOCK_CONST_METHOD3(GetConnectionProperties,
diff --git a/mock_file_writer.h b/mock_file_writer.h
index d662871f..46e57f45 100644
--- a/mock_file_writer.h
+++ b/mock_file_writer.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_FILE_WRITER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_FILE_WRITER_H_
+#include <vector>
+
#include "base/basictypes.h"
#include "update_engine/file_writer.h"
@@ -43,6 +45,7 @@ class MockFileWriter : public FileWriter {
const std::vector<char>& bytes() {
return bytes_;
}
+
private:
// The internal store of all bytes that have been written
std::vector<char> bytes_;
diff --git a/mock_http_fetcher.cc b/mock_http_fetcher.cc
index 81f9225a..9b3ae865 100644
--- a/mock_http_fetcher.cc
+++ b/mock_http_fetcher.cc
@@ -109,7 +109,6 @@ void MockHttpFetcher::Pause() {
g_source_destroy(timeout_source_);
timeout_source_ = NULL;
}
-
}
void MockHttpFetcher::Unpause() {
diff --git a/mock_http_fetcher.h b/mock_http_fetcher.h
index 8fef9ab4..99c47a5e 100644
--- a/mock_http_fetcher.h
+++ b/mock_http_fetcher.h
@@ -5,6 +5,7 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H_
+#include <string>
#include <vector>
#include <base/logging.h>
diff --git a/mock_p2p_manager.h b/mock_p2p_manager.h
index 4d2e9f3e..b0b6ac8d 100644
--- a/mock_p2p_manager.h
+++ b/mock_p2p_manager.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_P2P_MANAGER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_P2P_MANAGER_H_
+#include <string>
+
#include "update_engine/fake_p2p_manager.h"
#include <gmock/gmock.h>
@@ -13,7 +15,7 @@ namespace chromeos_update_engine {
// A mocked, fake implementation of P2PManager.
class MockP2PManager : public P2PManager {
-public:
+ public:
MockP2PManager() {
// Delegate all calls to the fake instance
ON_CALL(*this, SetDevicePolicy(testing::_))
@@ -83,7 +85,7 @@ public:
return fake_;
}
-private:
+ private:
// The underlying FakeP2PManager.
FakeP2PManager fake_;
diff --git a/mock_payload_state.h b/mock_payload_state.h
index 8301adb3..2db1d1bd 100644
--- a/mock_payload_state.h
+++ b/mock_payload_state.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
+#include <string>
+
#include "gmock/gmock.h"
#include "update_engine/omaha_request_action.h"
#include "update_engine/payload_state_interface.h"
diff --git a/multi_range_http_fetcher.cc b/multi_range_http_fetcher.cc
index 9eeefcde..19263de6 100644
--- a/multi_range_http_fetcher.cc
+++ b/multi_range_http_fetcher.cc
@@ -4,6 +4,9 @@
#include <base/strings/stringprintf.h>
+#include <algorithm>
+#include <string>
+
#include "update_engine/multi_range_http_fetcher.h"
#include "update_engine/utils.h"
@@ -41,7 +44,7 @@ void MultiRangeHttpFetcher::TerminateTransfer() {
return;
}
terminating_ = true;
-
+
if (!pending_transfer_ended_) {
base_fetcher_->TerminateTransfer();
}
diff --git a/multi_range_http_fetcher.h b/multi_range_http_fetcher.h
index 8b5ace84..800c7fd0 100644
--- a/multi_range_http_fetcher.h
+++ b/multi_range_http_fetcher.h
@@ -6,6 +6,7 @@
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MULTI_RANGE_HTTP_FETCHER_H_
#include <deque>
+#include <string>
#include <utility>
#include <vector>
@@ -106,7 +107,7 @@ class MultiRangeHttpFetcher : public HttpFetcher, public HttpFetcherDelegate {
class Range {
public:
Range(off_t offset, size_t length) : offset_(offset), length_(length) {}
- Range(off_t offset) : offset_(offset), length_(0) {}
+ explicit Range(off_t offset) : offset_(offset), length_(0) {}
inline off_t offset() const { return offset_; }
inline size_t length() const { return length_; }
diff --git a/omaha_hash_calculator.cc b/omaha_hash_calculator.cc
index f5237a21..1b61a9d2 100644
--- a/omaha_hash_calculator.cc
+++ b/omaha_hash_calculator.cc
@@ -39,8 +39,8 @@ class ScopedBioHandle {
BIO* bio() {
return bio_;
}
+
private:
- DISALLOW_COPY_AND_ASSIGN(ScopedBioHandle);
BIO* bio_;
void FreeCurrentBio() {
@@ -49,6 +49,8 @@ class ScopedBioHandle {
bio_ = NULL;
}
}
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedBioHandle);
};
OmahaHashCalculator::OmahaHashCalculator() : valid_(false) {
@@ -61,8 +63,8 @@ OmahaHashCalculator::OmahaHashCalculator() : valid_(false) {
bool OmahaHashCalculator::Update(const char* data, size_t length) {
TEST_AND_RETURN_FALSE(valid_);
TEST_AND_RETURN_FALSE(hash_.empty());
- COMPILE_ASSERT(sizeof(size_t) <= sizeof(unsigned long),
- length_param_may_be_truncated_in_SHA256_Update);
+ static_assert(sizeof(size_t) <= sizeof(unsigned long), // NOLINT(runtime/int)
+ "length param may be truncated in SHA256_Update");
TEST_AND_RETURN_FALSE(SHA256_Update(&ctx_, data, length) == 1);
return true;
}
@@ -153,7 +155,7 @@ bool OmahaHashCalculator::Base64Decode(const string& raw_in,
const int kOutBufferSize = 1024;
char out_buffer[kOutBufferSize];
- int num_bytes_read = 1; // any non-zero value is fine to enter the loop.
+ int num_bytes_read = 1; // any non-zero value is fine to enter the loop.
while (num_bytes_read > 0) {
num_bytes_read = BIO_read(b64.bio(), &out_buffer, kOutBufferSize);
for (int i = 0; i < num_bytes_read; i++)
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index 1bd17475..93a7125d 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -32,7 +32,7 @@ static const unsigned char kRawExpectedRawHash[] = {
};
class OmahaHashCalculatorTest : public ::testing::Test {
-public:
+ public:
const char *kExpectedRawHash;
const char *kExpectedRawHashEnd;
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 59551573..1a075666 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -58,7 +58,7 @@ static const char* kTagPublicKeyRsa = "PublicKeyRsa";
namespace {
-const string kGupdateVersion("ChromeOSUpdateEngine-0.1.0.0");
+static const char* const kGupdateVersion = "ChromeOSUpdateEngine-0.1.0.0";
// This is handy for passing strings into libxml2
#define ConstXMLStr(x) (reinterpret_cast<const xmlChar*>(x))
@@ -278,7 +278,7 @@ string GetRequestXml(const OmahaEvent* event,
return request_xml;
}
-} // namespace {}
+} // namespace
// Encodes XML entities in a given string with libxml2. input must be
// UTF-8 formatted. Output will be UTF-8 formatted.
@@ -465,7 +465,7 @@ xmlXPathObject* GetNodeSet(xmlDoc* doc, const xmlChar* xpath) {
LOG(ERROR) << "Unable to find " << xpath << " in XML document";
return NULL;
}
- if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
+ if (xmlXPathNodeSetIsEmpty(result->nodesetval)) {
LOG(INFO) << "Nodeset is empty for " << xpath;
xmlXPathFreeObject(result);
return NULL;
@@ -526,7 +526,7 @@ bool UpdateLastPingDays(xmlDoc* doc, PrefsInterface* prefs) {
prefs->SetInt64(kPrefsLastRollCallPingDay, daystart.ToInternalValue());
return true;
}
-} // namespace {}
+} // namespace
bool OmahaRequestAction::ParseResponse(xmlDoc* doc,
OmahaResponse* output_object,
@@ -1101,8 +1101,7 @@ OmahaRequestAction::IsWallClockBasedWaitingSatisfied(
update_first_seen_at_int)) {
LOG(INFO) << "Persisted the new value for UpdateFirstSeenAt: "
<< utils::ToString(update_first_seen_at);
- }
- else {
+ } else {
// This seems like an unexpected error where the value cannot be
// persisted for some reason. Just skip scattering in this
// case to be safe.
@@ -1363,15 +1362,15 @@ bool OmahaRequestAction::ShouldIgnoreUpdate(
// Note: policy decision to not update to a version we rolled back from.
string rollback_version =
system_state_->payload_state()->GetRollbackVersion();
- if(!rollback_version.empty()) {
+ if (!rollback_version.empty()) {
LOG(INFO) << "Detected previous rollback from version " << rollback_version;
- if(rollback_version == response.version) {
+ if (rollback_version == response.version) {
LOG(INFO) << "Received version that we rolled back from. Ignoring.";
return true;
}
}
- if(!IsUpdateAllowedOverCurrentConnection()) {
+ if (!IsUpdateAllowedOverCurrentConnection()) {
LOG(INFO) << "Update is not allowed over current connection.";
return true;
}
diff --git a/omaha_request_action.h b/omaha_request_action.h
index c005cc4a..6fef8e5b 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -48,7 +48,7 @@ struct OmahaEvent {
kResultError = 0,
kResultSuccess = 1,
kResultSuccessReboot = 2,
- kResultUpdateDeferred = 9, // When we ignore/defer updates due to policy.
+ kResultUpdateDeferred = 9, // When we ignore/defer updates due to policy.
};
OmahaEvent()
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 9cd32941..bfb13173 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -58,13 +58,13 @@ OmahaRequestParams kDefaultTestParams(
"OEM MODEL 09235 7471",
"ChromeOSFirmware.1.0",
"0X0A1",
- false, // delta okay
- false, // interactive
+ false, // delta okay
+ false, // interactive
"http://url",
- false, // update_disabled
- "", // target_version_prefix
- false, // use_p2p_for_downloading
- false); // use_p2p_for_sharing
+ false, // update_disabled
+ "", // target_version_prefix
+ false, // use_p2p_for_downloading
+ false); // use_p2p_for_sharing
string GetNoUpdateResponse(const string& app_id) {
return string(
@@ -138,9 +138,9 @@ string GetUpdateResponse(const string& app_id,
size,
deadline,
"7",
- "42", // elapsed_days
- false, // disable_p2p_for_downloading
- false); // disable_p2p_for sharing
+ "42", // elapsed_days
+ false, // disable_p2p_for_downloading
+ false); // disable_p2p_for sharing
}
class OmahaRequestActionTestProcessorDelegate : public ActionProcessorDelegate {
@@ -174,7 +174,7 @@ gboolean StartProcessorInRunLoop(gpointer data) {
processor->StartProcessing();
return FALSE;
}
-} // namespace {}
+} // namespace
class OutputObjectCollectorAction;
@@ -229,7 +229,7 @@ bool TestUpdateCheck(PrefsInterface* prefs,
PayloadStateInterface *payload_state,
P2PManager *p2p_manager,
ConnectionManager *connection_manager,
- OmahaRequestParams& params,
+ OmahaRequestParams* params,
const string& http_response,
int fail_http_response_code,
bool ping_only,
@@ -255,7 +255,7 @@ bool TestUpdateCheck(PrefsInterface* prefs,
fake_system_state.set_p2p_manager(p2p_manager);
if (connection_manager)
fake_system_state.set_connection_manager(connection_manager);
- fake_system_state.set_request_params(&params);
+ fake_system_state.set_request_params(params);
OmahaRequestAction action(&fake_system_state,
NULL,
fetcher,
@@ -334,7 +334,7 @@ TEST(OmahaRequestActionTest, NoUpdateTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
@@ -354,13 +354,13 @@ TEST(OmahaRequestActionTest, ValidUpdateTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetUpdateResponse(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
@@ -393,13 +393,13 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByPolicyTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
@@ -420,7 +420,7 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) {
// Set up a connection manager that doesn't allow a valid update over
// the current ethernet connection.
MockConnectionManager mock_cm(NULL);
- EXPECT_CALL(mock_cm, GetConnectionProperties(_,_,_))
+ EXPECT_CALL(mock_cm, GetConnectionProperties(_, _, _))
.WillRepeatedly(DoAll(SetArgumentPointee<1>(kNetEthernet),
SetArgumentPointee<2>(NetworkTethering::kUnknown),
Return(true)));
@@ -433,14 +433,14 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) {
TestUpdateCheck(NULL, // prefs
NULL, // payload_state
NULL, // p2p_manager
- &mock_cm, // connection_manager
- kDefaultTestParams,
+ &mock_cm, // connection_manager
+ &kDefaultTestParams,
GetUpdateResponse(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
@@ -469,13 +469,13 @@ TEST(OmahaRequestActionTest, ValidUpdateBlockedByRollback) {
&mock_payload_state, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetUpdateResponse(OmahaRequestParams::kAppId,
rollback_version, // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
@@ -500,7 +500,7 @@ TEST(OmahaRequestActionTest, NoUpdatesSentWhenBlockedByPolicyTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
@@ -534,21 +534,21 @@ TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kOmahaUpdateDeferredPerPolicy,
@@ -566,21 +566,21 @@ TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -616,21 +616,21 @@ TEST(OmahaRequestActionTest, NoWallClockBasedWaitCausesNoScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -666,21 +666,21 @@ TEST(OmahaRequestActionTest, ZeroMaxDaysToScatterCausesNoScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "0", // max days to scatter
- "42", // elapsed_days
+ "0", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -717,21 +717,21 @@ TEST(OmahaRequestActionTest, ZeroUpdateCheckCountCausesNoScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -743,7 +743,7 @@ TEST(OmahaRequestActionTest, ZeroUpdateCheckCountCausesNoScattering) {
int64 count;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
- ASSERT_TRUE(count == 0);
+ ASSERT_EQ(count, 0);
EXPECT_TRUE(response.update_exists);
}
@@ -771,21 +771,21 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kOmahaUpdateDeferredPerPolicy,
@@ -797,7 +797,7 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) {
int64 count;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
- ASSERT_TRUE(count > 0);
+ ASSERT_GT(count, 0);
EXPECT_FALSE(response.update_exists);
// Verify if we are interactive check we don't defer.
@@ -807,21 +807,21 @@ TEST(OmahaRequestActionTest, NonZeroUpdateCheckCountCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -859,21 +859,21 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kOmahaUpdateDeferredPerPolicy,
@@ -887,7 +887,7 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) {
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &count));
// count remains the same, as the decrementing happens in update_attempter
// which this test doesn't exercise.
- ASSERT_TRUE(count == 5);
+ ASSERT_EQ(count, 5);
EXPECT_FALSE(response.update_exists);
// Verify if we are interactive check we don't defer.
@@ -897,21 +897,21 @@ TEST(OmahaRequestActionTest, ExistingUpdateCheckCountCausesScattering) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -955,7 +955,7 @@ TEST(OmahaRequestActionTest, InvalidXmlTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"invalid xml>",
-1,
false, // ping_only
@@ -975,7 +975,7 @@ TEST(OmahaRequestActionTest, EmptyResponseTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"",
-1,
false, // ping_only
@@ -995,7 +995,7 @@ TEST(OmahaRequestActionTest, MissingStatusTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
"<app appid=\"foo\" status=\"ok\">"
@@ -1019,7 +1019,7 @@ TEST(OmahaRequestActionTest, InvalidStatusTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
"<app appid=\"foo\" status=\"ok\">"
@@ -1043,7 +1043,7 @@ TEST(OmahaRequestActionTest, MissingNodesetTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response protocol=\"3.0\">"
"<daystart elapsed_seconds=\"100\"/>"
"<app appid=\"foo\" status=\"ok\">"
@@ -1085,7 +1085,7 @@ TEST(OmahaRequestActionTest, MissingFieldTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
input_response,
-1,
false, // ping_only
@@ -1122,7 +1122,7 @@ gboolean TerminateTransferTestStarter(gpointer data) {
processor->StopProcessing();
return FALSE;
}
-} // namespace {}
+} // namespace
TEST(OmahaRequestActionTest, TerminateTransferTest) {
string http_response("doesn't matter");
@@ -1170,20 +1170,20 @@ TEST(OmahaRequestActionTest, XmlEncodeTest) {
"<OEM MODEL>",
"ChromeOSFirmware.1.0",
"EC100",
- false, // delta okay
- false, // interactive
+ false, // delta okay
+ false, // interactive
"http://url",
- false, // update_disabled
- "", // target_version_prefix
- false, // use_p2p_for_downloading
- false); // use_p2p_for_sharing
+ false, // update_disabled
+ "", // target_version_prefix
+ false, // use_p2p_for_downloading
+ false); // use_p2p_for_sharing
OmahaResponse response;
ASSERT_FALSE(
TestUpdateCheck(NULL, // prefs
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -1212,14 +1212,14 @@ TEST(OmahaRequestActionTest, XmlDecodeTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetUpdateResponse(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"testthe&lt;url", // more info
"true", // prompt
"testthe&amp;codebase/", // dl url
- "file.signed", // file name
- "HASH1234=", // checksum
+ "file.signed", // file name
+ "HASH1234=", // checksum
"false", // needs admin
"123", // size
"&lt;20110101"), // deadline
@@ -1244,14 +1244,14 @@ TEST(OmahaRequestActionTest, ParseIntTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetUpdateResponse(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"theurl", // more info
"true", // prompt
"thecodebase/", // dl url
- "file.signed", // file name
- "HASH1234=", // checksum
+ "file.signed", // file name
+ "HASH1234=", // checksum
"false", // needs admin
// overflows int32:
"123123123123123", // size
@@ -1278,7 +1278,7 @@ TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"invalid xml>",
-1,
false, // ping_only
@@ -1315,7 +1315,7 @@ TEST(OmahaRequestActionTest, FormatUpdateDisabledOutputTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -1426,12 +1426,12 @@ TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) {
false, // update_disabled
"", // target_version_prefix
false, // use_p2p_for_downloading
- false); // use_p2p_for_sharing
+ false); // use_p2p_for_sharing
ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -1474,12 +1474,12 @@ TEST(OmahaRequestActionTest, FormatInteractiveOutputTest) {
false, // update_disabled
"", // target_version_prefix
false, // use_p2p_for_downloading
- false); // use_p2p_for_sharing
+ false); // use_p2p_for_sharing
ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -1540,7 +1540,7 @@ TEST(OmahaRequestActionTest, PingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
ping_only,
@@ -1583,7 +1583,7 @@ TEST(OmahaRequestActionTest, ActivePingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
@@ -1618,7 +1618,7 @@ TEST(OmahaRequestActionTest, RollCallPingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
@@ -1654,7 +1654,7 @@ TEST(OmahaRequestActionTest, NoPingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
@@ -1684,7 +1684,7 @@ TEST(OmahaRequestActionTest, IgnoreEmptyPingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
true, // ping_only
@@ -1720,7 +1720,7 @@ TEST(OmahaRequestActionTest, BackInTimePingTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"100\"/>"
"<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
@@ -1760,7 +1760,7 @@ TEST(OmahaRequestActionTest, LastPingDayUpdateTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"200\"/>"
"<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
@@ -1786,7 +1786,7 @@ TEST(OmahaRequestActionTest, NoElapsedSecondsTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart blah=\"200\"/>"
"<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
@@ -1812,7 +1812,7 @@ TEST(OmahaRequestActionTest, BadElapsedSecondsTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
"protocol=\"3.0\"><daystart elapsed_seconds=\"x\"/>"
"<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
@@ -1833,7 +1833,7 @@ TEST(OmahaRequestActionTest, NoUniqueIDTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"invalid xml>",
-1,
false, // ping_only
@@ -1858,7 +1858,7 @@ TEST(OmahaRequestActionTest, NetworkFailureTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"",
501,
false, // ping_only
@@ -1880,7 +1880,7 @@ TEST(OmahaRequestActionTest, NetworkFailureBadHTTPCodeTest) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
"",
1500,
false, // ping_only
@@ -1914,21 +1914,21 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kOmahaUpdateDeferredPerPolicy,
@@ -1940,7 +1940,7 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) {
int64 timestamp = 0;
ASSERT_TRUE(prefs.GetInt64(kPrefsUpdateFirstSeenAt, &timestamp));
- ASSERT_TRUE(timestamp > 0);
+ ASSERT_GT(timestamp, 0);
EXPECT_FALSE(response.update_exists);
// Verify if we are interactive check we don't defer.
@@ -1950,21 +1950,21 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsPersistedFirstTime) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -2002,21 +2002,21 @@ TEST(OmahaRequestActionTest, TestUpdateFirstSeenAtGetsUsedIfAlreadyPresent) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -2066,7 +2066,7 @@ TEST(OmahaRequestActionTest, TestChangingToMoreStableChannel) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -2117,7 +2117,7 @@ TEST(OmahaRequestActionTest, TestChangingToLessStableChannel) {
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- params,
+ &params,
"invalid xml>",
-1,
false, // ping_only
@@ -2133,7 +2133,7 @@ TEST(OmahaRequestActionTest, TestChangingToLessStableChannel) {
"appid=\"{11111111-1111-1111-1111-111111111111}\" "
"version=\"5.6.7.8\" "
"track=\"canary-channel\" from_track=\"stable-channel\""));
- EXPECT_EQ(string::npos, post_str.find( "from_version"));
+ EXPECT_EQ(string::npos, post_str.find("from_version"));
ASSERT_TRUE(utils::RecursiveUnlinkDir(test_dir));
}
@@ -2168,19 +2168,19 @@ void P2PTest(bool initial_allow_p2p_for_downloading,
&mock_payload_state,
&mock_p2p_manager,
NULL, // connection_manager
- request_params,
+ &request_params,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
- "42", // elapsed_days
+ "7", // max days to scatter
+ "42", // elapsed_days
omaha_disable_p2p_for_downloading,
omaha_disable_p2p_for_sharing),
-1,
@@ -2208,81 +2208,81 @@ void P2PTest(bool initial_allow_p2p_for_downloading,
}
TEST(OmahaRequestActionTest, P2PWithPeer) {
- P2PTest(true, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- false, // omaha_disable_p2p_for_downloading
- false, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- true, // expect_p2p_client_lookup
- "http://1.3.5.7/p2p", // p2p_client_result_url
- true, // expected_allow_p2p_for_downloading
- true, // expected_allow_p2p_for_sharing
- "http://1.3.5.7/p2p"); // expected_p2p_url
+ P2PTest(true, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ false, // omaha_disable_p2p_for_downloading
+ false, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ true, // expect_p2p_client_lookup
+ "http://1.3.5.7/p2p", // p2p_client_result_url
+ true, // expected_allow_p2p_for_downloading
+ true, // expected_allow_p2p_for_sharing
+ "http://1.3.5.7/p2p"); // expected_p2p_url
}
TEST(OmahaRequestActionTest, P2PWithoutPeer) {
- P2PTest(true, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- false, // omaha_disable_p2p_for_downloading
- false, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- true, // expect_p2p_client_lookup
- "", // p2p_client_result_url
- false, // expected_allow_p2p_for_downloading
- true, // expected_allow_p2p_for_sharing
- ""); // expected_p2p_url
+ P2PTest(true, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ false, // omaha_disable_p2p_for_downloading
+ false, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ true, // expect_p2p_client_lookup
+ "", // p2p_client_result_url
+ false, // expected_allow_p2p_for_downloading
+ true, // expected_allow_p2p_for_sharing
+ ""); // expected_p2p_url
}
TEST(OmahaRequestActionTest, P2PDownloadNotAllowed) {
- P2PTest(false, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- false, // omaha_disable_p2p_for_downloading
- false, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- false, // expect_p2p_client_lookup
- "unset", // p2p_client_result_url
- false, // expected_allow_p2p_for_downloading
- true, // expected_allow_p2p_for_sharing
- ""); // expected_p2p_url
+ P2PTest(false, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ false, // omaha_disable_p2p_for_downloading
+ false, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ false, // expect_p2p_client_lookup
+ "unset", // p2p_client_result_url
+ false, // expected_allow_p2p_for_downloading
+ true, // expected_allow_p2p_for_sharing
+ ""); // expected_p2p_url
}
TEST(OmahaRequestActionTest, P2PWithPeerDownloadDisabledByOmaha) {
- P2PTest(true, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- true, // omaha_disable_p2p_for_downloading
- false, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- false, // expect_p2p_client_lookup
- "unset", // p2p_client_result_url
- false, // expected_allow_p2p_for_downloading
- true, // expected_allow_p2p_for_sharing
- ""); // expected_p2p_url
+ P2PTest(true, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ true, // omaha_disable_p2p_for_downloading
+ false, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ false, // expect_p2p_client_lookup
+ "unset", // p2p_client_result_url
+ false, // expected_allow_p2p_for_downloading
+ true, // expected_allow_p2p_for_sharing
+ ""); // expected_p2p_url
}
TEST(OmahaRequestActionTest, P2PWithPeerSharingDisabledByOmaha) {
- P2PTest(true, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- false, // omaha_disable_p2p_for_downloading
- true, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- true, // expect_p2p_client_lookup
- "http://1.3.5.7/p2p", // p2p_client_result_url
- true, // expected_allow_p2p_for_downloading
- false, // expected_allow_p2p_for_sharing
- "http://1.3.5.7/p2p"); // expected_p2p_url
+ P2PTest(true, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ false, // omaha_disable_p2p_for_downloading
+ true, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ true, // expect_p2p_client_lookup
+ "http://1.3.5.7/p2p", // p2p_client_result_url
+ true, // expected_allow_p2p_for_downloading
+ false, // expected_allow_p2p_for_sharing
+ "http://1.3.5.7/p2p"); // expected_p2p_url
}
TEST(OmahaRequestActionTest, P2PWithPeerBothDisabledByOmaha) {
- P2PTest(true, // initial_allow_p2p_for_downloading
- true, // initial_allow_p2p_for_sharing
- true, // omaha_disable_p2p_for_downloading
- true, // omaha_disable_p2p_for_sharing
- true, // payload_state_allow_p2p_attempt
- false, // expect_p2p_client_lookup
- "unset", // p2p_client_result_url
- false, // expected_allow_p2p_for_downloading
- false, // expected_allow_p2p_for_sharing
- ""); // expected_p2p_url
+ P2PTest(true, // initial_allow_p2p_for_downloading
+ true, // initial_allow_p2p_for_sharing
+ true, // omaha_disable_p2p_for_downloading
+ true, // omaha_disable_p2p_for_sharing
+ true, // payload_state_allow_p2p_attempt
+ false, // expect_p2p_client_lookup
+ "unset", // p2p_client_result_url
+ false, // expected_allow_p2p_for_downloading
+ false, // expected_allow_p2p_for_sharing
+ ""); // expected_p2p_url
}
bool InstallDateParseHelper(const std::string &elapsed_days,
@@ -2293,21 +2293,21 @@ bool InstallDateParseHelper(const std::string &elapsed_days,
NULL, // payload_state
NULL, // p2p_manager
NULL, // connection_manager
- kDefaultTestParams,
+ &kDefaultTestParams,
GetUpdateResponse2(OmahaRequestParams::kAppId,
"1.2.3.4", // version
"http://more/info",
"true", // prompt
"http://code/base/", // dl url
- "file.signed", // file name
+ "file.signed", // file name
"HASH1234=", // checksum
"false", // needs admin
"123", // size
"", // deadline
- "7", // max days to scatter
+ "7", // max days to scatter
elapsed_days,
false, // disable_p2p_for_downloading
- false), // disable_p2p_for sharing
+ false), // disable_p2p_for sharing
-1,
false, // ping_only
ErrorCode::kSuccess,
@@ -2386,7 +2386,7 @@ TEST(OmahaRequestActionTest, GetInstallDate) {
FakeSystemState fake_system_state;
fake_system_state.set_prefs(&prefs);
- Time oobe_date = Time::FromTimeT(42); // Dec 31, 1969 16:00:42 PST.
+ Time oobe_date = Time::FromTimeT(42); // Dec 31, 1969 16:00:42 PST.
fake_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
EXPECT_EQ(OmahaRequestAction::GetInstallDate(&fake_system_state), -1);
EXPECT_FALSE(prefs.Exists(kPrefsInstallDateDays));
@@ -2398,7 +2398,7 @@ TEST(OmahaRequestActionTest, GetInstallDate) {
FakeSystemState fake_system_state;
fake_system_state.set_prefs(&prefs);
- Time oobe_date = Time::FromTimeT(1169280000); // Jan 20, 2007 0:00 PST.
+ Time oobe_date = Time::FromTimeT(1169280000); // Jan 20, 2007 0:00 PST.
fake_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
EXPECT_EQ(OmahaRequestAction::GetInstallDate(&fake_system_state), 14);
EXPECT_TRUE(prefs.Exists(kPrefsInstallDateDays));
@@ -2416,7 +2416,7 @@ TEST(OmahaRequestActionTest, GetInstallDate) {
FakeSystemState fake_system_state;
fake_system_state.set_prefs(&prefs);
- Time oobe_date = Time::FromTimeT(1170144000); // Jan 30, 2007 0:00 PST.
+ Time oobe_date = Time::FromTimeT(1170144000); // Jan 30, 2007 0:00 PST.
fake_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
EXPECT_EQ(OmahaRequestAction::GetInstallDate(&fake_system_state), 14);
diff --git a/omaha_request_params.cc b/omaha_request_params.cc
index 667ed46f..73117a45 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -114,14 +114,14 @@ bool OmahaRequestParams::Init(const std::string& in_app_version,
}
bool OmahaRequestParams::CollectECFWVersions() const {
- return (
+ return {
StartsWithASCII(hwid_, string("SAMS ALEX"), true) ||
StartsWithASCII(hwid_, string("BUTTERFLY"), true) ||
StartsWithASCII(hwid_, string("LUMPY"), true) ||
StartsWithASCII(hwid_, string("PARROT"), true) ||
StartsWithASCII(hwid_, string("SPRING"), true) ||
StartsWithASCII(hwid_, string("SNOW"), true)
- );
+ };
}
bool OmahaRequestParams::SetTargetChannel(const std::string& new_target_channel,
@@ -179,8 +179,8 @@ void OmahaRequestParams::SetIsPowerwashAllowedFromLsbValue() {
string is_powerwash_allowed_str = GetLsbValue(
kIsPowerwashAllowedKey,
"false",
- NULL, // no need to validate
- true); // always get it from stateful, as that's the only place it'll be
+ NULL, // no need to validate
+ true); // always get it from stateful, as that's the only place it'll be
bool is_powerwash_allowed_new_value = (is_powerwash_allowed_str == "true");
if (is_powerwash_allowed_ != is_powerwash_allowed_new_value) {
is_powerwash_allowed_ = is_powerwash_allowed_new_value;
diff --git a/omaha_request_params.h b/omaha_request_params.h
index b370bb74..86a18a6a 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -25,11 +25,11 @@ class SystemState;
// essential state needed for the processing of the request/response. The
// strings in this struct should not be XML escaped.
//
-// TODO (jaysri): chromium-os:39752 tracks the need to rename this class to
+// TODO(jaysri): chromium-os:39752 tracks the need to rename this class to
// reflect its lifetime more appropriately.
class OmahaRequestParams {
public:
- OmahaRequestParams(SystemState* system_state)
+ explicit OmahaRequestParams(SystemState* system_state)
: system_state_(system_state),
os_platform_(kOsPlatform),
os_version_(kOsVersion),
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 01cf154d..432eb6c3 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -79,7 +79,7 @@ string GetMachineType() {
machine_type.erase(newline_pos);
return machine_type;
}
-} // namespace {}
+} // namespace
TEST_F(OmahaRequestParamsTest, SimpleTest) {
ASSERT_TRUE(WriteFileString(
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 4af21b46..80aad609 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -52,7 +52,7 @@ class OmahaResponseHandlerActionProcessorDelegate
};
namespace {
-const string kLongName =
+const char* const kLongName =
"very_long_name_and_no_slashes-very_long_name_and_no_slashes"
"very_long_name_and_no_slashes-very_long_name_and_no_slashes"
"very_long_name_and_no_slashes-very_long_name_and_no_slashes"
@@ -61,8 +61,8 @@ const string kLongName =
"very_long_name_and_no_slashes-very_long_name_and_no_slashes"
"very_long_name_and_no_slashes-very_long_name_and_no_slashes"
"-the_update_a.b.c.d_DELTA_.tgz";
-const string kBadVersion = "don't update me";
-} // namespace {}
+const char* const kBadVersion = "don't update me";
+} // namespace
bool OmahaResponseHandlerActionTest::DoTestCommon(
FakeSystemState* fake_system_state,
@@ -76,7 +76,7 @@ bool OmahaResponseHandlerActionTest::DoTestCommon(
ObjectFeederAction<OmahaResponse> feeder_action;
feeder_action.set_obj(in);
- if (in.update_exists and in.version != kBadVersion) {
+ if (in.update_exists && in.version != kBadVersion) {
EXPECT_CALL(*(fake_system_state->mock_prefs()),
SetString(kPrefsUpdateCheckResponseHash, in.hash))
.WillOnce(Return(true));
diff --git a/p2p_manager.cc b/p2p_manager.cc
index ddb9bf0e..548d25c8 100644
--- a/p2p_manager.cc
+++ b/p2p_manager.cc
@@ -22,8 +22,8 @@
#include <sys/statvfs.h>
#include <sys/types.h>
#include <unistd.h>
-#include <unistd.h>
+#include <algorithm>
#include <map>
#include <utility>
#include <vector>
@@ -54,11 +54,11 @@ const char kDefaultP2PDir[] = "/var/cache/p2p";
// p2p ddoc for details.
const char kCrosP2PFileSizeXAttrName[] = "user.cros-p2p-filesize";
-} // namespace
+} // namespace
// The default P2PManager::Configuration implementation.
class ConfigurationImpl : public P2PManager::Configuration {
-public:
+ public:
ConfigurationImpl() {}
virtual ~ConfigurationImpl() {}
@@ -84,13 +84,13 @@ public:
return args;
}
-private:
+ private:
DISALLOW_COPY_AND_ASSIGN(ConfigurationImpl);
};
// The default P2PManager implementation.
class P2PManagerImpl : public P2PManager {
-public:
+ public:
P2PManagerImpl(Configuration *configuration,
PrefsInterface *prefs,
const string& file_extension,
@@ -116,7 +116,7 @@ public:
virtual bool FileMakeVisible(const string& file_id);
virtual int CountSharedFiles();
-private:
+ private:
// Enumeration for specifying visibility.
enum Visibility {
kVisible,
@@ -224,9 +224,9 @@ bool P2PManagerImpl::EnsureP2P(bool should_be_running) {
vector<string> args = configuration_->GetInitctlArgs(should_be_running);
scoped_ptr<gchar*, GLibStrvFreeDeleter> argv(
utils::StringVectorToGStrv(args));
- if (!g_spawn_sync(NULL, // working_directory
+ if (!g_spawn_sync(NULL, // working_directory
argv.get(),
- NULL, // envp
+ NULL, // envp
static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH),
NULL, NULL, // child_setup, user_data
NULL, // standard_output
@@ -362,8 +362,8 @@ bool P2PManagerImpl::PerformHousekeeping() {
// Helper class for implementing LookupUrlForFile().
class LookupData {
-public:
- LookupData(P2PManager::LookupCallback callback)
+ public:
+ explicit LookupData(P2PManager::LookupCallback callback)
: callback_(callback),
pid_(0),
stdout_fd_(-1),
@@ -392,17 +392,17 @@ public:
// guarantee is useful for testing).
GError *error = NULL;
- if (!g_spawn_async_with_pipes(NULL, // working_directory
+ if (!g_spawn_async_with_pipes(NULL, // working_directory
argv,
- NULL, // envp
+ NULL, // envp
static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH |
G_SPAWN_DO_NOT_REAP_CHILD),
- NULL, // child_setup
+ NULL, // child_setup
this,
&pid_,
- NULL, // standard_input
+ NULL, // standard_input
&stdout_fd_,
- NULL, // standard_error
+ NULL, // standard_error
&error)) {
LOG(ERROR) << "Error spawning p2p-client: "
<< utils::GetAndFreeGError(&error);
@@ -415,21 +415,21 @@ public:
io_channel,
static_cast<GIOCondition>(G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP),
OnIOChannelActivity, this);
- CHECK(stdout_channel_source_id_ != 0);
+ CHECK_NE(stdout_channel_source_id_, 0u);
g_io_channel_unref(io_channel);
child_watch_source_id_ = g_child_watch_add(pid_, OnChildWatchActivity,
this);
- CHECK(child_watch_source_id_ != 0);
+ CHECK_NE(child_watch_source_id_, 0u);
if (timeout.ToInternalValue() > 0) {
timeout_source_id_ = g_timeout_add(timeout.InMilliseconds(),
OnTimeout, this);
- CHECK(timeout_source_id_ != 0);
+ CHECK_NE(timeout_source_id_, 0u);
}
}
-private:
+ private:
void ReportErrorAndDeleteInIdle() {
g_idle_add(static_cast<GSourceFunc>(OnIdleForReportErrorAndDelete), this);
}
@@ -438,7 +438,7 @@ private:
LookupData *lookup_data = reinterpret_cast<LookupData*>(user_data);
lookup_data->ReportError();
delete lookup_data;
- return FALSE; // Remove source.
+ return FALSE; // Remove source.
}
void IssueCallback(const string& url) {
@@ -501,7 +501,7 @@ private:
g_free(str);
}
}
- return TRUE; // Don't remove source.
+ return TRUE; // Don't remove source.
}
static void OnChildWatchActivity(GPid pid,
@@ -526,7 +526,7 @@ private:
LookupData *lookup_data = reinterpret_cast<LookupData*>(user_data);
lookup_data->ReportError();
delete lookup_data;
- return TRUE; // Don't remove source.
+ return TRUE; // Don't remove source.
}
P2PManager::LookupCallback callback_;
@@ -603,7 +603,7 @@ bool P2PManagerImpl::FileShare(const string& file_id,
// space) and set the user.cros-p2p-filesize xattr.
if (expected_size != 0) {
if (fallocate(fd,
- FALLOC_FL_KEEP_SIZE, // Keep file size as 0.
+ FALLOC_FL_KEEP_SIZE, // Keep file size as 0.
0,
expected_size) != 0) {
if (errno == ENOSYS || errno == EOPNOTSUPP) {
@@ -716,7 +716,7 @@ ssize_t P2PManagerImpl::FileGetExpectedSize(const string& file_id) {
}
char* endp = NULL;
- long long int val = strtoll(ea_value, &endp, 0);
+ long long int val = strtoll(ea_value, &endp, 0); // NOLINT(runtime/int)
if (*endp != '\0') {
LOG(ERROR) << "Error parsing the value '" << ea_value
<< "' of the xattr " << kCrosP2PFileSizeXAttrName
diff --git a/p2p_manager.h b/p2p_manager.h
index 0b393f27..25526bff 100644
--- a/p2p_manager.h
+++ b/p2p_manager.h
@@ -21,11 +21,11 @@ namespace chromeos_update_engine {
// Interface for sharing and discovering files via p2p.
class P2PManager {
-public:
+ public:
// Interface used for P2PManager implementations. The sole reason
// for this interface is unit testing.
class Configuration {
- public:
+ public:
virtual ~Configuration() {}
// Gets the path to the p2p dir being used, e.g. /var/cache/p2p.
diff --git a/p2p_manager_unittest.cc b/p2p_manager_unittest.cc
index 32237248..262031f3 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -35,7 +35,7 @@ namespace chromeos_update_engine {
// temporary p2p dir) for P2PManager and cleans up when the test is
// done.
class P2PManagerTest : public testing::Test {
-protected:
+ protected:
P2PManagerTest() {}
virtual ~P2PManagerTest() {}
@@ -100,7 +100,7 @@ TEST_F(P2PManagerTest, P2PEnabledEnterpriseSettingTrue) {
scoped_ptr<policy::MockDevicePolicy> device_policy(
new policy::MockDevicePolicy());
EXPECT_CALL(*device_policy, GetAuP2PEnabled(testing::_)).WillRepeatedly(
- DoAll(testing::SetArgumentPointee<0>(bool(true)),
+ DoAll(testing::SetArgumentPointee<0>(true),
testing::Return(true)));
manager->SetDevicePolicy(device_policy.get());
EXPECT_TRUE(manager->IsP2PEnabled());
@@ -126,7 +126,7 @@ TEST_F(P2PManagerTest, P2PEnabledEnterpriseSettingFalse) {
scoped_ptr<policy::MockDevicePolicy> device_policy(
new policy::MockDevicePolicy());
EXPECT_CALL(*device_policy, GetAuP2PEnabled(testing::_)).WillRepeatedly(
- DoAll(testing::SetArgumentPointee<0>(bool(false)),
+ DoAll(testing::SetArgumentPointee<0>(false),
testing::Return(true)));
manager->SetDevicePolicy(device_policy.get());
EXPECT_FALSE(manager->IsP2PEnabled());
@@ -243,7 +243,7 @@ static bool CheckP2PFile(const string& p2p_dir, const string& file_name,
return false;
}
char* endp = NULL;
- long long int val = strtoll(ea_value, &endp, 0);
+ long long int val = strtoll(ea_value, &endp, 0); // NOLINT(runtime/int)
if (endp == NULL || *endp != '\0') {
LOG(ERROR) << "Error parsing xattr '" << ea_value
<< "' as an integer";
@@ -477,4 +477,4 @@ TEST_F(P2PManagerTest, LookupURL) {
g_main_loop_unref(loop);
}
-} // namespace chromeos_update_engine
+} // namespace chromeos_update_engine
diff --git a/payload_generator/cycle_breaker_unittest.cc b/payload_generator/cycle_breaker_unittest.cc
index b2cd5d4d..b58bb087 100644
--- a/payload_generator/cycle_breaker_unittest.cc
+++ b/payload_generator/cycle_breaker_unittest.cc
@@ -29,7 +29,7 @@ void SetOpForNodes(Graph* graph) {
it->op.set_type(DeltaArchiveManifest_InstallOperation_Type_MOVE);
}
}
-} // namespace {}
+} // namespace
class CycleBreakerTest : public ::testing::Test {};
@@ -90,7 +90,7 @@ uint64_t weight) {
props.extents[0].set_num_blocks(weight);
return make_pair(dest, props);
}
-} // namespace {}
+} // namespace
// This creates a bunch of cycles like this:
diff --git a/payload_generator/delta_diff_generator.cc b/payload_generator/delta_diff_generator.cc
index 8fbbd0dd..587892c7 100644
--- a/payload_generator/delta_diff_generator.cc
+++ b/payload_generator/delta_diff_generator.cc
@@ -663,7 +663,7 @@ size_t RemoveIdenticalBlockRanges(vector<Extent>* src_extents,
return removed_bytes;
}
-} // namespace {}
+} // namespace
bool DeltaDiffGenerator::ReadFileToDiff(
const string& old_filename,
@@ -893,7 +893,7 @@ vector<Extent> CompressExtents(const vector<uint64_t>& blocks) {
return new_extents;
}
-} // namespace {}
+} // namespace
void DeltaDiffGenerator::SubstituteBlocks(
Vertex* vertex,
@@ -1047,7 +1047,7 @@ class SortCutsByTopoOrderLess {
vector<vector<Vertex::Index>::size_type>& table_;
};
-} // namespace {}
+} // namespace
void DeltaDiffGenerator::GenerateReverseTopoOrderMap(
vector<Vertex::Index>& op_indexes,
@@ -1276,7 +1276,7 @@ bool AssignBlockForAdjoiningCuts(
return true;
}
-} // namespace {}
+} // namespace
// Returns true if |op| is a no-op operation that doesn't do any useful work
// (e.g., a move operation that copies blocks onto themselves).
diff --git a/payload_generator/delta_diff_generator_unittest.cc b/payload_generator/delta_diff_generator_unittest.cc
index 05b173cf..c9ac8cf0 100644
--- a/payload_generator/delta_diff_generator_unittest.cc
+++ b/payload_generator/delta_diff_generator_unittest.cc
@@ -54,7 +54,7 @@ int64_t BlocksInExtents(
}
return ret;
}
-} // namespace {}
+} // namespace
class DeltaDiffGeneratorTest : public ::testing::Test {
protected:
@@ -660,7 +660,7 @@ void DumpVect(const vector<T>& vect) {
LOG(INFO) << "{" << ss.str() << "}";
}
-} // namespace {}
+} // namespace
TEST_F(DeltaDiffGeneratorTest, RunAsRootAssignTempBlocksTest) {
Graph graph(9);
diff --git a/payload_generator/full_update_generator_unittest.cc b/payload_generator/full_update_generator_unittest.cc
index c3da1154..689c5cec 100644
--- a/payload_generator/full_update_generator_unittest.cc
+++ b/payload_generator/full_update_generator_unittest.cc
@@ -17,7 +17,7 @@ namespace chromeos_update_engine {
namespace {
const size_t kBlockSize = 4096;
-} // namespace {}
+} // namespace
class FullUpdateGeneratorTest : public ::testing::Test { };
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index acf4dcd5..89bb2b9e 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -386,7 +386,7 @@ int Main(int argc, char** argv) {
return 0;
}
-} // namespace {}
+} // namespace
} // namespace chromeos_update_engine
diff --git a/payload_generator/graph_utils.cc b/payload_generator/graph_utils.cc
index 8b6535d6..b3c4231d 100644
--- a/payload_generator/graph_utils.cc
+++ b/payload_generator/graph_utils.cc
@@ -133,7 +133,7 @@ void DumpOutEdges(const Vertex::EdgeMap& out_edges) {
DumpExtents(it->second.write_extents, 6);
}
}
-} // namespace {}
+} // namespace
void DumpGraph(const Graph& graph) {
LOG(INFO) << "Graph length: " << graph.size();
diff --git a/payload_generator/metadata.cc b/payload_generator/metadata.cc
index f0c9238c..d0ab82c9 100644
--- a/payload_generator/metadata.cc
+++ b/payload_generator/metadata.cc
@@ -425,7 +425,7 @@ bool ReadInodeMetadata(Graph* graph,
return true;
}
-} // namespace {}
+} // namespace
// Reads metadata from old image and new image and determines
// the smallest way to encode the metadata for the diff.
diff --git a/payload_generator/metadata_unittest.cc b/payload_generator/metadata_unittest.cc
index 39a2476b..14e21ae0 100644
--- a/payload_generator/metadata_unittest.cc
+++ b/payload_generator/metadata_unittest.cc
@@ -112,8 +112,8 @@ TEST_F(MetadataTest, RunAsRootReadMetadata) {
// - test_file indirect block (inode 12)
struct {
string metadata_name;
- off_t start_block; // Set to -1 to skip start block verification
- off_t num_blocks; // Set to -1 to skip num blocks verification
+ off_t start_block; // Set to -1 to skip start block verification
+ off_t num_blocks; // Set to -1 to skip num blocks verification
} exp_results[] =
{{"<rootfs-bg-0-0-metadata>", 0, 104},
{"<rootfs-bg-0-1-metadata>", 104, 104},
diff --git a/payload_generator/topological_sort.cc b/payload_generator/topological_sort.cc
index 3ee8c75a..2a6e586e 100644
--- a/payload_generator/topological_sort.cc
+++ b/payload_generator/topological_sort.cc
@@ -31,7 +31,7 @@ void TopologicalSortVisit(const Graph& graph,
// Visit this node.
nodes->push_back(node);
}
-} // namespace {}
+} // namespace
void TopologicalSort(const Graph& graph, vector<Vertex::Index>* out) {
set<Vertex::Index> visited_nodes;
diff --git a/payload_generator/topological_sort_unittest.cc b/payload_generator/topological_sort_unittest.cc
index 696fd5b5..c1d19b75 100644
--- a/payload_generator/topological_sort_unittest.cc
+++ b/payload_generator/topological_sort_unittest.cc
@@ -34,7 +34,7 @@ bool IndexOf(const vector<T>& vect,
}
return false;
}
-} // namespace {}
+} // namespace
TEST(TopologicalSortTest, SimpleTest) {
int counter = 0;
diff --git a/payload_signer.cc b/payload_signer.cc
index a3ac5b95..15c2b329 100644
--- a/payload_signer.cc
+++ b/payload_signer.cc
@@ -133,7 +133,6 @@ bool AddSignatureOpToPayload(const string& payload_path,
// Is there already a signature op in place?
if (manifest.has_signatures_size()) {
-
// The signature op is tied to the size of the signature blob, but not it's
// contents. We don't allow the manifest to change if there is already an op
// present, because that might invalidate previously generated
@@ -177,7 +176,7 @@ bool AddSignatureOpToPayload(const string& payload_path,
LOG(INFO) << "Signature Blob Offset: " << *out_signatures_offset;
return true;
}
-} // namespace {}
+} // namespace
bool PayloadSigner::LoadPayload(const string& payload_path,
vector<char>* out_payload,
diff --git a/payload_signer_unittest.cc b/payload_signer_unittest.cc
index 086e54a5..829fdd8a 100644
--- a/payload_signer_unittest.cc
+++ b/payload_signer_unittest.cc
@@ -77,8 +77,6 @@ const unsigned char kDataSignature[] = {
0x29, 0x93, 0x43, 0xc7, 0x43, 0xb9, 0xab, 0x7d
};
-//class PayloadSignerTest : public ::testing::Test {};
-
namespace {
void SignSampleData(vector<char>* out_signature_blob) {
string data_path;
@@ -99,7 +97,7 @@ void SignSampleData(vector<char>* out_signature_blob) {
out_signature_blob));
EXPECT_EQ(length, out_signature_blob->size());
}
-}
+} // namespace
TEST(PayloadSignerTest, SimpleTest) {
vector<char> signature_blob;
diff --git a/payload_state.cc b/payload_state.cc
index 3f9aa19c..a9815464 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -5,6 +5,7 @@
#include "update_engine/payload_state.h"
#include <algorithm>
+#include <string>
#include <base/logging.h>
#include <base/strings/string_util.h>
@@ -48,10 +49,9 @@ PayloadState::PayloadState()
p2p_num_attempts_(0),
attempt_num_bytes_downloaded_(0),
attempt_connection_type_(metrics::ConnectionType::kUnknown),
- attempt_type_(AttemptType::kUpdate)
-{
- for (int i = 0; i <= kNumDownloadSources; i++)
- total_bytes_downloaded_[i] = current_bytes_downloaded_[i] = 0;
+ attempt_type_(AttemptType::kUpdate) {
+ for (int i = 0; i <= kNumDownloadSources; i++)
+ total_bytes_downloaded_[i] = current_bytes_downloaded_[i] = 0;
}
bool PayloadState::Initialize(SystemState* system_state) {
@@ -291,11 +291,12 @@ void PayloadState::UpdateFailed(ErrorCode error) {
// (because download from a local server URL that appears earlier in a
// response is preferable than downloading from the next URL which could be
// a internet URL and thus could be more expensive).
+
case ErrorCode::kError:
case ErrorCode::kDownloadTransferError:
case ErrorCode::kDownloadWriteError:
case ErrorCode::kDownloadStateInitializationError:
- case ErrorCode::kOmahaErrorInHTTPResponse: // Aggregate for HTTP errors.
+ case ErrorCode::kOmahaErrorInHTTPResponse: // Aggregate for HTTP errors.
IncrementFailureCount();
break;
@@ -497,7 +498,7 @@ void PayloadState::UpdateBackoffExpiryTime() {
// Since we're doing left-shift below, make sure we don't shift more
// than this. E.g. if int is 4-bytes, don't left-shift more than 30 bits,
// since we don't expect value of kMaxBackoffDays to be more than 100 anyway.
- int num_days = 1; // the value to be shifted.
+ int num_days = 1; // the value to be shifted.
const int kMaxShifts = (sizeof(num_days) * 8) - 2;
// Normal backoff days is 2 raised to (payload_attempt_number - 1).
@@ -896,14 +897,14 @@ void PayloadState::ResetPersistedState() {
SetUrlIndex(0);
SetUrlFailureCount(0);
SetUrlSwitchCount(0);
- UpdateBackoffExpiryTime(); // This will reset the backoff expiry time.
+ UpdateBackoffExpiryTime(); // This will reset the backoff expiry time.
SetUpdateTimestampStart(system_state_->clock()->GetWallclockTime());
- SetUpdateTimestampEnd(Time()); // Set to null time
+ SetUpdateTimestampEnd(Time()); // Set to null time
SetUpdateDurationUptime(TimeDelta::FromSeconds(0));
ResetDownloadSourcesOnNewUpdate();
ResetRollbackVersion();
SetP2PNumAttempts(0);
- SetP2PFirstAttemptTimestamp(Time()); // Set to null time
+ SetP2PFirstAttemptTimestamp(Time()); // Set to null time
}
void PayloadState::ResetRollbackVersion() {
@@ -1334,8 +1335,8 @@ void PayloadState::BootedIntoUpdate(TimeDelta time_to_reboot) {
string metric = "Installer.TimeToRebootMinutes";
system_state_->metrics_lib()->SendToUMA(metric,
time_to_reboot.InMinutes(),
- 0, // min: 0 minute
- 30*24*60, // max: 1 month (approx)
+ 0, // min: 0 minute
+ 30*24*60, // max: 1 month (approx)
kNumDefaultUmaBuckets);
LOG(INFO) << "Uploading " << utils::FormatTimeDelta(time_to_reboot)
<< " for metric " << metric;
@@ -1343,8 +1344,8 @@ void PayloadState::BootedIntoUpdate(TimeDelta time_to_reboot) {
metric = metrics::kMetricTimeToRebootMinutes;
system_state_->metrics_lib()->SendToUMA(metric,
time_to_reboot.InMinutes(),
- 0, // min: 0 minute
- 30*24*60, // max: 1 month (approx)
+ 0, // min: 0 minute
+ 30*24*60, // max: 1 month (approx)
kNumDefaultUmaBuckets);
LOG(INFO) << "Uploading " << utils::FormatTimeDelta(time_to_reboot)
<< " for metric " << metric;
@@ -1392,7 +1393,7 @@ void PayloadState::ReportFailedBootIfNeeded() {
LOG(ERROR) << "Error reading TargetVersionInstalledFrom on reboot.";
return;
}
- if (int(installed_from) ==
+ if (static_cast<int>(installed_from) ==
utils::GetPartitionNumber(system_state_->hardware()->BootDevice())) {
// A reboot was pending, but the chromebook is again in the same
// BootDevice where the update was installed from.
diff --git a/payload_state.h b/payload_state.h
index f8cc678a..b732c4c5 100644
--- a/payload_state.h
+++ b/payload_state.h
@@ -5,6 +5,9 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PAYLOAD_STATE_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PAYLOAD_STATE_H_
+#include <string>
+#include <vector>
+
#include <base/time/time.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index aa04cffb..17f7aeae 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -105,7 +105,7 @@ TEST(PayloadStateTest, SetResponseWorksWithEmptyResponse) {
OmahaResponse response;
FakeSystemState fake_system_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
EXPECT_CALL(*prefs, SetInt64(kPrefsFullPayloadAttemptNumber, 0))
@@ -153,7 +153,7 @@ TEST(PayloadStateTest, SetResponseWorksWithSingleUrl) {
response.metadata_signature = "msign";
FakeSystemState fake_system_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
EXPECT_CALL(*prefs, SetInt64(kPrefsFullPayloadAttemptNumber, 0))
@@ -206,7 +206,7 @@ TEST(PayloadStateTest, SetResponseWorksWithMultipleUrls) {
response.metadata_signature = "metasign";
FakeSystemState fake_system_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
EXPECT_CALL(*prefs, SetInt64(kPrefsFullPayloadAttemptNumber, 0))
@@ -253,7 +253,7 @@ TEST(PayloadStateTest, CanAdvanceUrlIndexCorrectly) {
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
PayloadState payload_state;
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
// Payload attempt should start with 0 and then advance to 1.
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
@@ -367,7 +367,7 @@ TEST(PayloadStateTest, AllCountersGetUpdatedProperlyOnErrorCodesAndEvents) {
int progress_bytes = 100;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(2));
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 1))
@@ -512,7 +512,7 @@ TEST(PayloadStateTest, PayloadAttemptNumberIncreasesOnSuccessfulFullDownload) {
FakeSystemState fake_system_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 1))
@@ -558,7 +558,7 @@ TEST(PayloadStateTest, PayloadAttemptNumberIncreasesOnSuccessfulDeltaDownload) {
FakeSystemState fake_system_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AnyNumber());
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
.Times(AtLeast(1));
EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 1))
@@ -623,7 +623,7 @@ TEST(PayloadStateTest, SetResponseResetsInvalidUrlIndex) {
FakeSystemState fake_system_state2;
NiceMock<PrefsMock>* prefs2 = fake_system_state2.mock_prefs();
EXPECT_CALL(*prefs2, Exists(_)).WillRepeatedly(Return(true));
- EXPECT_CALL(*prefs2, GetInt64(_,_)).Times(AtLeast(1));
+ EXPECT_CALL(*prefs2, GetInt64(_, _)).Times(AtLeast(1));
EXPECT_CALL(*prefs2, GetInt64(kPrefsPayloadAttemptNumber, _))
.Times(AtLeast(1));
EXPECT_CALL(*prefs2, GetInt64(kPrefsFullPayloadAttemptNumber, _))
@@ -657,7 +657,7 @@ TEST(PayloadStateTest, NoBackoffInteractiveChecks) {
PayloadState payload_state;
FakeSystemState fake_system_state;
OmahaRequestParams params(&fake_system_state);
- params.Init("", "", true); // is_interactive = True.
+ params.Init("", "", true); // is_interactive = True.
fake_system_state.set_request_params(&params);
EXPECT_TRUE(payload_state.Initialize(&fake_system_state));
@@ -680,7 +680,7 @@ TEST(PayloadStateTest, NoBackoffForP2PUpdates) {
PayloadState payload_state;
FakeSystemState fake_system_state;
OmahaRequestParams params(&fake_system_state);
- params.Init("", "", false); // is_interactive = False.
+ params.Init("", "", false); // is_interactive = False.
fake_system_state.set_request_params(&params);
EXPECT_TRUE(payload_state.Initialize(&fake_system_state));
@@ -1025,7 +1025,7 @@ TEST(PayloadStateTest, NumRebootsIncrementsCorrectly) {
PayloadState payload_state;
NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
- EXPECT_CALL(*prefs, SetInt64(_,_)).Times(AtLeast(0));
+ EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AtLeast(0));
EXPECT_CALL(*prefs, SetInt64(kPrefsNumReboots, 1)).Times(AtLeast(1));
EXPECT_TRUE(payload_state.Initialize(&fake_system_state));
@@ -1148,7 +1148,8 @@ TEST(PayloadStateTest, DurationsAreCorrect) {
PayloadState payload_state2;
EXPECT_TRUE(payload_state2.Initialize(&fake_system_state));
EXPECT_EQ(payload_state2.GetUpdateDuration().InMicroseconds(), 10000000);
- EXPECT_EQ(payload_state2.GetUpdateDurationUptime().InMicroseconds(),10000000);
+ EXPECT_EQ(payload_state2.GetUpdateDurationUptime().InMicroseconds(),
+ 10000000);
// Advance wall-clock by 7 seconds and monotonic clock by 6 seconds
// and check that the durations are increased accordingly.
@@ -1156,7 +1157,8 @@ TEST(PayloadStateTest, DurationsAreCorrect) {
fake_clock.SetMonotonicTime(Time::FromInternalValue(6005000));
payload_state2.UpdateSucceeded();
EXPECT_EQ(payload_state2.GetUpdateDuration().InMicroseconds(), 17000000);
- EXPECT_EQ(payload_state2.GetUpdateDurationUptime().InMicroseconds(),16000000);
+ EXPECT_EQ(payload_state2.GetUpdateDurationUptime().InMicroseconds(),
+ 16000000);
EXPECT_TRUE(utils::RecursiveUnlinkDir(temp_dir));
}
@@ -1824,4 +1826,4 @@ TEST(PayloadStateTest, P2PStateVarsAreClearedOnNewResponse) {
EXPECT_TRUE(utils::RecursiveUnlinkDir(temp_dir));
}
-}
+} // namespace chromeos_update_engine
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
index cc8968be..86b75019 100644
--- a/postinstall_runner_action.cc
+++ b/postinstall_runner_action.cc
@@ -38,7 +38,7 @@ void PostinstallRunnerAction::PerformAction() {
&temp_rootfs_dir_));
ScopedDirRemover temp_dir_remover(temp_rootfs_dir_);
- unsigned long mountflags = MS_RDONLY;
+ unsigned long mountflags = MS_RDONLY; // NOLINT(runtime/int)
int rc = mount(install_device.c_str(),
temp_rootfs_dir_.c_str(),
"ext2",
diff --git a/postinstall_runner_action.h b/postinstall_runner_action.h
index fea0a39d..4e3e6e5c 100644
--- a/postinstall_runner_action.h
+++ b/postinstall_runner_action.h
@@ -49,7 +49,7 @@ class PostinstallRunnerAction : public InstallPlanAction {
const char* powerwash_marker_file_;
// Special ctor + friend declaration for testing purposes.
- PostinstallRunnerAction(const char* powerwash_marker_file)
+ explicit PostinstallRunnerAction(const char* powerwash_marker_file)
: powerwash_marker_created_(false),
powerwash_marker_file_(powerwash_marker_file) {}
diff --git a/prefs.h b/prefs.h
index f05da0a3..0ca221bc 100644
--- a/prefs.h
+++ b/prefs.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H_
+#include <string>
+
#include <base/files/file_path.h>
#include "gtest/gtest_prod.h" // for FRIEND_TEST
#include "update_engine/prefs_interface.h"
diff --git a/prefs_mock.h b/prefs_mock.h
index 5a56ba0e..36efd401 100644
--- a/prefs_mock.h
+++ b/prefs_mock.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_MOCK_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_MOCK_H_
+#include <string>
+
#include "gmock/gmock.h"
#include "update_engine/constants.h"
#include "update_engine/prefs_interface.h"
diff --git a/subprocess.cc b/subprocess.cc
index 5274655d..f2ac17d0 100644
--- a/subprocess.cc
+++ b/subprocess.cc
@@ -109,7 +109,7 @@ char** ArgPointer() {
class ScopedFreeArgPointer {
public:
- ScopedFreeArgPointer(char** arr) : arr_(arr) {}
+ explicit ScopedFreeArgPointer(char** arr) : arr_(arr) {}
~ScopedFreeArgPointer() {
if (!arr_)
return;
@@ -121,7 +121,7 @@ class ScopedFreeArgPointer {
char** arr_;
DISALLOW_COPY_AND_ASSIGN(ScopedFreeArgPointer);
};
-} // namespace {}
+} // namespace
uint32_t Subprocess::Exec(const vector<string>& cmd,
ExecCallback callback,
diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc
index efda13b2..f625519d 100644
--- a/subprocess_unittest.cc
+++ b/subprocess_unittest.cc
@@ -66,7 +66,7 @@ gboolean LaunchEchoInMainLoop(gpointer data) {
Subprocess::Get().Exec(cmd, CallbackEcho, data);
return FALSE;
}
-} // namespace {}
+} // namespace
TEST(SubprocessTest, SimpleTest) {
GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -154,7 +154,8 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
const char* listening_port_str =
line + strlen(kServerListeningMsgPrefix);
char* end_ptr;
- long raw_port = strtol(listening_port_str, &end_ptr, 10);
+ long raw_port = strtol(listening_port_str, // NOLINT(runtime/int)
+ &end_ptr, 10);
CHECK(!*end_ptr || *end_ptr == '\n');
local_server_port = static_cast<in_port_t>(raw_port);
break;
@@ -173,7 +174,7 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
Subprocess::Get().CancelExec(tag);
return FALSE;
}
-} // namespace {}
+} // namespace
gboolean ExitWhenDone(gpointer data) {
CancelTestData* cancel_test_data = reinterpret_cast<CancelTestData*>(data);
diff --git a/terminator_unittest.cc b/terminator_unittest.cc
index 68d4d136..0096c0cf 100644
--- a/terminator_unittest.cc
+++ b/terminator_unittest.cc
@@ -7,7 +7,6 @@
#include "update_engine/terminator.h"
-using std::string;
using testing::ExitedWithCode;
namespace chromeos_update_engine {
@@ -36,7 +35,7 @@ void UnblockExitThroughUnblocker() {
void RaiseSIGTERM() {
ASSERT_EXIT(raise(SIGTERM), ExitedWithCode(2), "");
}
-} // namespace {}
+} // namespace
TEST_F(TerminatorTest, HandleSignalTest) {
Terminator::set_exit_blocked(true);
diff --git a/test_http_server.cc b/test_http_server.cc
index a94f5542..f5f9202e 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -455,7 +455,7 @@ void HandleDefault(int fd, const HttpRequest& request) {
// Break a URL into terms delimited by slashes.
class UrlTerms {
public:
- UrlTerms(string &url, size_t num_terms) {
+ UrlTerms(const string &url, size_t num_terms) {
// URL must be non-empty and start with a slash.
CHECK_GT(url.size(), static_cast<size_t>(0));
CHECK_EQ(url[0], '/');
@@ -476,8 +476,8 @@ class UrlTerms {
inline int GetInt(const off_t index) const {
return atoi(GetCStr(index));
}
- inline long GetLong(const off_t index) const {
- return atol(GetCStr(index));
+ inline size_t GetSizeT(const off_t index) const {
+ return static_cast<size_t>(atol(GetCStr(index)));
}
private:
@@ -494,18 +494,18 @@ void HandleConnection(int fd) {
HandleQuit(fd);
} else if (StartsWithASCII(url, "/download/", true)) {
const UrlTerms terms(url, 2);
- HandleGet(fd, request, terms.GetLong(1));
+ HandleGet(fd, request, terms.GetSizeT(1));
} else if (StartsWithASCII(url, "/flaky/", true)) {
const UrlTerms terms(url, 5);
- HandleGet(fd, request, terms.GetLong(1), terms.GetLong(2), terms.GetLong(3),
- terms.GetLong(4));
+ HandleGet(fd, request, terms.GetSizeT(1), terms.GetSizeT(2),
+ terms.GetInt(3), terms.GetInt(4));
} else if (url.find("/redirect/") == 0) {
HandleRedirect(fd, request);
} else if (url == "/error") {
HandleError(fd, request);
} else if (StartsWithASCII(url, "/error-if-offset/", true)) {
const UrlTerms terms(url, 3);
- HandleErrorIfOffset(fd, request, terms.GetLong(1), terms.GetInt(2));
+ HandleErrorIfOffset(fd, request, terms.GetSizeT(1), terms.GetInt(2));
} else {
HandleDefault(fd, request);
}
@@ -515,7 +515,7 @@ void HandleConnection(int fd) {
} // namespace chromeos_update_engine
-using namespace chromeos_update_engine;
+using namespace chromeos_update_engine; // NOLINT(build/namespaces)
void usage(const char *prog_arg) {
diff --git a/test_utils.cc b/test_utils.cc
index 7e03ef19..b452ca35 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -301,7 +301,7 @@ void VerifyAllPaths(const string& parent, set<string> expected_paths) {
ScopedLoopMounter::ScopedLoopMounter(const string& file_path,
string* mnt_path,
- unsigned long flags) {
+ unsigned long flags) { // NOLINT - long
EXPECT_TRUE(utils::MakeTempDirectory("mnt.XXXXXX", mnt_path));
dir_remover_.reset(new ScopedDirRemover(*mnt_path));
diff --git a/test_utils.h b/test_utils.h
index 120f0808..ec191f83 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -70,7 +70,7 @@ inline int Chdir(const std::string& path) {
void FillWithData(std::vector<char>* buffer);
-namespace {
+namespace { // NOLINT(build/namespaces) - anon. NS in header file.
// 300 byte pseudo-random string. Not null terminated.
// This does not gzip compress well.
const unsigned char kRandomString[] = {
@@ -114,7 +114,7 @@ const unsigned char kRandomString[] = {
0xbe, 0x9f, 0xa3, 0x5d
};
-} // namespace {}
+} // namespace
// Creates an empty ext image.
void CreateEmptyExtImageAtPath(const std::string& path,
@@ -263,7 +263,7 @@ class ScopedLoopMounter {
public:
explicit ScopedLoopMounter(const std::string& file_path,
std::string* mnt_path,
- unsigned long flags);
+ unsigned long flags); // NOLINT(runtime/int)
private:
// These objects must be destructed in the following order:
diff --git a/update_attempter.cc b/update_attempter.cc
index 46a798b5..520d9c9e 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -6,8 +6,10 @@
#include <algorithm>
#include <memory>
+#include <set>
#include <string>
#include <vector>
+#include <utility>
#include <base/file_util.h>
#include <base/logging.h>
@@ -62,7 +64,7 @@ const int kMaxConsecutiveObeyProxyRequests = 20;
const char* kUpdateCompletedMarker =
"/var/run/update_engine_autoupdate_completed";
-} // namespace {}
+} // namespace
const char* UpdateStatusToString(UpdateStatus status) {
switch (status) {
@@ -368,8 +370,7 @@ bool UpdateAttempter::CalculateUpdateParams(const string& app_version,
if (!device_policy->GetReleaseChannelDelegated(&delegated) || delegated) {
LOG(INFO) << "Channel settings are delegated to user by policy. "
"Ignoring ReleaseChannel policy value";
- }
- else {
+ } else {
LOG(INFO) << "Channel settings are not delegated to the user by policy";
string target_channel;
if (device_policy->GetReleaseChannel(&target_channel) &&
@@ -439,7 +440,7 @@ void UpdateAttempter::CalculateScatteringParams(bool interactive) {
if (device_policy) {
int64 new_scatter_factor_in_secs = 0;
device_policy->GetScatterFactorInSeconds(&new_scatter_factor_in_secs);
- if (new_scatter_factor_in_secs < 0) // sanitize input, just in case.
+ if (new_scatter_factor_in_secs < 0) // sanitize input, just in case.
new_scatter_factor_in_secs = 0;
scatter_factor_ = TimeDelta::FromSeconds(new_scatter_factor_in_secs);
}
@@ -482,8 +483,7 @@ void UpdateAttempter::CalculateScatteringParams(bool interactive) {
LOG(INFO) << "Using persisted wall-clock waiting period: " <<
utils::FormatSecs(
omaha_request_params_->waiting_period().InSeconds());
- }
- else {
+ } else {
// This means there's no persisted value for the waiting period
// available or its value is invalid given the new scatter_factor value.
// So, we should go ahead and regenerate a new value for the
@@ -741,14 +741,14 @@ std::string UpdateAttempter::GetRollbackPartition() const {
system_state_->hardware()->BootKernelDevice();
LOG(INFO) << "UpdateAttempter::GetRollbackPartition";
- for (auto&& name : kernel_devices)
+ for (const auto& name : kernel_devices)
LOG(INFO) << " Available kernel device = " << name;
LOG(INFO) << " Boot kernel device = " << boot_kernel_device;
auto current = std::find(kernel_devices.begin(), kernel_devices.end(),
boot_kernel_device);
- if(current == kernel_devices.end()) {
+ if (current == kernel_devices.end()) {
LOG(ERROR) << "Unable to find the boot kernel device in the list of "
<< "available devices";
return std::string();
diff --git a/update_attempter.h b/update_attempter.h
index 82cba8cb..007da5bd 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -10,6 +10,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <utility>
#include <base/time/time.h>
#include <glib.h>
diff --git a/update_attempter_mock.h b/update_attempter_mock.h
index 3bde3474..7655c42e 100644
--- a/update_attempter_mock.h
+++ b/update_attempter_mock.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_MOCK_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_MOCK_H_
+#include <string>
+
#include "update_engine/update_attempter.h"
#include <gmock/gmock.h>
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index aa0af3e1..43897aa2 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -154,7 +154,7 @@ class UpdateAttempterTest : public ::testing::Test {
NiceMock<MockDBusWrapper> dbus_;
UpdateAttempterUnderTest attempter_;
NiceMock<ActionProcessorMock>* processor_;
- NiceMock<PrefsMock>* prefs_; // shortcut to fake_system_state_->mock_prefs()
+ NiceMock<PrefsMock>* prefs_; // shortcut to fake_system_state_->mock_prefs()
NiceMock<MockConnectionManager> mock_connection_manager;
GMainLoop* loop_;
@@ -410,7 +410,7 @@ gboolean UpdateAttempterTest::StaticNoScatteringDoneDuringManualUpdateTestStart(
namespace {
// Actions that will be built as part of an update check.
-const string kUpdateActionTypes[] = {
+const string kUpdateActionTypes[] = { // NOLINT(runtime/string)
OmahaRequestAction::StaticType(),
OmahaResponseHandlerAction::StaticType(),
FilesystemCopierAction::StaticType(),
@@ -425,12 +425,12 @@ const string kUpdateActionTypes[] = {
};
// Actions that will be built as part of a user-initiated rollback.
-const string kRollbackActionTypes[] = {
+const string kRollbackActionTypes[] = { // NOLINT(runtime/string)
InstallPlanAction::StaticType(),
PostinstallRunnerAction::StaticType(),
};
-} // namespace {}
+} // namespace
void UpdateAttempterTest::UpdateTestStart() {
attempter_.set_http_response_code(200);
@@ -643,7 +643,7 @@ void UpdateAttempterTest::ReadChannelFromPolicyTestStart() {
fake_system_state_.set_device_policy(device_policy);
EXPECT_CALL(*device_policy, GetReleaseChannelDelegated(_)).WillRepeatedly(
- DoAll(SetArgumentPointee<0>(bool(false)),
+ DoAll(SetArgumentPointee<0>(bool(false)), // NOLINT(readability/casting)
Return(true)));
EXPECT_CALL(*device_policy, GetReleaseChannel(_)).WillRepeatedly(
diff --git a/update_check_scheduler_unittest.cc b/update_check_scheduler_unittest.cc
index 79e99749..cd79a23a 100644
--- a/update_check_scheduler_unittest.cc
+++ b/update_check_scheduler_unittest.cc
@@ -205,7 +205,7 @@ TEST_F(UpdateCheckSchedulerTest, ScheduleCheckDisabledTest) {
TEST_F(UpdateCheckSchedulerTest, ScheduleCheckEnabledTest) {
int interval_min, interval_max;
- FuzzRange(100, 10, &interval_min,&interval_max);
+ FuzzRange(100, 10, &interval_min, &interval_max);
EXPECT_CALL(scheduler_,
GTimeoutAddSeconds(AllOf(Ge(interval_min), Le(interval_max)),
scheduler_.StaticCheck)).Times(1);
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 7406b651..516895a8 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -194,7 +194,7 @@ void WatchForUpdates() {
G_TYPE_STRING,
G_TYPE_INT64,
G_TYPE_INVALID);
- GMainLoop* loop = g_main_loop_new (NULL, TRUE);
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
dbus_g_proxy_connect_signal(proxy,
kStatusUpdate,
G_CALLBACK(StatusUpdateSignalHandler),
@@ -393,10 +393,10 @@ static gboolean CompleteUpdateSource(gpointer data) {
}
// This is similar to watching for updates but rather than registering
-// a signal watch, activelly poll the daemon just in case it stops
+// a signal watch, actively poll the daemon just in case it stops
// sending notifications.
void CompleteUpdate() {
- GMainLoop* loop = g_main_loop_new (NULL, TRUE);
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
g_timeout_add_seconds(5, CompleteUpdateSource, NULL);
g_main_loop_run(loop);
g_main_loop_unref(loop);
@@ -529,7 +529,7 @@ bool BlockUntilRebootIsNeeded() {
return ret;
}
-} // namespace {}
+} // namespace
int main(int argc, char** argv) {
// Boilerplate init commands.
@@ -591,9 +591,9 @@ int main(int argc, char** argv) {
if (rollback_partition.empty()) {
rollback_partition = "UNAVAILABLE";
can_rollback = false;
- }
- else
+ } else {
rollback_partition = "AVAILABLE: " + rollback_partition;
+ }
LOG(INFO) << "Rollback partition: " << rollback_partition;
if (!can_rollback) {
@@ -633,7 +633,7 @@ int main(int argc, char** argv) {
return 1;
}
- if(FLAGS_rollback) {
+ if (FLAGS_rollback) {
LOG(INFO) << "Requesting rollback.";
CHECK(Rollback(FLAGS_powerwash)) << "Request for rollback failed.";
}
@@ -654,8 +654,7 @@ int main(int argc, char** argv) {
// These final options are all mutually exclusive with one another.
if (FLAGS_follow + FLAGS_watch_for_updates + FLAGS_reboot +
FLAGS_status + FLAGS_is_reboot_needed +
- FLAGS_block_until_reboot_is_needed > 1)
- {
+ FLAGS_block_until_reboot_is_needed > 1) {
LOG(ERROR) << "Multiple exclusive options selected. "
<< "Select only one of --follow, --watch_for_updates, --reboot, "
<< "--is_reboot_needed, --block_until_reboot_is_needed, "
diff --git a/utils.cc b/utils.cc
index 9e4a4d8e..af536d0c 100644
--- a/utils.cc
+++ b/utils.cc
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <algorithm>
+#include <utility>
#include <vector>
#include <base/file_util.h>
@@ -174,7 +175,6 @@ bool PReadAll(int fd, void* buf, size_t count, off_t offset,
}
*out_bytes_read = bytes_read;
return true;
-
}
// Append |nbytes| of content from |buf| to the vector pointed to by either
@@ -327,7 +327,7 @@ class ScopedDirCloser {
private:
DIR** dir_;
};
-} // namespace {}
+} // namespace
bool RecursiveUnlinkDir(const std::string& path) {
struct stat stbuf;
@@ -527,27 +527,6 @@ bool IsDir(const char* path) {
return S_ISDIR(stbuf.st_mode);
}
-std::string TempFilename(string path) {
- static const string suffix("XXXXXX");
- CHECK(StringHasSuffix(path, suffix));
- do {
- string new_suffix;
- for (unsigned int i = 0; i < suffix.size(); i++) {
- int r = rand() % (26 * 2 + 10); // [a-zA-Z0-9]
- if (r < 26)
- new_suffix.append(1, 'a' + r);
- else if (r < (26 * 2))
- new_suffix.append(1, 'A' + r - 26);
- else
- new_suffix.append(1, '0' + r - (26 * 2));
- }
- CHECK_EQ(new_suffix.size(), suffix.size());
- path.resize(path.size() - new_suffix.size());
- path.append(new_suffix);
- } while (FileExists(path.c_str()));
- return path;
-}
-
// If |path| is absolute, or explicit relative to the current working directory,
// leaves it as is. Otherwise, if TMPDIR is defined in the environment and is
// non-empty, prepends it to |path|. Otherwise, prepends /tmp. Returns the
@@ -612,7 +591,7 @@ bool StringHasPrefix(const std::string& str, const std::string& prefix) {
bool MountFilesystem(const string& device,
const string& mountpoint,
- unsigned long mountflags) {
+ unsigned long mountflags) { // NOLINT(runtime/int)
int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags, NULL);
if (rc < 0) {
string msg = ErrnoNumberAsString(errno);
@@ -802,7 +781,7 @@ namespace {
// consistent stack trace.
gboolean TriggerCrashReporterUpload(void* unused) {
pid_t pid = fork();
- CHECK(pid >= 0) << "fork failed"; // fork() failed. Something is very wrong.
+ CHECK_GE(pid, 0) << "fork failed"; // fork() failed. Something is very wrong.
if (pid == 0) {
// We are the child. Crash.
abort(); // never returns
@@ -812,7 +791,7 @@ gboolean TriggerCrashReporterUpload(void* unused) {
LOG_IF(ERROR, result < 0) << "waitpid() failed";
return FALSE; // Don't call this callback again
}
-} // namespace {}
+} // namespace
void ScheduleCrashReporterUpload() {
g_idle_add(&TriggerCrashReporterUpload, NULL);
@@ -822,8 +801,8 @@ bool SetCpuShares(CpuShares shares) {
string string_shares = base::IntToString(static_cast<int>(shares));
string cpu_shares_file = string(utils::kCGroupDir) + "/cpu.shares";
LOG(INFO) << "Setting cgroup cpu shares to " << string_shares;
- if(utils::WriteFile(cpu_shares_file.c_str(), string_shares.c_str(),
- string_shares.size())){
+ if (utils::WriteFile(cpu_shares_file.c_str(), string_shares.c_str(),
+ string_shares.size())) {
return true;
} else {
LOG(ERROR) << "Failed to change cgroup cpu shares to "<< string_shares
@@ -1184,7 +1163,7 @@ string GetFlagNames(uint32_t code) {
static_cast<uint32_t>(ErrorCode::kSpecialFlags));
string flag_names;
string separator = "";
- for(size_t i = 0; i < sizeof(flags) * 8; i++) {
+ for (size_t i = 0; i < sizeof(flags) * 8; i++) {
uint32_t flag = flags & (1 << i);
if (flag) {
flag_names += separator + CodeToString(static_cast<ErrorCode>(flag));
diff --git a/utils.h b/utils.h
index ed71e9f2..04efffa1 100644
--- a/utils.h
+++ b/utils.h
@@ -5,11 +5,13 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_
-#include <algorithm>
#include <errno.h>
+#include <unistd.h>
+
+#include <algorithm>
+#include <map>
#include <set>
#include <string>
-#include <unistd.h>
#include <vector>
#include <base/files/file_path.h>
@@ -108,13 +110,6 @@ bool IsSymlink(const char* path);
// Returns true if |path| exists and is a directory.
bool IsDir(const char* path);
-// The last 6 chars of path must be XXXXXX. They will be randomly changed
-// and a non-existent path will be returned. Intentionally makes a copy
-// of the string passed in.
-// NEVER CALL THIS FUNCTION UNLESS YOU ARE SURE
-// THAT YOUR PROCESS WILL BE THE ONLY THING WRITING FILES IN THIS DIRECTORY.
-std::string TempFilename(std::string path);
-
// If |base_filename_template| is neither absolute (starts with "/") nor
// explicitly relative to the current working directory (starts with "./" or
// "../"), then it is prepended the value of TMPDIR, which defaults to /tmp if
@@ -184,7 +179,7 @@ bool IsRemovableDevice(const std::string& device);
// Synchronously mount or unmount a filesystem. Return true on success.
// Mounts as ext3 with default options.
bool MountFilesystem(const std::string& device, const std::string& mountpoint,
- unsigned long flags);
+ unsigned long flags); // NOLINT(runtime/int)
bool UnmountFilesystem(const std::string& mountpoint);
// Returns the block count and the block byte size of the ext3 file system on
diff --git a/utils_unittest.cc b/utils_unittest.cc
index 3a4ec6ad..fa97f557 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -96,8 +96,10 @@ TEST(UtilsTest, NormalizePathTest) {
true));
EXPECT_EQ("\\\\", utils::NormalizePath("\\\\", false));
EXPECT_EQ("\\\\", utils::NormalizePath("\\\\", true));
- EXPECT_EQ("\\:/;$PATH\n\\", utils::NormalizePath("\\://;$PATH\n\\", false));
- EXPECT_EQ("\\:/;$PATH\n\\", utils::NormalizePath("\\://;$PATH\n\\", true));
+ EXPECT_EQ("\\:/;$PATH\n\\",
+ utils::NormalizePath("\\://;$PATH\n\\", false));
+ EXPECT_EQ("\\:/;$PATH\n\\",
+ utils::NormalizePath("\\://;$PATH\n\\", true));
EXPECT_EQ("/spaces s/ ok/s / / /",
utils::NormalizePath("/spaces s/ ok/s / / /", false));
EXPECT_EQ("/spaces s/ ok/s / / ",
@@ -212,14 +214,6 @@ TEST(UtilsTest, IsDirTest) {
ASSERT_TRUE(utils::RecursiveUnlinkDir(temp_dir));
}
-TEST(UtilsTest, TempFilenameTest) {
- const string original = "/foo.XXXXXX";
- const string result = utils::TempFilename(original);
- EXPECT_EQ(original.size(), result.size());
- EXPECT_TRUE(utils::StringHasPrefix(result, "/foo."));
- EXPECT_FALSE(utils::StringHasSuffix(result, "XXXXXX"));
-}
-
TEST(UtilsTest, GetDiskNameTest) {
EXPECT_EQ("/dev/sda", utils::GetDiskName("/dev/sda3"));
EXPECT_EQ("/dev/sdp", utils::GetDiskName("/dev/sdp1234"));
@@ -408,7 +402,7 @@ gboolean TerminateScheduleCrashReporterUploadTest(void* arg) {
g_main_loop_quit(loop);
return FALSE; // Don't call this callback again
}
-} // namespace {}
+} // namespace
TEST(UtilsTest, ScheduleCrashReporterUploadTest) {
// Not much to test. At least this tests for memory leaks, crashes,
@@ -551,7 +545,7 @@ TEST(UtilsTest, ConvertToOmahaInstallDate) {
// offset which is one hour. Conveniently, if the function were
// someday modified to be DST aware, this test would have to be
// modified as well.
- const time_t dst_time = 1180940400; // Jun 4, 2007 0:00 PDT.
+ const time_t dst_time = 1180940400; // Jun 4, 2007 0:00 PDT.
const time_t fudge = 3600;
int value1, value2;
EXPECT_TRUE(utils::ConvertToOmahaInstallDate(