clang-format many files.
Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
diff --git a/secdiscard.cpp b/secdiscard.cpp
index 25a0826..2d9dc35 100644
--- a/secdiscard.cpp
+++ b/secdiscard.cpp
@@ -18,15 +18,15 @@
#include <string>
#include <vector>
+#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/logging.h>
#include <android-base/unique_fd.h>
@@ -42,23 +42,23 @@
constexpr uint32_t max_extents = 32;
-bool read_command_line(int argc, const char * const argv[], Options &options);
-void usage(const char *progname);
-bool secdiscard_path(const std::string &path);
-bool check_fiemap(const struct fiemap &fiemap, const std::string &path);
+bool read_command_line(int argc, const char* const argv[], Options& options);
+void usage(const char* progname);
+bool secdiscard_path(const std::string& path);
+bool check_fiemap(const struct fiemap& fiemap, const std::string& path);
bool overwrite_with_zeros(int fd, off64_t start, off64_t length);
-}
+} // namespace
-int main(int argc, const char * const argv[]) {
- android::base::InitLogging(const_cast<char **>(argv));
+int main(int argc, const char* const argv[]) {
+ android::base::InitLogging(const_cast<char**>(argv));
Options options;
if (!read_command_line(argc, argv, options)) {
usage(argv[0]);
return -1;
}
- for (auto const &target: options.targets) {
+ for (auto const& target : options.targets) {
// F2FS-specific ioctl
// It requires the below kernel commit merged in v4.16-rc1.
// 1ad71a27124c ("f2fs: add an ioctl to disable GC for specific file")
@@ -70,13 +70,12 @@
// ce767d9a55bc ("f2fs: updates on v4.16-rc1")
#ifndef F2FS_IOC_SET_PIN_FILE
#ifndef F2FS_IOCTL_MAGIC
-#define F2FS_IOCTL_MAGIC 0xf5
+#define F2FS_IOCTL_MAGIC 0xf5
#endif
-#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
-#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
+#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
+#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
#endif
- android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(
- target.c_str(), O_WRONLY, 0)));
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(target.c_str(), O_WRONLY, 0)));
if (fd == -1) {
LOG(ERROR) << "Secure discard open failed for: " << target;
return 0;
@@ -102,29 +101,29 @@
namespace {
-bool read_command_line(int argc, const char * const argv[], Options &options) {
+bool read_command_line(int argc, const char* const argv[], Options& options) {
for (int i = 1; i < argc; i++) {
if (!strcmp("--no-unlink", argv[i])) {
options.unlink = false;
} else if (!strcmp("--", argv[i])) {
- for (int j = i+1; j < argc; j++) {
- if (argv[j][0] != '/') return false; // Must be absolute path
+ for (int j = i + 1; j < argc; j++) {
+ if (argv[j][0] != '/') return false; // Must be absolute path
options.targets.emplace_back(argv[j]);
}
return options.targets.size() > 0;
} else {
- return false; // Unknown option
+ return false; // Unknown option
}
}
- return false; // "--" not found
+ return false; // "--" not found
}
-void usage(const char *progname) {
+void usage(const char* progname) {
fprintf(stderr, "Usage: %s [--no-unlink] -- <absolute path> ...\n", progname);
}
// BLKSECDISCARD all content in "path", if it's small enough.
-bool secdiscard_path(const std::string &path) {
+bool secdiscard_path(const std::string& path) {
auto fiemap = android::vold::PathFiemap(path, max_extents);
if (!fiemap || !check_fiemap(*fiemap, path)) {
return false;
@@ -133,8 +132,8 @@
if (block_device.empty()) {
return false;
}
- android::base::unique_fd fs_fd(TEMP_FAILURE_RETRY(open(
- block_device.c_str(), O_RDWR | O_LARGEFILE | O_CLOEXEC, 0)));
+ android::base::unique_fd fs_fd(
+ TEMP_FAILURE_RETRY(open(block_device.c_str(), O_RDWR | O_LARGEFILE | O_CLOEXEC, 0)));
if (fs_fd == -1) {
PLOG(ERROR) << "Failed to open device " << block_device;
return false;
@@ -153,10 +152,10 @@
}
// Ensure that the FIEMAP covers the file and is OK to discard
-bool check_fiemap(const struct fiemap &fiemap, const std::string &path) {
+bool check_fiemap(const struct fiemap& fiemap, const std::string& path) {
auto mapped = fiemap.fm_mapped_extents;
if (!(fiemap.fm_extents[mapped - 1].fe_flags & FIEMAP_EXTENT_LAST)) {
- LOG(ERROR) << "Extent " << mapped -1 << " was not the last in " << path;
+ LOG(ERROR) << "Extent " << mapped - 1 << " was not the last in " << path;
return false;
}
for (uint32_t i = 0; i < mapped; i++) {
@@ -188,4 +187,4 @@
return true;
}
-}
+} // namespace