Skip to content

Commit aaf6d07

Browse files
authored
Merge pull request ARMmbed#128 from ARMmbed/fix/astyle
Format with UC AStyle
2 parents d9cf028 + c2df2f1 commit aaf6d07

13 files changed

+202
-259
lines changed

.astyleignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUILD
2+
scripts

.astylerc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Mbed OS code style definition file for astyle
2+
3+
# Don't create backup files, let git handle it
4+
suffix=none
5+
6+
# K&R style
7+
style=kr
8+
9+
# 1 TBS addition to k&r, add braces to one liners
10+
# Use -j as it was changed in astyle from brackets to braces, this way it is compatible with older astyle versions
11+
-j
12+
13+
# 4 spaces, convert tabs to spaces
14+
indent=spaces=4
15+
convert-tabs
16+
17+
# Indent switches and cases
18+
indent-switches
19+
20+
# Remove spaces in and around parentheses
21+
unpad-paren
22+
23+
# Insert a space after if, while, for, and around operators
24+
pad-header
25+
pad-oper
26+
27+
# Pointer/reference operators go next to the name (on the right)
28+
align-pointer=name
29+
align-reference=name
30+
31+
# Attach { for classes and namespaces
32+
attach-namespaces
33+
attach-classes
34+
35+
# Extend longer lines, define maximum 120 value. This results in aligned code,
36+
# otherwise the lines are broken and not consistent
37+
max-continuation-indent=120
38+
39+
40+
# Style formatting options for Update Client codebase.
41+
42+
# Each line no greater than 120 characters.
43+
--max-code-length=120
44+
45+
# Display only files that have been formatted.
46+
-Q
47+
48+
# Keep one-line blocks, especially for union initialization of error structs.
49+
--keep-one-line-blocks
50+
51+
# Indent pre-processor block
52+
# --indent-preproc-block
53+
54+
# Delete empty lines
55+
# --delete-empty-lines
56+
57+
# Attach the return type to a function definition or declaration.
58+
--attach-return-type # Definition
59+
--attach-return-type-decl # Declaration

firmware_update_test/firmware_update_test.cpp

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void copyAppToSDCard(uint32_t firmware_size)
3636
arm_uc_firmware_details_t details = { 0 };
3737

3838
tr_info("calculate firmware SHA256\r\n");
39-
const uint8_t* appStart =
40-
(const uint8_t*) (MBED_CONF_APP_APPLICATION_START_ADDRESS);
39+
const uint8_t *appStart =
40+
(const uint8_t *)(MBED_CONF_APP_APPLICATION_START_ADDRESS);
4141
mbedtls_sha256(appStart, firmware_size, details.hash, 0);
4242

4343
details.version = UINT32_MAX - 1;
@@ -58,15 +58,11 @@ void copyAppToSDCard(uint32_t firmware_size)
5858
arm_uc_error_t ucp_status = ARM_UCP_Prepare(0, &details, &temp_buffer);
5959

6060
/* wait for event if call was accepted */
61-
if (ucp_status.error == ERR_NONE)
62-
{
63-
while (event_callback == CLEAR_EVENT)
64-
{
61+
if (ucp_status.error == ERR_NONE) {
62+
while (event_callback == CLEAR_EVENT) {
6563
__WFI();
6664
}
67-
}
68-
else
69-
{
65+
} else {
7066
tr_error("ARM_UCP_Prepare failed\r\n");
7167
}
7268

@@ -77,7 +73,7 @@ void copyAppToSDCard(uint32_t firmware_size)
7773
arm_uc_buffer_t write_buffer = {
7874
.size_max = firmware_size,
7975
.size = firmware_size,
80-
.ptr = (uint8_t*) appStart
76+
.ptr = (uint8_t *) appStart
8177
};
8278

8379
/* clear most recent event */
@@ -87,15 +83,11 @@ void copyAppToSDCard(uint32_t firmware_size)
8783
ucp_status = ARM_UCP_Write(0, 0, &write_buffer);
8884

8985
/* wait for event if call was accepted */
90-
if (ucp_status.error == ERR_NONE)
91-
{
92-
while (event_callback == CLEAR_EVENT)
93-
{
86+
if (ucp_status.error == ERR_NONE) {
87+
while (event_callback == CLEAR_EVENT) {
9488
__WFI();
9589
}
96-
}
97-
else
98-
{
90+
} else {
9991
tr_error("ARM_UCP_Write failed\r\n");
10092
}
10193

@@ -110,15 +102,11 @@ void copyAppToSDCard(uint32_t firmware_size)
110102
ucp_status = ARM_UCP_Finalize(0);
111103

112104
/* wait for event if call was accepted */
113-
if (ucp_status.error == ERR_NONE)
114-
{
115-
while (event_callback == CLEAR_EVENT)
116-
{
105+
if (ucp_status.error == ERR_NONE) {
106+
while (event_callback == CLEAR_EVENT) {
117107
__WFI();
118108
}
119-
}
120-
else
121-
{
109+
} else {
122110
tr_error("ARM_UCP_Finalize failed\r\n");
123111
}
124112
}
@@ -138,18 +126,14 @@ void firmware_update_test_validate()
138126

139127
void firmware_update_test_end()
140128
{
141-
if (firmware_update_test_valid_flag)
142-
{
129+
if (firmware_update_test_valid_flag) {
143130
GREENTEA_TESTSUITE_RESULT(true);
144-
}
145-
else
146-
{
131+
} else {
147132
GREENTEA_TESTSUITE_RESULT(false);
148133
}
149134

150135
/* test end block forever */
151-
for (;;)
152-
{
136+
for (;;) {
153137
__WFI();
154138
}
155139
}

power_cut_test/bootloader_power_cut_test.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "bootloader_power_cut_test.h"
2525

26-
DigitalOut JigTrigger(D2,0);
26+
DigitalOut JigTrigger(D2, 0);
2727

2828
Timeout JigTimeout;
2929

@@ -54,8 +54,7 @@ void power_cut_test_end()
5454
greentea_send_kv("power_cut_test_end", 0);
5555

5656
/* test end block forever */
57-
for (;;)
58-
{
57+
for (;;) {
5958
__WFI();
6059
}
6160
}

0 commit comments

Comments
 (0)