Skip to content

Commit e54ce88

Browse files
committed
storage: fix astyle coding style
1 parent 5c79ba5 commit e54ce88

File tree

30 files changed

+241
-224
lines changed

30 files changed

+241
-224
lines changed

features/storage/TESTS/blockdevice/flashsim_block_device/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void functionality_test()
3838
uint8_t *dummy = new (std::nothrow) uint8_t[num_blocks * erase_size];
3939
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
4040
delete[] dummy;
41-
41+
4242
HeapBlockDevice heap_bd(num_blocks * erase_size, read_size, prog_size, erase_size);
4343
FlashSimBlockDevice bd(&heap_bd, blank);
4444

features/storage/TESTS/blockdevice/general_block_device/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ void basic_erase_program_read_test(BlockDevice *block_device, bd_size_t block_si
8282
int val_rand;
8383
for (bd_size_t i_ind = 0; i_ind < block_size; i_ind++) {
8484
val_rand = rand();
85-
if ( (0xff & val_rand) != read_block[i_ind] ) {
85+
if ((0xff & val_rand) != read_block[i_ind]) {
8686
utest_printf("\n Assert Failed Buf Read - block:size: %llx:%llu \n", block, block_size);
87-
utest_printf("\n pos: %llu, exp: %02x, act: %02x, wrt: %02x \n", i_ind, (0xff & val_rand),
87+
utest_printf("\n pos: %llu, exp: %02x, act: %02x, wrt: %02x \n", i_ind, (0xff & val_rand),
8888
read_block[i_ind],
89-
write_block[i_ind] );
89+
write_block[i_ind]);
9090
}
9191
TEST_ASSERT_EQUAL(0xff & val_rand, read_block[i_ind]);
9292
}
@@ -153,7 +153,7 @@ static void test_thread_job(void *block_device_ptr)
153153
uint8_t *write_block = new (std::nothrow) uint8_t[block_size];
154154
uint8_t *read_block = new (std::nothrow) uint8_t[block_size];
155155

156-
if (!write_block || !read_block ) {
156+
if (!write_block || !read_block) {
157157
utest_printf("\n Not enough memory for test");
158158
goto end;
159159
}

features/storage/TESTS/blockdevice/heap_block_device/main.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using namespace utest::v1;
2525

2626
// TODO HACK, replace with available ram/heap property
2727
#if defined(TARGET_MTB_MTS_XDOT)
28-
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
28+
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
2929
#endif
3030

3131
#define TEST_BLOCK_SIZE 128
@@ -45,7 +45,8 @@ const struct {
4545

4646

4747
// Simple test that read/writes random set of blocks
48-
void test_read_write() {
48+
void test_read_write()
49+
{
4950
uint8_t *dummy = new (std::nothrow) uint8_t[TEST_BLOCK_DEVICE_SIZE];
5051
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
5152
delete[] dummy;
@@ -55,19 +56,19 @@ void test_read_write() {
5556
int err = bd.init();
5657
TEST_ASSERT_EQUAL(0, err);
5758

58-
for (unsigned a = 0; a < sizeof(ATTRS)/sizeof(ATTRS[0]); a++) {
59+
for (unsigned a = 0; a < sizeof(ATTRS) / sizeof(ATTRS[0]); a++) {
5960
static const char *prefixes[] = {"", "k", "M", "G"};
6061
for (int i = 3; i >= 0; i--) {
6162
bd_size_t size = (bd.*ATTRS[a].method)();
62-
if (size >= (1ULL << 10*i)) {
63+
if (size >= (1ULL << 10 * i)) {
6364
printf("%s: %llu%sbytes (%llubytes)\n",
64-
ATTRS[a].name, size >> 10*i, prefixes[i], size);
65+
ATTRS[a].name, size >> 10 * i, prefixes[i], size);
6566
break;
6667
}
6768
}
6869
}
6970

70-
unsigned addrwidth = ceil(log(float(bd.size()-1)) / log(float(16)))+1;
71+
unsigned addrwidth = ceil(log(float(bd.size() - 1)) / log(float(16))) + 1;
7172

7273
bd_size_t block_size = bd.get_erase_size();
7374
uint8_t *write_block = new (std::nothrow) uint8_t[block_size];
@@ -81,7 +82,7 @@ void test_read_write() {
8182

8283
for (int b = 0; b < TEST_BLOCK_COUNT; b++) {
8384
// Find a random block
84-
bd_addr_t block = (rand()*block_size) % bd.size();
85+
bd_addr_t block = (rand() * block_size) % bd.size();
8586

8687
// Use next random number as temporary seed to keep
8788
// the address progressing in the pseudorandom sequence
@@ -119,13 +120,13 @@ void test_read_write() {
119120

120121
// Find error mask for debugging
121122
memset(error_mask, 0, TEST_ERROR_MASK);
122-
bd_size_t error_scale = block_size / (TEST_ERROR_MASK*8);
123+
bd_size_t error_scale = block_size / (TEST_ERROR_MASK * 8);
123124

124125
srand(seed);
125-
for (bd_size_t i = 0; i < TEST_ERROR_MASK*8; i++) {
126+
for (bd_size_t i = 0; i < TEST_ERROR_MASK * 8; i++) {
126127
for (bd_size_t j = 0; j < error_scale; j++) {
127-
if ((0xff & rand()) != read_block[i*error_scale + j]) {
128-
error_mask[i/8] |= 1 << (i%8);
128+
if ((0xff & rand()) != read_block[i * error_scale + j]) {
129+
error_mask[i / 8] |= 1 << (i % 8);
129130
}
130131
}
131132
}
@@ -142,7 +143,7 @@ void test_read_write() {
142143
TEST_ASSERT_EQUAL(0xff & rand(), read_block[i]);
143144
}
144145
}
145-
146+
146147
err = bd.deinit();
147148
TEST_ASSERT_EQUAL(0, err);
148149

@@ -155,7 +156,8 @@ void test_read_write() {
155156

156157

157158
// Test setup
158-
utest::v1::status_t test_setup(const size_t number_of_cases) {
159+
utest::v1::status_t test_setup(const size_t number_of_cases)
160+
{
159161
GREENTEA_SETUP(30, "default_auto");
160162
return verbose_test_setup_handler(number_of_cases);
161163
}
@@ -166,6 +168,7 @@ Case cases[] = {
166168

167169
Specification specification(test_setup, cases);
168170

169-
int main() {
171+
int main()
172+
{
170173
return !Harness::run(specification);
171174
}

features/storage/TESTS/blockdevice/mbr_block_device/main.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ using namespace utest::v1;
2626

2727
// TODO HACK, replace with available ram/heap property
2828
#if defined(TARGET_MTB_MTS_XDOT)
29-
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
29+
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
3030
#endif
3131

3232
#define BLOCK_COUNT 16
3333
#define BLOCK_SIZE 512
3434

35-
HeapBlockDevice bd(BLOCK_COUNT*BLOCK_SIZE, BLOCK_SIZE);
35+
HeapBlockDevice bd(BLOCK_COUNT *BLOCK_SIZE, BLOCK_SIZE);
3636

3737
// Testing formatting of master boot record
3838
void test_mbr_format()
@@ -42,10 +42,10 @@ void test_mbr_format()
4242
delete[] dummy;
4343

4444
// Create two partitions splitting device in ~half
45-
int err = MBRBlockDevice::partition(&bd, 1, 0x83, 0, (BLOCK_COUNT/2)*BLOCK_SIZE);
45+
int err = MBRBlockDevice::partition(&bd, 1, 0x83, 0, (BLOCK_COUNT / 2) * BLOCK_SIZE);
4646
TEST_ASSERT_EQUAL(0, err);
4747

48-
err = MBRBlockDevice::partition(&bd, 2, 0x83, -(BLOCK_COUNT/2)*BLOCK_SIZE);
48+
err = MBRBlockDevice::partition(&bd, 2, 0x83, -(BLOCK_COUNT / 2) * BLOCK_SIZE);
4949
TEST_ASSERT_EQUAL(0, err);
5050

5151
// Load both partitions, as well as a third to check for invalid partitions
@@ -95,13 +95,13 @@ void test_mbr_attr()
9595
printf("partition 1 erase size: %llu bytes\n", part1.get_erase_size());
9696
printf("partition 1 size: %llu bytes\n", part1.size());
9797
TEST_ASSERT_EQUAL(1, part1.get_partition_number());
98-
TEST_ASSERT_EQUAL(1*BLOCK_SIZE, part1.get_partition_start());
99-
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, part1.get_partition_stop());
98+
TEST_ASSERT_EQUAL(1 * BLOCK_SIZE, part1.get_partition_start());
99+
TEST_ASSERT_EQUAL((BLOCK_COUNT / 2)*BLOCK_SIZE, part1.get_partition_stop());
100100
TEST_ASSERT_EQUAL(0x83, part1.get_partition_type());
101101
TEST_ASSERT_EQUAL(BLOCK_SIZE, part1.get_read_size());
102102
TEST_ASSERT_EQUAL(BLOCK_SIZE, part1.get_program_size());
103103
TEST_ASSERT_EQUAL(BLOCK_SIZE, part1.get_erase_size());
104-
TEST_ASSERT_EQUAL(((BLOCK_COUNT/2)-1)*BLOCK_SIZE, part1.size());
104+
TEST_ASSERT_EQUAL(((BLOCK_COUNT / 2) - 1)*BLOCK_SIZE, part1.size());
105105

106106
printf("partition 2 partition number: %d\n", part2.get_partition_number());
107107
printf("partition 2 partition start: 0x%llx\n", part2.get_partition_start());
@@ -112,13 +112,13 @@ void test_mbr_attr()
112112
printf("partition 2 erase size: %llu bytes\n", part2.get_erase_size());
113113
printf("partition 2 size: %llu bytes\n", part2.size());
114114
TEST_ASSERT_EQUAL(2, part2.get_partition_number());
115-
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, part2.get_partition_start());
116-
TEST_ASSERT_EQUAL(BLOCK_COUNT*BLOCK_SIZE, part2.get_partition_stop());
115+
TEST_ASSERT_EQUAL((BLOCK_COUNT / 2)*BLOCK_SIZE, part2.get_partition_start());
116+
TEST_ASSERT_EQUAL(BLOCK_COUNT * BLOCK_SIZE, part2.get_partition_stop());
117117
TEST_ASSERT_EQUAL(0x83, part2.get_partition_type());
118118
TEST_ASSERT_EQUAL(BLOCK_SIZE, part2.get_read_size());
119119
TEST_ASSERT_EQUAL(BLOCK_SIZE, part2.get_program_size());
120120
TEST_ASSERT_EQUAL(BLOCK_SIZE, part2.get_erase_size());
121-
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, part2.size());
121+
TEST_ASSERT_EQUAL((BLOCK_COUNT / 2)*BLOCK_SIZE, part2.size());
122122

123123
// Deinit partitions
124124
err = part1.deinit();
@@ -177,7 +177,7 @@ void test_mbr_read_write()
177177
}
178178

179179
// Check with original block device
180-
err = bd.read(read_block, 1*BLOCK_SIZE, BLOCK_SIZE);
180+
err = bd.read(read_block, 1 * BLOCK_SIZE, BLOCK_SIZE);
181181
TEST_ASSERT_EQUAL(0, err);
182182

183183
// Check that the data was unmodified
@@ -209,7 +209,7 @@ void test_mbr_read_write()
209209
}
210210

211211
// Check with original block device
212-
err = bd.read(read_block, (BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
212+
err = bd.read(read_block, (BLOCK_COUNT / 2) * BLOCK_SIZE, BLOCK_SIZE);
213213
TEST_ASSERT_EQUAL(0, err);
214214

215215
// Check that the data was unmodified
@@ -232,7 +232,8 @@ void test_mbr_read_write()
232232

233233

234234
// Test setup
235-
utest::v1::status_t test_setup(const size_t number_of_cases) {
235+
utest::v1::status_t test_setup(const size_t number_of_cases)
236+
{
236237
GREENTEA_SETUP(10, "default_auto");
237238
return verbose_test_setup_handler(number_of_cases);
238239
}
@@ -245,6 +246,7 @@ Case cases[] = {
245246

246247
Specification specification(test_setup, cases);
247248

248-
int main() {
249+
int main()
250+
{
249251
return !Harness::run(specification);
250252
}

features/storage/TESTS/blockdevice/util_block_device/main.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,34 @@ using namespace utest::v1;
2828

2929
// TODO HACK, replace with available ram/heap property
3030
#if defined(TARGET_MTB_MTS_XDOT)
31-
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
31+
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
3232
#endif
3333

3434
#define BLOCK_COUNT 16
3535
#define BLOCK_SIZE 512
3636

3737

3838
// Simple test which read/writes blocks on a sliced block device
39-
void test_slicing() {
39+
void test_slicing()
40+
{
4041
uint8_t *dummy = new (std::nothrow) uint8_t[BLOCK_COUNT * BLOCK_SIZE];
4142
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
4243
delete[] dummy;
4344

4445
int err;
4546

46-
HeapBlockDevice bd(BLOCK_COUNT*BLOCK_SIZE, BLOCK_SIZE);
47+
HeapBlockDevice bd(BLOCK_COUNT * BLOCK_SIZE, BLOCK_SIZE);
4748

48-
SlicingBlockDevice slice1(&bd, 0, (BLOCK_COUNT/2)*BLOCK_SIZE);
49-
SlicingBlockDevice slice2(&bd, -(BLOCK_COUNT/2)*BLOCK_SIZE);
49+
SlicingBlockDevice slice1(&bd, 0, (BLOCK_COUNT / 2)*BLOCK_SIZE);
50+
SlicingBlockDevice slice2(&bd, -(BLOCK_COUNT / 2)*BLOCK_SIZE);
5051

5152
// Test with first slice of block device
5253
err = slice1.init();
5354
TEST_ASSERT_EQUAL(0, err);
5455

5556
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice1.get_program_size());
5657
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice1.get_erase_size(BLOCK_SIZE));
57-
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, slice1.size());
58+
TEST_ASSERT_EQUAL((BLOCK_COUNT / 2)*BLOCK_SIZE, slice1.size());
5859

5960
uint8_t *write_block = new (std::nothrow) uint8_t[BLOCK_SIZE];
6061
uint8_t *read_block = new (std::nothrow) uint8_t[BLOCK_SIZE];
@@ -97,7 +98,7 @@ void test_slicing() {
9798
TEST_ASSERT_EQUAL(0, err);
9899

99100
TEST_ASSERT_EQUAL(BLOCK_SIZE, slice2.get_program_size());
100-
TEST_ASSERT_EQUAL((BLOCK_COUNT/2)*BLOCK_SIZE, slice2.size());
101+
TEST_ASSERT_EQUAL((BLOCK_COUNT / 2)*BLOCK_SIZE, slice2.size());
101102

102103
// Fill with random sequence
103104
srand(1);
@@ -123,7 +124,7 @@ void test_slicing() {
123124
}
124125

125126
// Check with original block device
126-
err = bd.read(read_block, (BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
127+
err = bd.read(read_block, (BLOCK_COUNT / 2) * BLOCK_SIZE, BLOCK_SIZE);
127128
TEST_ASSERT_EQUAL(0, err);
128129

129130
// Check that the data was unmodified
@@ -141,15 +142,16 @@ void test_slicing() {
141142
}
142143

143144
// Simple test which read/writes blocks on a chain of block devices
144-
void test_chaining() {
145+
void test_chaining()
146+
{
145147
uint8_t *dummy = new (std::nothrow) uint8_t[BLOCK_COUNT * BLOCK_SIZE];
146148
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
147149
delete[] dummy;
148150

149151
int err;
150152

151-
HeapBlockDevice bd1((BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
152-
HeapBlockDevice bd2((BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
153+
HeapBlockDevice bd1((BLOCK_COUNT / 2)*BLOCK_SIZE, BLOCK_SIZE);
154+
HeapBlockDevice bd2((BLOCK_COUNT / 2)*BLOCK_SIZE, BLOCK_SIZE);
153155

154156
// Test with chain of block device
155157
BlockDevice *bds[] = {&bd1, &bd2};
@@ -167,8 +169,8 @@ void test_chaining() {
167169
TEST_ASSERT_EQUAL(0, err);
168170

169171
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_program_size());
170-
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_erase_size((BLOCK_COUNT/2)*BLOCK_SIZE+1));
171-
TEST_ASSERT_EQUAL(BLOCK_COUNT*BLOCK_SIZE, chain.size());
172+
TEST_ASSERT_EQUAL(BLOCK_SIZE, chain.get_erase_size((BLOCK_COUNT / 2)*BLOCK_SIZE + 1));
173+
TEST_ASSERT_EQUAL(BLOCK_COUNT * BLOCK_SIZE, chain.size());
172174

173175
// Fill with random sequence
174176
srand(1);
@@ -190,10 +192,10 @@ void test_chaining() {
190192
}
191193

192194
// Write, sync, and read the block
193-
err = chain.program(write_block, (BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
195+
err = chain.program(write_block, (BLOCK_COUNT / 2) * BLOCK_SIZE, BLOCK_SIZE);
194196
TEST_ASSERT_EQUAL(0, err);
195197

196-
err = chain.read(read_block, (BLOCK_COUNT/2)*BLOCK_SIZE, BLOCK_SIZE);
198+
err = chain.read(read_block, (BLOCK_COUNT / 2) * BLOCK_SIZE, BLOCK_SIZE);
197199
TEST_ASSERT_EQUAL(0, err);
198200

199201
// Check that the data was unmodified
@@ -211,23 +213,24 @@ void test_chaining() {
211213
}
212214

213215
// Simple test which read/writes blocks on a chain of block devices
214-
void test_profiling() {
216+
void test_profiling()
217+
{
215218
uint8_t *dummy = new (std::nothrow) uint8_t[BLOCK_COUNT * BLOCK_SIZE];
216219
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
217220
delete[] dummy;
218221

219222
int err;
220223
bd_size_t read_count, program_count, erase_count;
221224

222-
HeapBlockDevice bd(BLOCK_COUNT*BLOCK_SIZE, BLOCK_SIZE);
225+
HeapBlockDevice bd(BLOCK_COUNT * BLOCK_SIZE, BLOCK_SIZE);
223226
// Test under profiling
224227
ProfilingBlockDevice profiler(&bd);
225228

226229
err = profiler.init();
227230
TEST_ASSERT_EQUAL(0, err);
228231

229232
TEST_ASSERT_EQUAL(BLOCK_SIZE, profiler.get_erase_size());
230-
TEST_ASSERT_EQUAL(BLOCK_COUNT*BLOCK_SIZE, profiler.size());
233+
TEST_ASSERT_EQUAL(BLOCK_COUNT * BLOCK_SIZE, profiler.size());
231234

232235
uint8_t *write_block = new (std::nothrow) uint8_t[BLOCK_SIZE];
233236
uint8_t *read_block = new (std::nothrow) uint8_t[BLOCK_SIZE];
@@ -287,7 +290,8 @@ void test_profiling() {
287290

288291

289292
// Test setup
290-
utest::v1::status_t test_setup(const size_t number_of_cases) {
293+
utest::v1::status_t test_setup(const size_t number_of_cases)
294+
{
291295
GREENTEA_SETUP(10, "default_auto");
292296
return verbose_test_setup_handler(number_of_cases);
293297
}
@@ -300,6 +304,7 @@ Case cases[] = {
300304

301305
Specification specification(test_setup, cases);
302306

303-
int main() {
307+
int main()
308+
{
304309
return !Harness::run(specification);
305310
}

0 commit comments

Comments
 (0)