Skip to content

Commit 14c8c07

Browse files
committed
clang-format many files.
Test: Format-only changes; treehugger suffices. Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
1 parent 1251ef0 commit 14c8c07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1563
-1722
lines changed

Benchmark.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
#include <thread>
3030

31-
#include <sys/time.h>
3231
#include <sys/resource.h>
32+
#include <sys/time.h>
3333
#include <unistd.h>
3434

3535
using android::base::ReadFileToString;
@@ -50,12 +50,12 @@ constexpr auto kTimeout = 20s;
5050

5151
// RAII class for boosting device performance during benchmarks.
5252
class PerformanceBoost {
53-
private:
53+
private:
5454
int orig_prio;
5555
int orig_ioprio;
5656
IoSchedClass orig_clazz;
5757

58-
public:
58+
public:
5959
PerformanceBoost() {
6060
errno = 0;
6161
orig_prio = getpriority(PRIO_PROCESS, 0);
@@ -87,8 +87,8 @@ class PerformanceBoost {
8787
};
8888

8989
static status_t benchmarkInternal(const std::string& rootPath,
90-
const android::sp<android::os::IVoldTaskListener>& listener,
91-
android::os::PersistableBundle* extras) {
90+
const android::sp<android::os::IVoldTaskListener>& listener,
91+
android::os::PersistableBundle* extras) {
9292
status_t res = 0;
9393

9494
auto path = rootPath;
@@ -179,7 +179,7 @@ static status_t benchmarkInternal(const std::string& rootPath,
179179
}
180180

181181
void Benchmark(const std::string& path,
182-
const android::sp<android::os::IVoldTaskListener>& listener) {
182+
const android::sp<android::os::IVoldTaskListener>& listener) {
183183
std::lock_guard<std::mutex> lock(kBenchmarkLock);
184184
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
185185

Benchmark.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
namespace android {
2525
namespace vold {
2626

27+
// clang-format off
2728
void Benchmark(const std::string& path,
28-
const android::sp<android::os::IVoldTaskListener>& listener);
29+
const android::sp<android::os::IVoldTaskListener>& listener);
30+
// clang-format on
2931

3032
} // namespace vold
3133
} // namespace android

Devmapper.cpp

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@
1616

1717
#define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER
1818

19+
#include <errno.h>
20+
#include <fcntl.h>
1921
#include <stdio.h>
2022
#include <stdlib.h>
21-
#include <fcntl.h>
22-
#include <unistd.h>
23-
#include <errno.h>
2423
#include <string.h>
25-
#include <stdlib.h>
24+
#include <unistd.h>
2625

27-
#include <sys/types.h>
2826
#include <sys/ioctl.h>
2927
#include <sys/stat.h>
28+
#include <sys/types.h>
3029

3130
#include <linux/kdev_t.h>
3231

3332
#include <android-base/logging.h>
34-
#include <android-base/strings.h>
3533
#include <android-base/stringprintf.h>
34+
#include <android-base/strings.h>
3635
#include <utils/Trace.h>
3736

3837
#include "Devmapper.h"
@@ -43,8 +42,7 @@ using android::base::StringPrintf;
4342

4443
static const char* kVoldPrefix = "vold:";
4544

46-
void Devmapper::ioctlInit(struct dm_ioctl *io, size_t dataSize,
47-
const char *name, unsigned flags) {
45+
void Devmapper::ioctlInit(struct dm_ioctl* io, size_t dataSize, const char* name, unsigned flags) {
4846
memset(io, 0, dataSize);
4947
io->data_size = dataSize;
5048
io->data_start = sizeof(struct dm_ioctl);
@@ -54,17 +52,16 @@ void Devmapper::ioctlInit(struct dm_ioctl *io, size_t dataSize,
5452
io->flags = flags;
5553
if (name) {
5654
size_t ret = strlcpy(io->name, name, sizeof(io->name));
57-
if (ret >= sizeof(io->name))
58-
abort();
55+
if (ret >= sizeof(io->name)) abort();
5956
}
6057
}
6158

62-
int Devmapper::create(const char *name_raw, const char *loopFile, const char *key,
63-
unsigned long numSectors, char *ubuffer, size_t len) {
59+
int Devmapper::create(const char* name_raw, const char* loopFile, const char* key,
60+
unsigned long numSectors, char* ubuffer, size_t len) {
6461
auto name_string = StringPrintf("%s%s", kVoldPrefix, name_raw);
6562
const char* name = name_string.c_str();
6663

67-
char *buffer = (char *) malloc(DEVMAPPER_BUFFER_SIZE);
64+
char* buffer = (char*)malloc(DEVMAPPER_BUFFER_SIZE);
6865
if (!buffer) {
6966
PLOG(ERROR) << "Failed malloc";
7067
return -1;
@@ -77,8 +74,8 @@ int Devmapper::create(const char *name_raw, const char *loopFile, const char *ke
7774
return -1;
7875
}
7976

80-
struct dm_ioctl *io = (struct dm_ioctl *) buffer;
81-
77+
struct dm_ioctl* io = (struct dm_ioctl*)buffer;
78+
8279
// Create the DM device
8380
ioctlInit(io, DEVMAPPER_BUFFER_SIZE, name, 0);
8481

@@ -92,11 +89,11 @@ int Devmapper::create(const char *name_raw, const char *loopFile, const char *ke
9289
// Set the legacy geometry
9390
ioctlInit(io, DEVMAPPER_BUFFER_SIZE, name, 0);
9491

95-
char *geoParams = buffer + sizeof(struct dm_ioctl);
92+
char* geoParams = buffer + sizeof(struct dm_ioctl);
9693
// bps=512 spc=8 res=32 nft=2 sec=8190 mid=0xf0 spt=63 hds=64 hid=0 bspf=8 rdcl=2 infs=1 bkbs=2
9794
strlcpy(geoParams, "0 64 63 0", DEVMAPPER_BUFFER_SIZE - sizeof(struct dm_ioctl));
9895
geoParams += strlen(geoParams) + 1;
99-
geoParams = (char *) _align(geoParams, 8);
96+
geoParams = (char*)_align(geoParams, 8);
10097
if (ioctl(fd, DM_DEV_SET_GEOMETRY, io)) {
10198
PLOG(ERROR) << "Failed DM_DEV_SET_GEOMETRY";
10299
free(buffer);
@@ -117,8 +114,8 @@ int Devmapper::create(const char *name_raw, const char *loopFile, const char *ke
117114
snprintf(ubuffer, len, "/dev/block/dm-%u", minor);
118115

119116
// Load the table
120-
struct dm_target_spec *tgt;
121-
tgt = (struct dm_target_spec *) &buffer[sizeof(struct dm_ioctl)];
117+
struct dm_target_spec* tgt;
118+
tgt = (struct dm_target_spec*)&buffer[sizeof(struct dm_ioctl)];
122119

123120
ioctlInit(io, DEVMAPPER_BUFFER_SIZE, name, DM_STATUS_TABLE_FLAG);
124121
io->target_count = 1;
@@ -129,12 +126,12 @@ int Devmapper::create(const char *name_raw, const char *loopFile, const char *ke
129126

130127
strlcpy(tgt->target_type, "crypt", sizeof(tgt->target_type));
131128

132-
char *cryptParams = buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
129+
char* cryptParams = buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
133130
snprintf(cryptParams,
134-
DEVMAPPER_BUFFER_SIZE - (sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec)),
135-
"twofish %s 0 %s 0", key, loopFile);
131+
DEVMAPPER_BUFFER_SIZE - (sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec)),
132+
"twofish %s 0 %s 0", key, loopFile);
136133
cryptParams += strlen(cryptParams) + 1;
137-
cryptParams = (char *) _align(cryptParams, 8);
134+
cryptParams = (char*)_align(cryptParams, 8);
138135
tgt->next = cryptParams - buffer;
139136

140137
if (ioctl(fd, DM_TABLE_LOAD, io)) {
@@ -160,11 +157,11 @@ int Devmapper::create(const char *name_raw, const char *loopFile, const char *ke
160157
return 0;
161158
}
162159

163-
int Devmapper::destroy(const char *name_raw) {
160+
int Devmapper::destroy(const char* name_raw) {
164161
auto name_string = StringPrintf("%s%s", kVoldPrefix, name_raw);
165162
const char* name = name_string.c_str();
166163

167-
char *buffer = (char *) malloc(DEVMAPPER_BUFFER_SIZE);
164+
char* buffer = (char*)malloc(DEVMAPPER_BUFFER_SIZE);
168165
if (!buffer) {
169166
PLOG(ERROR) << "Failed malloc";
170167
return -1;
@@ -177,8 +174,8 @@ int Devmapper::destroy(const char *name_raw) {
177174
return -1;
178175
}
179176

180-
struct dm_ioctl *io = (struct dm_ioctl *) buffer;
181-
177+
struct dm_ioctl* io = (struct dm_ioctl*)buffer;
178+
182179
// Create the DM device
183180
ioctlInit(io, DEVMAPPER_BUFFER_SIZE, name, 0);
184181

@@ -198,14 +195,14 @@ int Devmapper::destroy(const char *name_raw) {
198195

199196
int Devmapper::destroyAll() {
200197
ATRACE_NAME("Devmapper::destroyAll");
201-
char *buffer = (char *) malloc(1024 * 64);
198+
char* buffer = (char*)malloc(1024 * 64);
202199
if (!buffer) {
203200
PLOG(ERROR) << "Failed malloc";
204201
return -1;
205202
}
206203
memset(buffer, 0, (1024 * 64));
207204

208-
char *buffer2 = (char *) malloc(DEVMAPPER_BUFFER_SIZE);
205+
char* buffer2 = (char*)malloc(DEVMAPPER_BUFFER_SIZE);
209206
if (!buffer2) {
210207
PLOG(ERROR) << "Failed malloc";
211208
free(buffer);
@@ -220,7 +217,7 @@ int Devmapper::destroyAll() {
220217
return -1;
221218
}
222219

223-
struct dm_ioctl *io = (struct dm_ioctl *) buffer;
220+
struct dm_ioctl* io = (struct dm_ioctl*)buffer;
224221
ioctlInit(io, (1024 * 64), NULL, 0);
225222

226223
if (ioctl(fd, DM_LIST_DEVICES, io)) {
@@ -231,7 +228,7 @@ int Devmapper::destroyAll() {
231228
return -1;
232229
}
233230

234-
struct dm_name_list *n = (struct dm_name_list *) (((char *) buffer) + io->data_start);
231+
struct dm_name_list* n = (struct dm_name_list*)(((char*)buffer) + io->data_start);
235232
if (!n->dev) {
236233
free(buffer);
237234
free(buffer2);
@@ -241,13 +238,13 @@ int Devmapper::destroyAll() {
241238

242239
unsigned nxt = 0;
243240
do {
244-
n = (struct dm_name_list *) (((char *) n) + nxt);
241+
n = (struct dm_name_list*)(((char*)n) + nxt);
245242
auto name = std::string(n->name);
246243
if (android::base::StartsWith(name, kVoldPrefix)) {
247244
LOG(DEBUG) << "Tearing down stale dm device named " << name;
248245

249246
memset(buffer2, 0, DEVMAPPER_BUFFER_SIZE);
250-
struct dm_ioctl *io2 = (struct dm_ioctl *) buffer2;
247+
struct dm_ioctl* io2 = (struct dm_ioctl*)buffer2;
251248
ioctlInit(io2, DEVMAPPER_BUFFER_SIZE, n->name, 0);
252249
if (ioctl(fd, DM_DEV_REMOVE, io2)) {
253250
if (errno != ENXIO) {
@@ -266,9 +263,8 @@ int Devmapper::destroyAll() {
266263
return 0;
267264
}
268265

269-
void *Devmapper::_align(void *ptr, unsigned int a)
270-
{
271-
unsigned long agn = --a;
266+
void* Devmapper::_align(void* ptr, unsigned int a) {
267+
unsigned long agn = --a;
272268

273-
return (void *) (((unsigned long) ptr + agn) & ~agn);
269+
return (void*)(((unsigned long)ptr + agn) & ~agn);
274270
}

Devmapper.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@
1717
#ifndef _DEVMAPPER_H
1818
#define _DEVMAPPER_H
1919

20-
#include <unistd.h>
2120
#include <linux/dm-ioctl.h>
21+
#include <unistd.h>
2222

2323
class Devmapper {
24-
public:
25-
static int create(const char *name, const char *loopFile, const char *key,
26-
unsigned long numSectors, char *buffer, size_t len);
27-
static int destroy(const char *name);
24+
public:
25+
static int create(const char* name, const char* loopFile, const char* key,
26+
unsigned long numSectors, char* buffer, size_t len);
27+
static int destroy(const char* name);
2828
static int destroyAll();
2929

30-
private:
31-
static void *_align(void *ptr, unsigned int a);
32-
static void ioctlInit(struct dm_ioctl *io, size_t data_size,
33-
const char *name, unsigned flags);
30+
private:
31+
static void* _align(void* ptr, unsigned int a);
32+
static void ioctlInit(struct dm_ioctl* io, size_t data_size, const char* name, unsigned flags);
3433
};
3534

3635
#endif

0 commit comments

Comments
 (0)