Skip to content

Commit ab538f5

Browse files
author
Seppo Takalo
committed
Fix Astyle failures and small typos.
1 parent f6c08b3 commit ab538f5

File tree

11 files changed

+107
-70
lines changed

11 files changed

+107
-70
lines changed

.astyleignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
^TESTS/mbed_hal/trng/pithy
3232
^TESTS/mbed_hal/trng/pithy
3333
^tools
34+
^UNITTESTS

UNITTESTS/features/storage/blockdevice/HeapBlockDevice/test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "gtest/gtest.h"
22
#include "features/storage/blockdevice/HeapBlockDevice.h"
3-
#include "string.h"
3+
#include <string.h>
44
#include "mbed_assert.h"
55

66
#define BLOCK_SIZE (512)
@@ -51,7 +51,7 @@ TEST_F(HeapBlockDeviceTest, get_type)
5151

5252
TEST_F(HeapBlockDeviceTest, erase_program_read)
5353
{
54-
uint8_t *block = new uint8_t[BLOCK_SIZE]{0xaa,0xbb,0xcc};
54+
uint8_t *block = new uint8_t[BLOCK_SIZE] {0xaa, 0xbb, 0xcc};
5555
uint8_t *buf = new uint8_t[BLOCK_SIZE];
5656
EXPECT_EQ(bd.erase(0, BLOCK_SIZE), BD_ERROR_OK);
5757
EXPECT_EQ(bd.program(block, 0, BLOCK_SIZE), BD_ERROR_OK);
@@ -61,7 +61,7 @@ TEST_F(HeapBlockDeviceTest, erase_program_read)
6161
delete[] buf;
6262
}
6363

64-
TEST_F(HeapBlockDeviceTest, use_uninitalized)
64+
TEST_F(HeapBlockDeviceTest, use_uninitialized)
6565
{
6666
mbed::HeapBlockDevice one{DEVICE_SIZE};
6767
uint8_t *buf = new uint8_t[BLOCK_SIZE];
@@ -79,7 +79,7 @@ TEST_F(HeapBlockDeviceTest, over_read)
7979

8080
TEST_F(HeapBlockDeviceTest, over_write)
8181
{
82-
uint8_t *buf = new uint8_t[BLOCK_SIZE]{0xaa,0xbb,0xcc};
82+
uint8_t *buf = new uint8_t[BLOCK_SIZE] {0xaa, 0xbb, 0xcc};
8383
EXPECT_EQ(bd.program(buf, DEVICE_SIZE, BLOCK_SIZE), BD_ERROR_DEVICE_ERROR);
8484
delete[] buf;
8585
}

UNITTESTS/moduletests/storage/blockdevice/SlicingBlockDevice/moduletest.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class VerifyBorders_HeapBlockDevice : public mbed::HeapBlockDevice {
1212
mutable bd_size_t upper_limit;
1313

1414
VerifyBorders_HeapBlockDevice(bd_size_t size)
15-
: HeapBlockDevice(size) {
15+
: HeapBlockDevice(size)
16+
{
1617
borders_crossed = false;
1718
lower_limit = 0;
1819
upper_limit = size;
@@ -21,21 +22,21 @@ class VerifyBorders_HeapBlockDevice : public mbed::HeapBlockDevice {
2122
virtual bool is_valid_read(bd_addr_t addr, bd_size_t size) const
2223
{
2324
borders_crossed |= addr < lower_limit;
24-
borders_crossed |= addr+size > upper_limit;
25+
borders_crossed |= addr + size > upper_limit;
2526
return BlockDevice::is_valid_read(addr, size);
2627
}
2728

2829
virtual bool is_valid_program(bd_addr_t addr, bd_size_t size) const
2930
{
3031
borders_crossed |= addr < lower_limit;
31-
borders_crossed |= addr+size > upper_limit;
32+
borders_crossed |= addr + size > upper_limit;
3233
return BlockDevice::is_valid_program(addr, size);
3334
}
3435

3536
virtual bool is_valid_erase(bd_addr_t addr, bd_size_t size) const
3637
{
3738
borders_crossed |= addr < lower_limit;
38-
borders_crossed |= addr+size > upper_limit;
39+
borders_crossed |= addr + size > upper_limit;
3940
return BlockDevice::is_valid_erase(addr, size);
4041
}
4142
};
@@ -51,7 +52,7 @@ class SlicingBlockModuleTest : public testing::Test {
5152
magic = new uint8_t[BLOCK_SIZE];
5253
buf = new uint8_t[BLOCK_SIZE];
5354
// Generate simple pattern to verify against
54-
for (int i=0; i < BLOCK_SIZE; i++) {
55+
for (int i = 0; i < BLOCK_SIZE; i++) {
5556
magic[i] = 0xaa + i;
5657
}
5758
}
@@ -77,20 +78,20 @@ TEST_F(SlicingBlockModuleTest, constructor)
7778

7879
TEST_F(SlicingBlockModuleTest, slice_in_middle)
7980
{
80-
uint8_t *program = new uint8_t[BLOCK_SIZE]{0xbb,0xbb,0xbb};
81+
uint8_t *program = new uint8_t[BLOCK_SIZE] {0xbb, 0xbb, 0xbb};
8182

8283
//Write magic value to heap block before and after the space for slice
8384
bd.program(magic, 0, BLOCK_SIZE);
84-
bd.program(magic, BLOCK_SIZE*3, BLOCK_SIZE);
85+
bd.program(magic, BLOCK_SIZE * 3, BLOCK_SIZE);
8586

86-
bd.upper_limit = BLOCK_SIZE*3;
87+
bd.upper_limit = BLOCK_SIZE * 3;
8788
bd.lower_limit = BLOCK_SIZE;
8889
bd.borders_crossed = false;
8990

9091
//Skip first block, then create sclicing device, with size of 2 blocks
91-
mbed::SlicingBlockDevice slice(&bd, BLOCK_SIZE, BLOCK_SIZE*3);
92+
mbed::SlicingBlockDevice slice(&bd, BLOCK_SIZE, BLOCK_SIZE * 3);
9293
EXPECT_EQ(slice.init(), BD_ERROR_OK);
93-
EXPECT_EQ(BLOCK_SIZE*2, slice.size());
94+
EXPECT_EQ(BLOCK_SIZE * 2, slice.size());
9495
EXPECT_EQ(bd.borders_crossed, false);
9596

9697
//Program a test value
@@ -101,44 +102,44 @@ TEST_F(SlicingBlockModuleTest, slice_in_middle)
101102
//Verify that blocks before and after the slicing blocks are not touched
102103
bd.read(buf, 0, BLOCK_SIZE);
103104
EXPECT_EQ(0, memcmp(buf, magic, BLOCK_SIZE));
104-
bd.read(buf, BLOCK_SIZE*3, BLOCK_SIZE);
105+
bd.read(buf, BLOCK_SIZE * 3, BLOCK_SIZE);
105106
EXPECT_EQ(0, memcmp(buf, magic, BLOCK_SIZE));
106107
}
107108

108109
TEST_F(SlicingBlockModuleTest, slice_at_the_end)
109110
{
110-
uint8_t *program = new uint8_t[BLOCK_SIZE]{0xbb,0xbb,0xbb};
111+
uint8_t *program = new uint8_t[BLOCK_SIZE] {0xbb, 0xbb, 0xbb};
111112

112113
//Write magic value to heap block before the space for slice
113114
// our bd is 10*BLOCK_SIZE, so sector 7
114-
bd.program(magic, BLOCK_SIZE*7, BLOCK_SIZE);
115+
bd.program(magic, BLOCK_SIZE * 7, BLOCK_SIZE);
115116

116117
//Screate sclicing device, with size of 2 blocks
117118
// Use negative index
118-
mbed::SlicingBlockDevice slice(&bd, -BLOCK_SIZE*2);
119+
mbed::SlicingBlockDevice slice(&bd, -BLOCK_SIZE * 2);
119120
EXPECT_EQ(slice.init(), BD_ERROR_OK);
120-
EXPECT_EQ(BLOCK_SIZE*2, slice.size());
121+
EXPECT_EQ(BLOCK_SIZE * 2, slice.size());
121122

122123
//Program a test value
123124
EXPECT_EQ(slice.program(program, 0, BLOCK_SIZE), BD_ERROR_OK);
124125
EXPECT_EQ(slice.program(program, BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_OK);
125126

126127
//Verify that blocks before and after the slicing blocks are not touched
127-
bd.read(buf, BLOCK_SIZE*7, BLOCK_SIZE);
128+
bd.read(buf, BLOCK_SIZE * 7, BLOCK_SIZE);
128129
EXPECT_EQ(0, memcmp(buf, magic, BLOCK_SIZE));
129130
}
130131

131132
TEST_F(SlicingBlockModuleTest, over_write)
132133
{
133-
uint8_t *program = new uint8_t[BLOCK_SIZE]{0xbb,0xbb,0xbb};
134+
uint8_t *program = new uint8_t[BLOCK_SIZE] {0xbb, 0xbb, 0xbb};
134135

135136
//Screate sclicing device, with size of 2 blocks
136-
mbed::SlicingBlockDevice slice(&bd, BLOCK_SIZE, BLOCK_SIZE*3);
137+
mbed::SlicingBlockDevice slice(&bd, BLOCK_SIZE, BLOCK_SIZE * 3);
137138
EXPECT_EQ(slice.init(), BD_ERROR_OK);
138139

139140
EXPECT_EQ(slice.program(program, 0, BLOCK_SIZE), BD_ERROR_OK);
140141
EXPECT_EQ(slice.program(program, BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_OK);
141142
//Program a test value to address that is one pass the device size
142-
EXPECT_EQ(slice.program(program, 2*BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_DEVICE_ERROR);
143-
143+
EXPECT_EQ(slice.program(program, 2 * BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_DEVICE_ERROR);
144+
delete[] program;
144145
}

UNITTESTS/stubs/mbed_atomic_stub.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,33 @@ uint32_t core_util_atomic_exchange_u32(volatile uint32_t *ptr, uint32_t desiredV
5757

5858
uint8_t core_util_atomic_incr_u8(volatile uint8_t *valuePtr, uint8_t delta)
5959
{
60-
return *valuePtr+=delta;
60+
return *valuePtr += delta;
6161
}
6262

6363
uint16_t core_util_atomic_incr_u16(volatile uint16_t *valuePtr, uint16_t delta)
6464
{
65-
return *valuePtr+=delta;
65+
return *valuePtr += delta;
6666
}
6767

6868
uint32_t core_util_atomic_incr_u32(volatile uint32_t *valuePtr, uint32_t delta)
6969
{
70-
return *valuePtr+=delta;
70+
return *valuePtr += delta;
7171
}
7272

7373

7474
uint8_t core_util_atomic_decr_u8(volatile uint8_t *valuePtr, uint8_t delta)
7575
{
76-
return *valuePtr-=delta;
76+
return *valuePtr -= delta;
7777
}
7878

7979
uint16_t core_util_atomic_decr_u16(volatile uint16_t *valuePtr, uint16_t delta)
8080
{
81-
return *valuePtr-=delta;
81+
return *valuePtr -= delta;
8282
}
8383

8484
uint32_t core_util_atomic_decr_u32(volatile uint32_t *valuePtr, uint32_t delta)
8585
{
86-
return *valuePtr-=delta;
86+
return *valuePtr -= delta;
8787
}
8888

8989

UNITTESTS/target_h/PinNames.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ typedef enum {
3434
} PinName;
3535

3636
typedef enum {
37-
PullNone,
38-
PullUp,
39-
PullDown
37+
PullNone,
38+
PullUp,
39+
PullDown
4040
} PinMode;
4141

4242
typedef enum {

UNITTESTS/target_h/gpio_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
typedef struct {
30-
int unused;
30+
int unused;
3131
} gpio_t;
3232

3333
#ifdef __cplusplus

UNITTESTS/target_h/objects.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,39 @@ struct serial_s {
3434
};
3535

3636
struct dac_s {
37-
int unused;
37+
int unused;
3838
};
3939

4040
struct i2c_s {
41-
int unused;
41+
int unused;
4242
};
4343

4444
struct qspi_s {
45-
int unused;
45+
int unused;
4646
};
4747

4848
struct spi_s {
49-
int unused;
49+
int unused;
5050
};
5151

5252
struct analogin_s {
53-
int unused;
53+
int unused;
5454
};
5555

5656
struct port_s {
57-
int unused;
57+
int unused;
5858
};
5959

6060
struct pwmout_s {
61-
int unused;
61+
int unused;
6262
};
6363

6464
struct flash_s {
65-
int unused;
65+
int unused;
6666
};
6767

6868
struct can_s {
69-
int unused;
69+
int unused;
7070
};
7171

7272
#include "gpio_object.h"

UNITTESTS/target_h/platform/CThunk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CThunk {
4141
}
4242
uint32_t entry(void)
4343
{
44-
44+
4545
return 0;
4646
}
4747
};

UNITTESTS/target_h/rtos/Semaphore.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,22 @@ class Semaphore {
3232
Semaphore(int32_t count = 0) {};
3333
Semaphore(int32_t count, uint16_t max_count) {};
3434
void acquire() {};
35-
bool try_acquire() { return false; };
36-
bool try_acquire_for(uint32_t millisec) { return false; };
37-
bool try_acquire_until(uint64_t millisec) { return false; };
38-
osStatus release(void) {return 0;};
35+
bool try_acquire()
36+
{
37+
return false;
38+
};
39+
bool try_acquire_for(uint32_t millisec)
40+
{
41+
return false;
42+
};
43+
bool try_acquire_until(uint64_t millisec)
44+
{
45+
return false;
46+
};
47+
osStatus release(void)
48+
{
49+
return 0;
50+
};
3951
};
4052
}
4153

UNITTESTS/target_h/rtos/Thread.h

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,31 @@ class Thread {
4242
{
4343
}
4444

45-
osStatus start(mbed::Callback<void()> task) {
46-
return 0;
45+
osStatus start(mbed::Callback<void()> task)
46+
{
47+
return 0;
4748
}
4849

49-
osStatus join() {return 0;};
50-
osStatus terminate(){return 0;};
51-
osStatus set_priority(osPriority priority){return 0;};
52-
osPriority get_priority() const{return osPriorityNormal;};
53-
uint32_t flags_set(uint32_t flags){return 0;};
50+
osStatus join()
51+
{
52+
return 0;
53+
};
54+
osStatus terminate()
55+
{
56+
return 0;
57+
};
58+
osStatus set_priority(osPriority priority)
59+
{
60+
return 0;
61+
};
62+
osPriority get_priority() const
63+
{
64+
return osPriorityNormal;
65+
};
66+
uint32_t flags_set(uint32_t flags)
67+
{
68+
return 0;
69+
};
5470

5571
/** State of the Thread */
5672
enum State {
@@ -75,26 +91,33 @@ class Thread {
7591
Deleted, /**< The task has been deleted or not started */
7692
};
7793

78-
State get_state() const {
79-
return Ready;
94+
State get_state() const
95+
{
96+
return Ready;
8097
};
81-
uint32_t stack_size() const {
82-
return 0;
98+
uint32_t stack_size() const
99+
{
100+
return 0;
83101
};
84-
uint32_t free_stack() const {
85-
return 0;
102+
uint32_t free_stack() const
103+
{
104+
return 0;
86105
};
87-
uint32_t used_stack() const {
88-
return 0;
106+
uint32_t used_stack() const
107+
{
108+
return 0;
89109
};
90-
uint32_t max_stack() const {
91-
return 0;
110+
uint32_t max_stack() const
111+
{
112+
return 0;
92113
};
93-
const char *get_name() const {
94-
return "";
114+
const char *get_name() const
115+
{
116+
return "";
95117
};
96-
osThreadId_t get_id() const {
97-
return 0;
118+
osThreadId_t get_id() const
119+
{
120+
return 0;
98121
};
99122
};
100123
}

0 commit comments

Comments
 (0)