clang-format many files.
Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
diff --git a/FileDeviceUtils.cpp b/FileDeviceUtils.cpp
index bc9f4bd..ce938a9 100644
--- a/FileDeviceUtils.cpp
+++ b/FileDeviceUtils.cpp
@@ -16,15 +16,15 @@
#include "FileDeviceUtils.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/fiemap.h>
+#include <linux/fs.h>
+#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <linux/fs.h>
-#include <linux/fiemap.h>
-#include <mntent.h>
+#include <sys/types.h>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -40,38 +40,33 @@
namespace vold {
// Given a file path, look for the corresponding block device in /proc/mount
-std::string BlockDeviceForPath(const std::string &path)
-{
- std::unique_ptr<FILE, int(*)(FILE*)> mnts(setmntent("/proc/mounts", "re"), endmntent);
+std::string BlockDeviceForPath(const std::string& path) {
+ std::unique_ptr<FILE, int (*)(FILE*)> mnts(setmntent("/proc/mounts", "re"), endmntent);
if (!mnts) {
PLOG(ERROR) << "Unable to open /proc/mounts";
return "";
}
std::string result;
size_t best_length = 0;
- struct mntent *mnt; // getmntent returns a thread local, so it's safe.
+ struct mntent* mnt; // getmntent returns a thread local, so it's safe.
while ((mnt = getmntent(mnts.get())) != nullptr) {
auto l = strlen(mnt->mnt_dir);
- if (l > best_length &&
- path.size() > l &&
- path[l] == '/' &&
+ if (l > best_length && path.size() > l && path[l] == '/' &&
path.compare(0, l, mnt->mnt_dir) == 0) {
- result = mnt->mnt_fsname;
- best_length = l;
+ result = mnt->mnt_fsname;
+ best_length = l;
}
}
if (result.empty()) {
- LOG(ERROR) <<"Didn't find a mountpoint to match path " << path;
+ LOG(ERROR) << "Didn't find a mountpoint to match path " << path;
return "";
}
LOG(DEBUG) << "For path " << path << " block device is " << result;
return result;
}
-std::unique_ptr<struct fiemap> PathFiemap(const std::string &path, uint32_t extent_count)
-{
- android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(
- path.c_str(), O_RDONLY | O_CLOEXEC, 0)));
+std::unique_ptr<struct fiemap> PathFiemap(const std::string& path, uint32_t extent_count) {
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC, 0)));
if (fd == -1) {
if (errno == ENOENT) {
PLOG(DEBUG) << "Unable to open " << path;
@@ -88,7 +83,7 @@
auto mapped = fiemap->fm_mapped_extents;
if (mapped < 1 || mapped > extent_count) {
LOG(ERROR) << "Extent count not in bounds 1 <= " << mapped << " <= " << extent_count
- << " in " << path;
+ << " in " << path;
return nullptr;
}
return fiemap;
@@ -99,10 +94,9 @@
namespace {
-std::unique_ptr<struct fiemap> alloc_fiemap(uint32_t extent_count)
-{
+std::unique_ptr<struct fiemap> alloc_fiemap(uint32_t extent_count) {
size_t allocsize = offsetof(struct fiemap, fm_extents[extent_count]);
- std::unique_ptr<struct fiemap> res(new (::operator new (allocsize)) struct fiemap);
+ std::unique_ptr<struct fiemap> res(new (::operator new(allocsize)) struct fiemap);
memset(res.get(), 0, allocsize);
res->fm_start = 0;
res->fm_length = UINT64_MAX;
@@ -112,4 +106,4 @@
return res;
}
-}
+} // namespace