clang-format many files.
Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
diff --git a/Utils.cpp b/Utils.cpp
index 002af03..f085c22 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -22,26 +22,26 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
-#include <android-base/strings.h>
#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
#include <cutils/fs.h>
#include <logwrap/logwrap.h>
#include <private/android_filesystem_config.h>
-#include <mutex>
#include <dirent.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <stdlib.h>
#include <sys/mount.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <sys/wait.h>
#include <sys/statvfs.h>
+#include <sys/sysmacros.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <mutex>
#ifndef UMOUNT_NOFOLLOW
-#define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */
+#define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */
#endif
using android::base::ReadFileToString;
@@ -81,8 +81,8 @@
mode_t mode = 0660 | S_IFBLK;
if (mknod(cpath, mode, dev) < 0) {
if (errno != EEXIST) {
- PLOG(ERROR) << "Failed to create device node for " << major(dev)
- << ":" << minor(dev) << " at " << path;
+ PLOG(ERROR) << "Failed to create device node for " << major(dev) << ":" << minor(dev)
+ << " at " << path;
res = -errno;
}
}
@@ -209,8 +209,8 @@
return true;
}
-static status_t readMetadata(const std::string& path, std::string* fsType,
- std::string* fsUuid, std::string* fsLabel, bool untrusted) {
+static status_t readMetadata(const std::string& path, std::string* fsType, std::string* fsUuid,
+ std::string* fsLabel, bool untrusted) {
fsType->clear();
fsUuid->clear();
fsLabel->clear();
@@ -244,13 +244,13 @@
return OK;
}
-status_t ReadMetadata(const std::string& path, std::string* fsType,
- std::string* fsUuid, std::string* fsLabel) {
+status_t ReadMetadata(const std::string& path, std::string* fsType, std::string* fsUuid,
+ std::string* fsLabel) {
return readMetadata(path, fsType, fsUuid, fsLabel, false);
}
-status_t ReadMetadataUntrusted(const std::string& path, std::string* fsType,
- std::string* fsUuid, std::string* fsLabel) {
+status_t ReadMetadataUntrusted(const std::string& path, std::string* fsType, std::string* fsUuid,
+ std::string* fsLabel) {
return readMetadata(path, fsType, fsUuid, fsLabel, true);
}
@@ -261,9 +261,9 @@
status_t ForkExecvp(const std::vector<std::string>& args, security_context_t context) {
std::lock_guard<std::mutex> lock(kSecurityLock);
size_t argc = args.size();
- char** argv = (char**) calloc(argc, sizeof(char*));
+ char** argv = (char**)calloc(argc, sizeof(char*));
for (size_t i = 0; i < argc; i++) {
- argv[i] = (char*) args[i].c_str();
+ argv[i] = (char*)args[i].c_str();
if (i == 0) {
LOG(VERBOSE) << args[i];
} else {
@@ -289,13 +289,12 @@
return res;
}
-status_t ForkExecvp(const std::vector<std::string>& args,
- std::vector<std::string>& output) {
+status_t ForkExecvp(const std::vector<std::string>& args, std::vector<std::string>& output) {
return ForkExecvp(args, output, nullptr);
}
-status_t ForkExecvp(const std::vector<std::string>& args,
- std::vector<std::string>& output, security_context_t context) {
+status_t ForkExecvp(const std::vector<std::string>& args, std::vector<std::string>& output,
+ security_context_t context) {
std::lock_guard<std::mutex> lock(kSecurityLock);
std::string cmd;
for (size_t i = 0; i < args.size(); i++) {
@@ -314,7 +313,7 @@
abort();
}
}
- FILE* fp = popen(cmd.c_str(), "r"); // NOLINT
+ FILE* fp = popen(cmd.c_str(), "r"); // NOLINT
if (context) {
if (setexeccon(nullptr)) {
LOG(ERROR) << "Failed to setexeccon";
@@ -341,9 +340,9 @@
pid_t ForkExecvpAsync(const std::vector<std::string>& args) {
size_t argc = args.size();
- char** argv = (char**) calloc(argc + 1, sizeof(char*));
+ char** argv = (char**)calloc(argc + 1, sizeof(char*));
for (size_t i = 0; i < argc; i++) {
- argv[i] = (char*) args[i].c_str();
+ argv[i] = (char*)args[i].c_str();
if (i == 0) {
LOG(VERBOSE) << args[i];
} else {
@@ -400,10 +399,10 @@
status_t GenerateRandomUuid(std::string& out) {
status_t res = ReadRandomBytes(16, out);
if (res == OK) {
- out[6] &= 0x0f; /* clear version */
- out[6] |= 0x40; /* set to version 4 */
- out[8] &= 0x3f; /* clear variant */
- out[8] |= 0x80; /* set to IETF variant */
+ out[6] &= 0x0f; /* clear version */
+ out[6] |= 0x40; /* set to version 4 */
+ out[8] &= 0x3f; /* clear variant */
+ out[8] |= 0x80; /* set to IETF variant */
}
return res;
}
@@ -415,24 +414,26 @@
for (size_t i = 0; i < hex.size(); i++) {
int val = 0;
switch (hex[i]) {
- case ' ': case '-': case ':': continue;
- case 'f': case 'F': val = 15; break;
- case 'e': case 'E': val = 14; break;
- case 'd': case 'D': val = 13; break;
- case 'c': case 'C': val = 12; break;
- case 'b': case 'B': val = 11; break;
- case 'a': case 'A': val = 10; break;
- case '9': val = 9; break;
- case '8': val = 8; break;
- case '7': val = 7; break;
- case '6': val = 6; break;
- case '5': val = 5; break;
- case '4': val = 4; break;
- case '3': val = 3; break;
- case '2': val = 2; break;
- case '1': val = 1; break;
- case '0': val = 0; break;
- default: return -EINVAL;
+ // clang-format off
+ case ' ': case '-': case ':': continue;
+ case 'f': case 'F': val = 15; break;
+ case 'e': case 'E': val = 14; break;
+ case 'd': case 'D': val = 13; break;
+ case 'c': case 'C': val = 12; break;
+ case 'b': case 'B': val = 11; break;
+ case 'a': case 'A': val = 10; break;
+ case '9': val = 9; break;
+ case '8': val = 8; break;
+ case '7': val = 7; break;
+ case '6': val = 6; break;
+ case '5': val = 5; break;
+ case '4': val = 4; break;
+ case '3': val = 3; break;
+ case '2': val = 2; break;
+ case '1': val = 1; break;
+ case '0': val = 0; break;
+ default: return -EINVAL;
+ // clang-format on
}
if (even) {
@@ -478,7 +479,7 @@
uint64_t GetFreeBytes(const std::string& path) {
struct statvfs sb;
if (statvfs(path.c_str(), &sb) == 0) {
- return (uint64_t) sb.f_bavail * sb.f_frsize;
+ return (uint64_t)sb.f_bavail * sb.f_frsize;
} else {
return -1;
}
@@ -486,7 +487,7 @@
// TODO: borrowed from frameworks/native/libs/diskusage/ which should
// eventually be migrated into system/
-static int64_t stat_size(struct stat *s) {
+static int64_t stat_size(struct stat* s) {
int64_t blksize = s->st_blksize;
// count actual blocks used instead of nominal file size
int64_t size = s->st_blocks * 512;
@@ -504,8 +505,8 @@
int64_t calculate_dir_size(int dfd) {
int64_t size = 0;
struct stat s;
- DIR *d;
- struct dirent *de;
+ DIR* d;
+ struct dirent* de;
d = fdopendir(dfd);
if (d == NULL) {
@@ -514,7 +515,7 @@
}
while ((de = readdir(d))) {
- const char *name = de->d_name;
+ const char* name = de->d_name;
if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
size += stat_size(&s);
}
@@ -523,10 +524,8 @@
/* always skip "." and ".." */
if (name[0] == '.') {
- if (name[1] == 0)
- continue;
- if ((name[1] == '.') && (name[2] == 0))
- continue;
+ if (name[1] == 0) continue;
+ if ((name[1] == '.') && (name[2] == 0)) continue;
}
subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
@@ -576,7 +575,7 @@
}
range[0] = 0;
- range[1] = (unsigned long long) nr_sec * 512;
+ range[1] = (unsigned long long)nr_sec * 512;
LOG(INFO) << "About to discard " << range[1] << " on " << path;
if (ioctl(fd, BLKDISCARD, &range) == 0) {
@@ -592,8 +591,7 @@
}
static bool isValidFilename(const std::string& name) {
- if (name.empty() || (name == ".") || (name == "..")
- || (name.find('/') != std::string::npos)) {
+ if (name.empty() || (name == ".") || (name == "..") || (name.find('/') != std::string::npos)) {
return false;
} else {
return true;
@@ -713,8 +711,7 @@
while (true) {
ssize_t size = readlinkat(dirfd, path.c_str(), &buf[0], buf.size());
// Unrecoverable error?
- if (size == -1)
- return false;
+ if (size == -1) return false;
// It fit! (If size == buf.size(), it may have been truncated.)
if (static_cast<size_t>(size) < buf.size()) {
result->assign(&buf[0], size);