update_engine: update to libbase 242728
Made update_engine link with libchrome-242728 and fixed compile
issues due to changes in namespaces and include file layout.
Also removed some of suppressed compiler warnings and fixed the
issues masked by them (e.g. mismatched printf-like specifiers).
Added -Wextra compiler option to enable additional useful warnings
to ensure more strict checking... Had to disable "unused-parameter"
though since we have a lot of functions (mainly in fakes) that do
not use all of their parameters.
BUG=chromium:351593
TEST=Unit tests passed.
CQ-DEPEND=CL:191721
Change-Id: I1aa63a48d5f1f4ea75ba6b00aec7aa5f3bad15c4
Reviewed-on: https://chromium-review.googlesource.com/191510
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/p2p_manager.cc b/p2p_manager.cc
index 596adf1..ddb9bf0 100644
--- a/p2p_manager.cc
+++ b/p2p_manager.cc
@@ -28,9 +28,9 @@
#include <utility>
#include <vector>
-#include <base/file_path.h>
+#include <base/files/file_path.h>
#include <base/logging.h>
-#include <base/stringprintf.h>
+#include <base/strings/stringprintf.h>
#include "update_engine/utils.h"
@@ -63,8 +63,8 @@
virtual ~ConfigurationImpl() {}
- virtual FilePath GetP2PDir() {
- return FilePath(kDefaultP2PDir);
+ virtual base::FilePath GetP2PDir() {
+ return base::FilePath(kDefaultP2PDir);
}
virtual vector<string> GetInitctlArgs(bool is_start) {
@@ -80,7 +80,7 @@
vector<string> args;
args.push_back("p2p-client");
args.push_back(string("--get-url=") + file_id);
- args.push_back(StringPrintf("--minimum-size=%zu", minimum_size));
+ args.push_back(base::StringPrintf("--minimum-size=%zu", minimum_size));
return args;
}
@@ -108,7 +108,7 @@
LookupCallback callback);
virtual bool FileShare(const string& file_id,
size_t expected_size);
- virtual FilePath FileGetPath(const string& file_id);
+ virtual base::FilePath FileGetPath(const string& file_id);
virtual ssize_t FileGetSize(const string& file_id);
virtual ssize_t FileGetExpectedSize(const string& file_id);
virtual bool FileGetVisible(const string& file_id,
@@ -129,7 +129,7 @@
// Gets the on-disk path for |file_id| depending on if the file
// is visible or not.
- FilePath GetPath(const string& file_id, Visibility visibility);
+ base::FilePath GetPath(const string& file_id, Visibility visibility);
// Utility function used by EnsureP2PRunning() and EnsureP2PNotRunning().
bool EnsureP2P(bool should_be_running);
@@ -313,7 +313,7 @@
// Go through all files in the p2p dir and pick the ones that match
// and get their ctime.
- FilePath p2p_dir = configuration_->GetP2PDir();
+ base::FilePath p2p_dir = configuration_->GetP2PDir();
dir = g_dir_open(p2p_dir.value().c_str(), 0, &error);
if (dir == NULL) {
LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": "
@@ -332,7 +332,7 @@
continue;
struct stat statbuf;
- FilePath file = p2p_dir.Append(name);
+ base::FilePath file = p2p_dir.Append(name);
if (stat(file.value().c_str(), &statbuf) != 0) {
PLOG(ERROR) << "Error getting file status for " << file.value();
continue;
@@ -349,7 +349,7 @@
// Delete starting at element num_files_to_keep_.
vector<pair<FilePath, Time> >::const_iterator i;
for (i = matches.begin() + num_files_to_keep_; i < matches.end(); ++i) {
- const FilePath& file = i->first;
+ const base::FilePath& file = i->first;
LOG(INFO) << "Deleting p2p file " << file.value();
if (unlink(file.value().c_str()) != 0) {
PLOG(ERROR) << "Error deleting p2p file " << file.value();
@@ -555,7 +555,7 @@
bool P2PManagerImpl::FileShare(const string& file_id,
size_t expected_size) {
// Check if file already exist.
- FilePath path = FileGetPath(file_id);
+ base::FilePath path = FileGetPath(file_id);
if (!path.empty()) {
// File exists - double check its expected size though.
ssize_t file_expected_size = FileGetExpectedSize(file_id);
@@ -573,7 +573,7 @@
// Before creating the file, bail if statvfs(3) indicates that at
// least twice the size is not available in P2P_DIR.
struct statvfs statvfsbuf;
- FilePath p2p_dir = configuration_->GetP2PDir();
+ base::FilePath p2p_dir = configuration_->GetP2PDir();
if (statvfs(p2p_dir.value().c_str(), &statvfsbuf) != 0) {
PLOG(ERROR) << "Error calling statvfs() for dir " << p2p_dir.value();
return false;
@@ -623,7 +623,7 @@
}
}
- string decimal_size = StringPrintf("%zu", expected_size);
+ string decimal_size = base::StringPrintf("%zu", expected_size);
if (fsetxattr(fd, kCrosP2PFileSizeXAttrName,
decimal_size.c_str(), decimal_size.size(), 0) != 0) {
PLOG(ERROR) << "Error setting xattr " << path.value();
@@ -636,7 +636,7 @@
FilePath P2PManagerImpl::FileGetPath(const string& file_id) {
struct stat statbuf;
- FilePath path;
+ base::FilePath path;
path = GetPath(file_id, kVisible);
if (stat(path.value().c_str(), &statbuf) == 0) {
@@ -654,7 +654,7 @@
bool P2PManagerImpl::FileGetVisible(const string& file_id,
bool *out_result) {
- FilePath path = FileGetPath(file_id);
+ base::FilePath path = FileGetPath(file_id);
if (path.empty()) {
LOG(ERROR) << "No file for id " << file_id;
return false;
@@ -665,7 +665,7 @@
}
bool P2PManagerImpl::FileMakeVisible(const string& file_id) {
- FilePath path = FileGetPath(file_id);
+ base::FilePath path = FileGetPath(file_id);
if (path.empty()) {
LOG(ERROR) << "No file for id " << file_id;
return false;
@@ -676,7 +676,7 @@
return true;
LOG_ASSERT(path.MatchesExtension(kTmpExtension));
- FilePath new_path = path.RemoveExtension();
+ base::FilePath new_path = path.RemoveExtension();
LOG_ASSERT(new_path.MatchesExtension(kP2PExtension));
if (rename(path.value().c_str(), new_path.value().c_str()) != 0) {
PLOG(ERROR) << "Error renaming " << path.value()
@@ -688,7 +688,7 @@
}
ssize_t P2PManagerImpl::FileGetSize(const string& file_id) {
- FilePath path = FileGetPath(file_id);
+ base::FilePath path = FileGetPath(file_id);
if (path.empty())
return -1;
@@ -702,7 +702,7 @@
}
ssize_t P2PManagerImpl::FileGetExpectedSize(const string& file_id) {
- FilePath path = FileGetPath(file_id);
+ base::FilePath path = FileGetPath(file_id);
if (path.empty())
return -1;
@@ -733,7 +733,7 @@
const char* name;
int num_files = 0;
- FilePath p2p_dir = configuration_->GetP2PDir();
+ base::FilePath p2p_dir = configuration_->GetP2PDir();
dir = g_dir_open(p2p_dir.value().c_str(), 0, &error);
if (dir == NULL) {
LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": "