Skip to content

Commit 29a1149

Browse files
committed
nanostakc cmsis rtos: fix coding style
1 parent 3aab381 commit 29a1149

File tree

13 files changed

+79
-88
lines changed

13 files changed

+79
-88
lines changed

features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_fhss_timer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ static const fhss_api_t *fhss_active_handle = NULL;
3636
static EventQueue *equeue;
3737
#endif
3838

39-
struct fhss_timeout_s
40-
{
39+
struct fhss_timeout_s {
4140
void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t);
4241
uint32_t start_time;
4342
uint32_t stop_time;

features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_interrupt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ static uint8_t sys_irq_disable_counter;
3939

4040
static mbed_rtos_storage_mutex_t critical_mutex;
4141
static const osMutexAttr_t critical_mutex_attr = {
42-
.name = "nanostack_critical_mutex",
43-
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
44-
.cb_mem = &critical_mutex,
45-
.cb_size = sizeof critical_mutex,
42+
.name = "nanostack_critical_mutex",
43+
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
44+
.cb_mem = &critical_mutex,
45+
.cb_size = sizeof critical_mutex,
4646
};
4747
static osMutexId_t critical_mutex_id;
4848

features/nanostack/nanostack-hal-mbed-cmsis-rtos/arm_hal_timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ uint16_t platform_timer_get_remaining_slots(void)
9494
{
9595
uint32_t elapsed = timer->read_us();
9696
if (elapsed < due) {
97-
return (uint16_t) ((due - elapsed) / 50);
97+
return (uint16_t)((due - elapsed) / 50);
9898
} else {
9999
return 0;
100100
}

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/cs_nvm.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ static void nvm_fsm_timer_cb(void *arg);
9999
static void configuration_store_cb(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *ctx, ARM_CFSTORE_HANDLE handle)
100100
{
101101
tr_debug("configuration_store_cb status=%d, cmd_code=%d, ctx=%x, hndl=%x", (int)status, (int)cmd_code, (unsigned int)ctx, (unsigned int)handle);
102-
cs_context_t *cf_context = (cs_context_t*)ctx;
102+
cs_context_t *cf_context = (cs_context_t *)ctx;
103103

104-
switch(cmd_code) {
104+
switch (cmd_code) {
105105
case CFSTORE_OPCODE_INITIALIZE:
106106
tr_debug("CFSTORE_OPCODE_INITIALIZE %d", (int)status);
107107
cf_context->state = NVM_STATE_INIT_DONE;
@@ -229,8 +229,7 @@ static int nvm_fsm_update(cs_context_t *cs_context)
229229
int ret_val = 0;
230230

231231
tr_debug("nvm_fsm_update() state=%d", (int)cs_context->state);
232-
switch (cs_context->state)
233-
{
232+
switch (cs_context->state) {
234233
case NVM_STATE_UNINIT_DONE:
235234
cs_context->client_cb(cs_context->client_status, cs_context->client_context);
236235
cs_context->state = NVM_STATE_NONE;
@@ -288,7 +287,7 @@ platform_nvm_status platform_nvm_init(nvm_callback *callback, void *context)
288287

289288
cs_context_ptr->capabilities = drv->GetCapabilities();
290289

291-
tr_debug("mode: %s", IS_SYNC_MODE(cs_context_ptr) ? "sync": "async" );
290+
tr_debug("mode: %s", IS_SYNC_MODE(cs_context_ptr) ? "sync" : "async");
292291

293292
ret = drv->Initialize(configuration_store_cb, cs_context_ptr);
294293
if (ret < ARM_DRIVER_OK) {
@@ -367,14 +366,14 @@ platform_nvm_status platform_nvm_key_create(nvm_callback *callback, const char *
367366
keydesc.drl = ARM_RETENTION_NVM;
368367

369368
ret = drv->Create(key_name, value_len, &keydesc, cs_context_ptr->hkey);
370-
if(ret < ARM_DRIVER_OK) {
369+
if (ret < ARM_DRIVER_OK) {
371370
if (ret == ARM_CFSTORE_DRIVER_ERROR_PREEXISTING_KEY) {
372371
tr_debug("adjust value len to %d", value_len);
373372
ret = drv->Create(key_name, value_len, NULL, cs_context_ptr->hkey);
374373
}
375374
}
376375

377-
if(ret < ARM_DRIVER_OK) {
376+
if (ret < ARM_DRIVER_OK) {
378377
tr_error("Key creation failed %d", (int)ret);
379378
cs_context_ptr->state = NVM_STATE_CREATE_DONE;
380379
cs_context_ptr->client_status = nvm_error_map(ret);
@@ -413,7 +412,7 @@ platform_nvm_status platform_nvm_key_delete(nvm_callback *callback, const char *
413412
flags.write = 1;
414413
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
415414

416-
if(ret < ARM_DRIVER_OK) {
415+
if (ret < ARM_DRIVER_OK) {
417416
tr_error("Key delete, open failed %d", (int)ret);
418417
cs_context_ptr->state = NVM_STATE_DELETE_DONE;
419418
cs_context_ptr->client_status = nvm_error_map(ret);
@@ -455,7 +454,7 @@ platform_nvm_status platform_nvm_read(nvm_callback *callback, const char *key_na
455454
flags.read = 1;
456455
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
457456

458-
if(ret < ARM_DRIVER_OK) {
457+
if (ret < ARM_DRIVER_OK) {
459458
tr_error("Read failed to open handle %d", (int)ret);
460459
cs_context_ptr->state = NVM_STATE_READ_DONE;
461460
cs_context_ptr->client_status = nvm_error_map(ret);
@@ -485,7 +484,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
485484
}
486485
cs_context_ptr->client_cb = callback;
487486
cs_context_ptr->client_context = context;
488-
cs_context_ptr->client_buf = (void*)data;
487+
cs_context_ptr->client_buf = (void *)data;
489488
cs_context_ptr->client_buf_len = data_len;
490489
cs_context_ptr->data_len = *data_len;
491490
cs_context_ptr->client_status = PLATFORM_NVM_OK;
@@ -496,7 +495,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
496495
flags.write = 1;
497496
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
498497

499-
if(ret < ARM_DRIVER_OK) {
498+
if (ret < ARM_DRIVER_OK) {
500499
tr_error("Write failed %d", (int)ret);
501500
cs_context_ptr->state = NVM_STATE_WRITE_DONE;
502501
cs_context_ptr->client_status = nvm_error_map(ret);
@@ -532,7 +531,7 @@ platform_nvm_status platform_nvm_flush(nvm_callback *callback, void *context)
532531

533532
ret = drv->Flush();
534533

535-
if(ret < ARM_DRIVER_OK) {
534+
if (ret < ARM_DRIVER_OK) {
536535
cs_context_ptr->state = NVM_STATE_FLUSH_DONE;
537536
cs_context_ptr->client_status = nvm_error_map(ret);
538537
}
@@ -547,9 +546,9 @@ static bool nvm_write_internal(cs_context_t *cf_context)
547546
{
548547
int32_t ret;
549548
cf_context->state = NVM_STATE_WRITING;
550-
ret = drv->Write(cf_context->hkey, (const char*)cf_context->client_buf, &cf_context->data_len);
549+
ret = drv->Write(cf_context->hkey, (const char *)cf_context->client_buf, &cf_context->data_len);
551550

552-
if(ret >= ARM_DRIVER_OK) {
551+
if (ret >= ARM_DRIVER_OK) {
553552
return true;
554553
} else {
555554
tr_error("Write failed %d", (int)ret);
@@ -561,9 +560,9 @@ static bool nvm_read_internal(cs_context_t *cf_context)
561560
{
562561
int32_t ret;
563562
cf_context->state = NVM_STATE_READING;
564-
ret = drv->Read(cf_context->hkey, (void*)cf_context->client_buf, &cf_context->data_len);
563+
ret = drv->Read(cf_context->hkey, (void *)cf_context->client_buf, &cf_context->data_len);
565564

566-
if(ret >= ARM_DRIVER_OK) {
565+
if (ret >= ARM_DRIVER_OK) {
567566
return true;
568567
} else {
569568
tr_error("Read failed %d", (int)ret);
@@ -577,7 +576,7 @@ static bool nvm_delete_internal(cs_context_t *cf_context)
577576
cf_context->state = NVM_STATE_DELETING;
578577
ret = drv->Delete(cf_context->hkey);
579578

580-
if(ret >= ARM_DRIVER_OK) {
579+
if (ret >= ARM_DRIVER_OK) {
581580
return true;
582581
} else {
583582
tr_error("Delete failed %d", (int)ret);
@@ -591,7 +590,7 @@ static bool nvm_close_internal(cs_context_t *cf_context)
591590
cf_context->state = NVM_STATE_CLOSING;
592591
ret = drv->Close(cf_context->hkey);
593592

594-
if(ret >= ARM_DRIVER_OK) {
593+
if (ret >= ARM_DRIVER_OK) {
595594
return true;
596595
} else {
597596
tr_error("Close failed %d", (int)ret);
@@ -626,7 +625,7 @@ static platform_nvm_status nvm_error_map(int32_t cs_error)
626625
return PLATFORM_NVM_OK;
627626
}
628627

629-
switch(cs_error) {
628+
switch (cs_error) {
630629
case ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND:
631630
client_error = PLATFORM_NVM_KEY_NOT_FOUND;
632631
break;
@@ -641,7 +640,7 @@ static platform_nvm_status nvm_error_map(int32_t cs_error)
641640
static void nvm_fsm_timer_cb(void *args)
642641
{
643642
(void) args;
644-
switch(nvm_fsm_update(cs_context_ptr)) {
643+
switch (nvm_fsm_update(cs_context_ptr)) {
645644
case 0:
646645
// Nothing processed, restart timer
647646
tr_debug("nvm_fsm_timer_cb not handled event in () %d", (int)cs_context_ptr->state);

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/cs_nvm/test_cs_nvm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ uint8_t buf[100];
2222
uint16_t buf_len;
2323
uint16_t data_len;
2424

25-
typedef struct
26-
{
25+
typedef struct {
2726
platform_nvm_status status;
2827
void *ctx;
2928
} test_platform_nvm_api_callback_t;
@@ -187,7 +186,7 @@ bool test_cs_nvm_init_finalize()
187186
}
188187

189188
// finalize NVM - OK
190-
if (!test_nvm_finalize()){
189+
if (!test_nvm_finalize()) {
191190
return false;
192191
}
193192

@@ -300,7 +299,7 @@ bool test_cs_nvm_key_create()
300299
}
301300

302301
// finalize NVM - OK
303-
if (!test_nvm_finalize()){
302+
if (!test_nvm_finalize()) {
304303
return false;
305304
}
306305

@@ -341,7 +340,7 @@ bool test_cs_nvm_key_delete()
341340
ret = platform_nvm_key_delete(test_nvm_callback, NULL, TEST_NS_NVM_HELPER_CONTEXT1);
342341
if (ret != PLATFORM_NVM_ERROR) {
343342
return false;
344-
}
343+
}
345344

346345
// Configuration-store returns error in OPEN directly
347346
cfstore_stub.ret_val = ARM_DRIVER_ERROR;
@@ -389,7 +388,7 @@ bool test_cs_nvm_key_delete()
389388
ret = platform_nvm_key_delete(test_nvm_callback, key_name, TEST_NS_NVM_HELPER_CONTEXT1);
390389
if (ret != PLATFORM_NVM_OK) {
391390
return false;
392-
}
391+
}
393392

394393
// simulate open
395394
cfstore_stub.cmd_code = CFSTORE_OPCODE_OPEN;

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/configuration_store_stub.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static int32_t test_cfstore_close(ARM_CFSTORE_HANDLE hkey)
1616
return cfstore_stub.close_ret_val;
1717
}
1818

19-
static int32_t test_cfstore_create(const char* key_name, ARM_CFSTORE_SIZE value_len, const ARM_CFSTORE_KEYDESC* kdesc, ARM_CFSTORE_HANDLE hkey)
19+
static int32_t test_cfstore_create(const char *key_name, ARM_CFSTORE_SIZE value_len, const ARM_CFSTORE_KEYDESC *kdesc, ARM_CFSTORE_HANDLE hkey)
2020
{
2121
return cfstore_stub.ret_val;
2222
}
@@ -26,7 +26,7 @@ static int32_t test_cfstore_delete(ARM_CFSTORE_HANDLE hkey)
2626
return cfstore_stub.delete_ret_val;
2727
}
2828

29-
static int32_t test_cfstore_find(const char* key_name_query, const ARM_CFSTORE_HANDLE previous, ARM_CFSTORE_HANDLE next)
29+
static int32_t test_cfstore_find(const char *key_name_query, const ARM_CFSTORE_HANDLE previous, ARM_CFSTORE_HANDLE next)
3030
{
3131
return ARM_DRIVER_OK;
3232
}
@@ -42,7 +42,7 @@ ARM_CFSTORE_CAPABILITIES test_cfstore_get_capabilities(void)
4242
return cfstore_caps_g;
4343
}
4444

45-
static int32_t test_cfstore_get_key_name(ARM_CFSTORE_HANDLE hkey, char* key_name, uint8_t *key_name_len)
45+
static int32_t test_cfstore_get_key_name(ARM_CFSTORE_HANDLE hkey, char *key_name, uint8_t *key_name_len)
4646
{
4747
return ARM_DRIVER_OK;
4848
}
@@ -64,14 +64,14 @@ ARM_DRIVER_VERSION test_cfstore_get_version(void)
6464
return cfstore_driver_version_g;
6565
}
6666

67-
static int32_t test_cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void* client_context)
67+
static int32_t test_cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void *client_context)
6868
{
6969
cfstore_stub.callback = callback;
7070
cfstore_stub.client_context = client_context;
7171
return cfstore_stub.ret_val;
7272
}
7373

74-
static int32_t test_cfstore_open(const char* key_name, ARM_CFSTORE_FMODE flags, ARM_CFSTORE_HANDLE hkey)
74+
static int32_t test_cfstore_open(const char *key_name, ARM_CFSTORE_FMODE flags, ARM_CFSTORE_HANDLE hkey)
7575
{
7676
return cfstore_stub.ret_val;
7777
}
@@ -81,7 +81,7 @@ static int32_t test_cfstore_power_control(ARM_POWER_STATE state)
8181
return ARM_DRIVER_OK;
8282
}
8383

84-
static int32_t test_cfstore_read(ARM_CFSTORE_HANDLE hkey, void* data, ARM_CFSTORE_SIZE* len)
84+
static int32_t test_cfstore_read(ARM_CFSTORE_HANDLE hkey, void *data, ARM_CFSTORE_SIZE *len)
8585
{
8686
return cfstore_stub.read_ret_val;
8787
}
@@ -96,30 +96,29 @@ static int32_t test_cfstore_uninitialise(void)
9696
return cfstore_stub.ret_val;
9797
}
9898

99-
static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE hkey, const char* data, ARM_CFSTORE_SIZE* len)
99+
static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE hkey, const char *data, ARM_CFSTORE_SIZE *len)
100100
{
101101
return cfstore_stub.write_ret_val;
102102
}
103103

104-
ARM_CFSTORE_DRIVER cfstore_driver =
105-
{
106-
.Close = test_cfstore_close,
107-
.Create = test_cfstore_create,
108-
.Delete= test_cfstore_delete,
109-
.Find = test_cfstore_find,
110-
.Flush = test_cfstore_flush,
111-
.GetCapabilities = test_cfstore_get_capabilities,
112-
.GetKeyName = test_cfstore_get_key_name,
113-
.GetStatus = test_cfstore_get_status,
114-
.GetValueLen = test_cfstore_get_value_len,
115-
.GetVersion = test_cfstore_get_version,
116-
.Initialize = test_cfstore_initialise,
117-
.Open = test_cfstore_open,
118-
.PowerControl = test_cfstore_power_control,
119-
.Read = test_cfstore_read,
120-
.Rseek = test_cfstore_rseek,
121-
.Uninitialize = test_cfstore_uninitialise,
122-
.Write = test_cfstore_write,
104+
ARM_CFSTORE_DRIVER cfstore_driver = {
105+
.Close = test_cfstore_close,
106+
.Create = test_cfstore_create,
107+
.Delete = test_cfstore_delete,
108+
.Find = test_cfstore_find,
109+
.Flush = test_cfstore_flush,
110+
.GetCapabilities = test_cfstore_get_capabilities,
111+
.GetKeyName = test_cfstore_get_key_name,
112+
.GetStatus = test_cfstore_get_status,
113+
.GetValueLen = test_cfstore_get_value_len,
114+
.GetVersion = test_cfstore_get_version,
115+
.Initialize = test_cfstore_initialise,
116+
.Open = test_cfstore_open,
117+
.PowerControl = test_cfstore_power_control,
118+
.Read = test_cfstore_read,
119+
.Rseek = test_cfstore_rseek,
120+
.Uninitialize = test_cfstore_uninitialise,
121+
.Write = test_cfstore_write,
123122
};
124123

125124

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/ns_trace_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void debug_int(int i)
190190
{
191191
}
192192

193-
void printf_array(const void *buf , uint16_t len)
193+
void printf_array(const void *buf, uint16_t len)
194194
{
195195
}
196196

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,26 @@ void ns_dyn_mem_init(uint8_t *heap, uint16_t h_size, void (*passed_fptr)(heap_fa
1717

1818
void *ns_dyn_mem_alloc(int16_t alloc_size)
1919
{
20-
if (nsdynmemlib_stub.returnCounter > 0)
21-
{
20+
if (nsdynmemlib_stub.returnCounter > 0) {
2221
nsdynmemlib_stub.returnCounter--;
2322
return malloc(alloc_size);
24-
}
25-
else
26-
{
27-
return(nsdynmemlib_stub.expectedPointer);
23+
} else {
24+
return (nsdynmemlib_stub.expectedPointer);
2825
}
2926
}
3027

3128
void *ns_dyn_mem_temporary_alloc(int16_t alloc_size)
3229
{
33-
if (nsdynmemlib_stub.returnCounter > 0)
34-
{
30+
if (nsdynmemlib_stub.returnCounter > 0) {
3531
nsdynmemlib_stub.returnCounter--;
3632
return malloc(alloc_size);
37-
}
38-
else
39-
{
40-
return(nsdynmemlib_stub.expectedPointer);
33+
} else {
34+
return (nsdynmemlib_stub.expectedPointer);
4135
}
4236
}
4337

4438
void ns_dyn_mem_free(void *block)
4539
{
46-
free(block);
40+
free(block);
4741
}
4842

features/nanostack/nanostack-hal-mbed-cmsis-rtos/cs_nvm/test/test_cs_nvm_unit/unittest/stubs/nsdynmemLIB_stub.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" {
1212

1313
typedef struct {
1414
uint8_t returnCounter;
15-
void* expectedPointer;
15+
void *expectedPointer;
1616
} nsdynmemlib_stub_data_t;
1717

1818
extern nsdynmemlib_stub_data_t nsdynmemlib_stub;

0 commit comments

Comments
 (0)