Skip to content

Commit d0b9b9a

Browse files
committed
test apps: fix astyle
1 parent bbfa322 commit d0b9b9a

File tree

2 files changed

+95
-61
lines changed

2 files changed

+95
-61
lines changed

TEST_APPS/device/nanostack_mac_tester/source/mac_commands.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static int handle_security_args(int argc, char *argv[], mlme_security_t *key)
406406
}
407407
}
408408
if (cmd_parameter_val(argc, argv, "--key_source", &str)) {
409-
if (strlen(str) == 2*8+7) {
409+
if (strlen(str) == 2 * 8 + 7) {
410410
if (string_to_bytes(str, key->Keysource, 8) != 0) {
411411
return CMDLINE_RETCODE_INVALID_PARAMETERS;
412412
}
@@ -425,9 +425,9 @@ static void add_beacon(const uint8_t *beacon, uint8_t len)
425425
}
426426
unsigned int cur_beacon = received_beacons.count;
427427
received_beacons.beacon_lengths[cur_beacon] = len;
428-
received_beacons.beacons[cur_beacon] = (char*)ns_dyn_mem_temporary_alloc(len <= 75 ? 75:len);
428+
received_beacons.beacons[cur_beacon] = (char *)ns_dyn_mem_temporary_alloc(len <= 75 ? 75 : len);
429429
if (len != 0) {
430-
std::memcpy(received_beacons.beacons[cur_beacon], beacon, len);
430+
std::memcpy(received_beacons.beacons[cur_beacon], beacon, len);
431431
}
432432
++received_beacons.count;
433433
}
@@ -503,7 +503,7 @@ void mac_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *da
503503
if (data->msduLength != expected_statuses.data_ind_len) {
504504
return;
505505
}
506-
if (strncmp((const char*)data->msdu_ptr, (const char*)expected_statuses.data_ind, expected_statuses.data_ind_len) == 0) {
506+
if (strncmp((const char *)data->msdu_ptr, (const char *)expected_statuses.data_ind, expected_statuses.data_ind_len) == 0) {
507507
++data_count;
508508
} else {
509509
tr_warn("Received unexpected data!");
@@ -535,13 +535,13 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
535535
break;
536536
}
537537
case MLME_GET: {
538-
mlme_get_conf_t *get_data = (mlme_get_conf_t*)data;
538+
mlme_get_conf_t *get_data = (mlme_get_conf_t *)data;
539539
cmd_printf("MLME-GET.confirm\n");
540540
if (!silent_mode) {
541541
cmd_printf("status: %hhu (%s)\n", get_data->status, mlme_status_string(get_data->status));
542542
cmd_printf("attr: %hhu\n", get_data->attr);
543543
cmd_printf("attr_index: %hhu\n", get_data->attr_index);
544-
cmd_printf("value_pointer: %s\n", trace_array((uint8_t*)get_data->value_pointer, get_data->value_size));
544+
cmd_printf("value_pointer: %s\n", trace_array((uint8_t *)get_data->value_pointer, get_data->value_size));
545545
cmd_printf("value_size: %hhu\n", get_data->value_size);
546546
}
547547
if (get_data->status == expected_statuses.get_conf) {
@@ -561,7 +561,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
561561
break;
562562
}
563563
case MLME_SCAN: {
564-
mlme_scan_conf_t *scan_data = (mlme_scan_conf_t*)data;
564+
mlme_scan_conf_t *scan_data = (mlme_scan_conf_t *)data;
565565
cmd_printf("MLME-SCAN.confirm\n");
566566
if (!silent_mode) {
567567
cmd_printf("status: %hhu (%s)\n", scan_data->status, mlme_status_string(scan_data->status));
@@ -596,7 +596,7 @@ void mac_mlme_confirm_handler(const mac_api_t *api, mlme_primitive id, const voi
596596
break;
597597
}
598598
case MLME_POLL: {
599-
mlme_poll_conf_t *poll_data = (mlme_poll_conf_t*)data;
599+
mlme_poll_conf_t *poll_data = (mlme_poll_conf_t *)data;
600600
cmd_printf("MLME-POLL.confirm\n");
601601
if (!silent_mode) {
602602
cmd_printf("status: %hhu (%s)\n", poll_data->status, mlme_status_string(poll_data->status));
@@ -632,15 +632,15 @@ void mac_mlme_indication_handler(const mac_api_t *api, mlme_primitive id, const
632632
break;
633633
}
634634
case MLME_BEACON_NOTIFY: {
635-
const mlme_beacon_ind_t *beacon_ind = (mlme_beacon_ind_t*)data;
635+
const mlme_beacon_ind_t *beacon_ind = (mlme_beacon_ind_t *)data;
636636
cmd_printf("MLME-BEACON-NOTIFY.indication\n");
637637
if (!silent_mode) {
638638
cmd_printf("BSN: %hhu\n", beacon_ind->BSN);
639639
print_PAN_descriptor(&beacon_ind->PANDescriptor);
640640
cmd_printf("PendAddrSpec.short_address_count %u\n", beacon_ind->PendAddrSpec.short_address_count);
641641
cmd_printf("PendAddrSpec.extended_address_count %u\n", beacon_ind->PendAddrSpec.extended_address_count);
642642
cmd_printf("AddrList %s\n", trace_array(beacon_ind->AddrList, beacon_ind->PendAddrSpec.short_address_count * 2 +
643-
beacon_ind->PendAddrSpec.extended_address_count * 8));
643+
beacon_ind->PendAddrSpec.extended_address_count * 8));
644644
cmd_printf("beacon_data_length %hu\n", beacon_ind->beacon_data_length);
645645
cmd_printf("beacon_data %s\n", trace_array(beacon_ind->beacon_data, beacon_ind->beacon_data_length));
646646
}
@@ -655,7 +655,7 @@ void mac_mlme_indication_handler(const mac_api_t *api, mlme_primitive id, const
655655
}
656656
case MLME_COMM_STATUS: {
657657
cmd_printf("MLME-COMM-STATUS.indication\n");
658-
const mlme_comm_status_t *comm_status_ind_data = (mlme_comm_status_t*)data;
658+
const mlme_comm_status_t *comm_status_ind_data = (mlme_comm_status_t *)data;
659659
if (!silent_mode) {
660660
cmd_printf("PANId: 0x%04X\n", comm_status_ind_data->PANId);
661661
cmd_printf("SrcAddrMode: %u\n", comm_status_ind_data->SrcAddrMode);
@@ -822,7 +822,7 @@ int mac_data_command(int argc, char *argv[])
822822
if (strlen(str) != data_req.msduLength) {
823823
return CMDLINE_RETCODE_INVALID_PARAMETERS;
824824
}
825-
data_req.msdu = (uint8_t*)ns_dyn_mem_temporary_alloc(data_req.msduLength);
825+
data_req.msdu = (uint8_t *)ns_dyn_mem_temporary_alloc(data_req.msduLength);
826826
if (data_req.msdu == NULL) {
827827
tr_error("Failed to allocate memory for the msdu");
828828
return CMDLINE_RETCODE_FAIL;
@@ -879,7 +879,7 @@ int mac_poll_command(int argc, char *argv[])
879879
}
880880
}
881881
if (cmd_parameter_val(argc, argv, "--coord_address", &str)) {
882-
int len = (poll_req.CoordAddrMode == 2 ? 2: 8);
882+
int len = (poll_req.CoordAddrMode == 2 ? 2 : 8);
883883
if (string_to_bytes(str, poll_req.CoordAddress, len) != 0) {
884884
return CMDLINE_RETCODE_INVALID_PARAMETERS;
885885
}
@@ -915,7 +915,7 @@ int mac_set_command(int argc, char *argv[])
915915
uint16_t val_uint16 = 0;
916916
uint32_t val_uint32 = 0;
917917
uint8_t *val_ptr_array = NULL;
918-
918+
919919
cmd_printf("MLME-SET.request\n");
920920
if (cmd_parameter_val(argc, argv, "--attr", &str)) {
921921
uint32_t attribute = strtoul(str, NULL, 16);
@@ -933,7 +933,7 @@ int mac_set_command(int argc, char *argv[])
933933
}
934934
}
935935
if (cmd_parameter_val(argc, argv, "--value_ascii", &str)) {
936-
val_ptr_array = (uint8_t*)ns_dyn_mem_temporary_alloc(strlen(str));
936+
val_ptr_array = (uint8_t *)ns_dyn_mem_temporary_alloc(strlen(str));
937937
if (val_ptr_array == NULL) {
938938
tr_error("Failed to allocate memory for MLME-SET.request");
939939
return CMDLINE_RETCODE_FAIL;
@@ -942,7 +942,7 @@ int mac_set_command(int argc, char *argv[])
942942
set_req.value_pointer = val_ptr_array;
943943
} else if (cmd_parameter_val(argc, argv, "--value_bytes", &str)) {
944944
size_t bytes = (strlen(str) + 1) / 3;
945-
val_ptr_array = (uint8_t*)ns_dyn_mem_temporary_alloc(bytes);
945+
val_ptr_array = (uint8_t *)ns_dyn_mem_temporary_alloc(bytes);
946946
if (val_ptr_array == NULL) {
947947
tr_error("Failed to allocate memory for MLME-SET.request");
948948
return CMDLINE_RETCODE_FAIL;
@@ -1074,7 +1074,7 @@ static int key_config_command(int argc, char *argv[])
10741074
int lookup_index = 0, device_index = 0, usage_index = 0;
10751075

10761076
if (cmd_parameter_val(argc, argv, "--key", &str)) {
1077-
if (strlen(str) == 2*16+15) {
1077+
if (strlen(str) == 2 * 16 + 15) {
10781078
if (string_to_bytes(str, key_descriptor.Key, 16) != 0) {
10791079
return CMDLINE_RETCODE_INVALID_PARAMETERS;
10801080
}
@@ -1111,7 +1111,7 @@ static int key_config_command(int argc, char *argv[])
11111111
}
11121112
}
11131113
if (cmd_parameter_val(argc, argv, "--lookup_data", &str)) {
1114-
if (strlen(str) == 2*9+8) {
1114+
if (strlen(str) == 2 * 9 + 8) {
11151115
if (string_to_bytes(str, key_descriptor.KeyIdLookupList[lookup_index].LookupData, 9) != 0) {
11161116
return CMDLINE_RETCODE_INVALID_PARAMETERS;
11171117
}
@@ -1226,7 +1226,7 @@ int mac_add_neighbour_command(int argc, char *argv[])
12261226
}
12271227
}
12281228
if (cmd_parameter_val(argc, argv, "--mac64", &str)) {
1229-
if (strlen(str) == 2*8+7) {
1229+
if (strlen(str) == 2 * 8 + 7) {
12301230
if (string_to_bytes(str, neighbour.ExtAddress, 8) != 0) {
12311231
return CMDLINE_RETCODE_INVALID_PARAMETERS;
12321232
}
@@ -1270,7 +1270,7 @@ static int filter_start(int argc, char *argv[])
12701270
} else if (strcmp(str, "fixed") == 0) {
12711271
int32_t lqi, dbm;
12721272
if (cmd_parameter_int(argc, argv, "--lqi_m", &lqi) &&
1273-
cmd_parameter_int(argc, argv, "--dbm_m", &dbm)) {
1273+
cmd_parameter_int(argc, argv, "--dbm_m", &dbm)) {
12741274
return mac_filter_start(mac_interface->parent_id, MAC_FILTER_FIXED(lqi, dbm)) < 0 ? CMDLINE_RETCODE_FAIL : CMDLINE_RETCODE_SUCCESS;
12751275
}
12761276
}
@@ -1286,9 +1286,9 @@ static int filter_add(int argc, char *argv[])
12861286
int32_t lqi_m, lqi_add, dbm_m, dbm_add;
12871287

12881288
if (cmd_parameter_int(argc, argv, "--lqi_m", &lqi_m) &&
1289-
cmd_parameter_int(argc, argv, "--lqi_add", &lqi_add) &&
1290-
cmd_parameter_int(argc, argv, "--dbm_m", &dbm_m) &&
1291-
cmd_parameter_int(argc, argv, "--dbm_add", &dbm_add)) {
1289+
cmd_parameter_int(argc, argv, "--lqi_add", &lqi_add) &&
1290+
cmd_parameter_int(argc, argv, "--dbm_m", &dbm_m) &&
1291+
cmd_parameter_int(argc, argv, "--dbm_add", &dbm_add)) {
12921292
} else if (cmd_parameter_val(argc, argv, "--mode", &str)) {
12931293
if (strcmp(str, "allow")) {
12941294
lqi_m = dbm_m = 256;
@@ -1298,7 +1298,7 @@ static int filter_add(int argc, char *argv[])
12981298
} else if (strcmp(str, "fixed")) {
12991299
lqi_add = dbm_add = 0;
13001300
if (cmd_parameter_int(argc, argv, "--lqi_m", &lqi_m) &&
1301-
cmd_parameter_int(argc, argv, "--dbm_m", &dbm_m)) {
1301+
cmd_parameter_int(argc, argv, "--dbm_m", &dbm_m)) {
13021302
} else {
13031303
return CMDLINE_RETCODE_INVALID_PARAMETERS;
13041304
}
@@ -1424,7 +1424,7 @@ int mac_config_status_command(int argc, char *argv[])
14241424
} else if (cmd_parameter_val(argc, argv, "--data_ind", &str)) {
14251425
size_t len = strlen(str);
14261426
ns_dyn_mem_free(expected_statuses.data_ind);
1427-
expected_statuses.data_ind = (uint8_t*)ns_dyn_mem_temporary_alloc(len);
1427+
expected_statuses.data_ind = (uint8_t *)ns_dyn_mem_temporary_alloc(len);
14281428
expected_statuses.data_ind_len = len;
14291429
std::memcpy(expected_statuses.data_ind, str, len);
14301430
} else if (cmd_parameter_int(argc, argv, "--get", &val)) {
@@ -1541,7 +1541,7 @@ int mac_analyze_ed_command(int argc, char *argv[])
15411541
return CMDLINE_RETCODE_INVALID_PARAMETERS;
15421542
}
15431543
} else {
1544-
return CMDLINE_RETCODE_INVALID_PARAMETERS;
1544+
return CMDLINE_RETCODE_INVALID_PARAMETERS;
15451545
}
15461546

15471547
if (cmd_parameter_int(argc, argv, "--above", &val)) {

TEST_APPS/device/nanostack_mac_tester/source/util.cpp

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#include "util.h"
17+
#include "util.h"
1818

1919
int string_to_bytes(const char *str, uint8_t *buf, int bytes)
2020
{
@@ -38,40 +38,74 @@ int string_to_bytes(const char *str, uint8_t *buf, int bytes)
3838
const char *mlme_status_string(uint8_t status)
3939
{
4040
switch (status) {
41-
case MLME_SUCCESS: return "MLME_SUCCESS";
42-
case MLME_BUSY_CHAN: return "MLME_BUSY_CHAN";
43-
case MLME_BUSY_RX: return "MLME_BUSY_RX";
44-
case MLME_BUSY_TX: return "MLME_BUSY_TX";
45-
case MLME_FORCE_TRX_OFF: return "MLME_FORCE_TRX_OFF";
46-
case MLME_IDLE: return "MLME_IDLE";
47-
case MLME_RX_ON: return "MLME_RX_ON";
48-
case MLME_TRX_OFF: return "MLME_TRX_OFF";
49-
case MLME_TX_ON: return "MLME_TX_ON";
50-
case MLME_COUNTER_ERROR: return "MLME_COUNTER_ERROR";
51-
case MLME_IMPROPER_KEY_TYPE: return "MLME_IMPROPER_KEY_TYPE";
52-
case MLME_IMPROPER_SECURITY_LEVEL: return "MLME_IMPROPER_SECURITY_LEVEL";
53-
case MLME_UNSUPPORTED_LEGACY: return "MLME_UNSUPPORTED_LEGACY";
54-
case MLME_UNSUPPORTED_SECURITY: return "MLME_UNSUPPORTED_SECURITY";
55-
case MLME_SECURITY_FAIL: return "MLME_SECURITY_FAIL";
56-
case MLME_FRAME_TOO_LONG: return "MLME_FRAME_TOO_LONG";
57-
case MLME_INVALID_HANDLE: return "MLME_INVALID_HANDLE";
58-
case MLME_INVALID_PARAMETER: return "MLME_INVALID_PARAMETER";
59-
case MLME_TX_NO_ACK: return "MLME_TX_NO_ACK";
60-
case MLME_NO_BEACON: return "MLME_NO_BEACON";
61-
case MLME_NO_DATA: return "MLME_NO_DATA";
62-
case MLME_NO_SHORT_ADDRESS: return "MLME_NO_SHORT_ADDRESS";
63-
case MLME_PAN_ID_CONFLICT: return "MLME_PAN_ID_CONFLICT";
64-
case MLME_TRANSACTION_EXPIRED: return "MLME_TRANSACTION_EXPIRED";
65-
case MLME_TRANSACTION_OVERFLOW: return "MLME_TRANSACTION_OVERFLOW";
66-
case MLME_UNAVAILABLE_KEY: return "MLME_UNAVAILABLE_KEY";
67-
case MLME_UNSUPPORTED_ATTRIBUTE: return "MLME_UNSUPPORTED_ATTRIBUTE";
68-
case MLME_INVALID_ADDRESS: return "MLME_INVALID_ADDRESS";
69-
case MLME_INVALID_INDEX: return "MLME_INVALID_INDEX";
70-
case MLME_LIMIT_REACHED: return "MLME_LIMIT_REACHED";
71-
case MLME_READ_ONLY: return "MLME_READ_ONLY";
72-
case MLME_SCAN_IN_PROGRESS: return "MLME_SCAN_IN_PROGRESS";
73-
case MLME_DATA_POLL_NOTIFICATION: return "MLME_DATA_POLL_NOTIFICATION";
74-
default: return NULL;
41+
case MLME_SUCCESS:
42+
return "MLME_SUCCESS";
43+
case MLME_BUSY_CHAN:
44+
return "MLME_BUSY_CHAN";
45+
case MLME_BUSY_RX:
46+
return "MLME_BUSY_RX";
47+
case MLME_BUSY_TX:
48+
return "MLME_BUSY_TX";
49+
case MLME_FORCE_TRX_OFF:
50+
return "MLME_FORCE_TRX_OFF";
51+
case MLME_IDLE:
52+
return "MLME_IDLE";
53+
case MLME_RX_ON:
54+
return "MLME_RX_ON";
55+
case MLME_TRX_OFF:
56+
return "MLME_TRX_OFF";
57+
case MLME_TX_ON:
58+
return "MLME_TX_ON";
59+
case MLME_COUNTER_ERROR:
60+
return "MLME_COUNTER_ERROR";
61+
case MLME_IMPROPER_KEY_TYPE:
62+
return "MLME_IMPROPER_KEY_TYPE";
63+
case MLME_IMPROPER_SECURITY_LEVEL:
64+
return "MLME_IMPROPER_SECURITY_LEVEL";
65+
case MLME_UNSUPPORTED_LEGACY:
66+
return "MLME_UNSUPPORTED_LEGACY";
67+
case MLME_UNSUPPORTED_SECURITY:
68+
return "MLME_UNSUPPORTED_SECURITY";
69+
case MLME_SECURITY_FAIL:
70+
return "MLME_SECURITY_FAIL";
71+
case MLME_FRAME_TOO_LONG:
72+
return "MLME_FRAME_TOO_LONG";
73+
case MLME_INVALID_HANDLE:
74+
return "MLME_INVALID_HANDLE";
75+
case MLME_INVALID_PARAMETER:
76+
return "MLME_INVALID_PARAMETER";
77+
case MLME_TX_NO_ACK:
78+
return "MLME_TX_NO_ACK";
79+
case MLME_NO_BEACON:
80+
return "MLME_NO_BEACON";
81+
case MLME_NO_DATA:
82+
return "MLME_NO_DATA";
83+
case MLME_NO_SHORT_ADDRESS:
84+
return "MLME_NO_SHORT_ADDRESS";
85+
case MLME_PAN_ID_CONFLICT:
86+
return "MLME_PAN_ID_CONFLICT";
87+
case MLME_TRANSACTION_EXPIRED:
88+
return "MLME_TRANSACTION_EXPIRED";
89+
case MLME_TRANSACTION_OVERFLOW:
90+
return "MLME_TRANSACTION_OVERFLOW";
91+
case MLME_UNAVAILABLE_KEY:
92+
return "MLME_UNAVAILABLE_KEY";
93+
case MLME_UNSUPPORTED_ATTRIBUTE:
94+
return "MLME_UNSUPPORTED_ATTRIBUTE";
95+
case MLME_INVALID_ADDRESS:
96+
return "MLME_INVALID_ADDRESS";
97+
case MLME_INVALID_INDEX:
98+
return "MLME_INVALID_INDEX";
99+
case MLME_LIMIT_REACHED:
100+
return "MLME_LIMIT_REACHED";
101+
case MLME_READ_ONLY:
102+
return "MLME_READ_ONLY";
103+
case MLME_SCAN_IN_PROGRESS:
104+
return "MLME_SCAN_IN_PROGRESS";
105+
case MLME_DATA_POLL_NOTIFICATION:
106+
return "MLME_DATA_POLL_NOTIFICATION";
107+
default:
108+
return NULL;
75109
}
76110
}
77111

0 commit comments

Comments
 (0)