Skip to content

Commit 923ce13

Browse files
author
Arto Kinnunen
committed
Merge commit '661681f65c3fb61aec2e4605bef0fc075cc8cb0d' into mbedos511
* commit '661681f65c3fb61aec2e4605bef0fc075cc8cb0d': Squashed 'features/frameworks/nanostack-libservice/' changes from bb56e37..1d4c358
2 parents e1ef0e4 + 661681f commit 923ce13

File tree

14 files changed

+164
-167
lines changed

14 files changed

+164
-167
lines changed

features/frameworks/nanostack-libservice/mbed-client-libservice/ns_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extern "C" {
8282
typedef struct ns_list {
8383
void *first_entry; ///< Pointer to first entry, or NULL if list is empty
8484
void **last_nextptr; ///< Pointer to last entry's `next` pointer, or
85-
///< to head's `first_entry` pointer if list is empty
85+
///< to head's `first_entry` pointer if list is empty
8686
} ns_list_t;
8787

8888
/** \brief Declare a list head type

features/frameworks/nanostack-libservice/mbed-client-libservice/ns_types.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ typedef int_fast32_t int_fast24_t;
213213
# define NS_STATIC_ASSERT(test, str) _Static_assert(test, str);
214214
# elif defined __GNUC__ && NS_GCC_VERSION >= 40600 && !defined __CC_ARM
215215
# ifdef _Static_assert
216-
/*
217-
* Some versions of glibc cdefs.h (which comes in via <stdint.h> above)
218-
* attempt to define their own _Static_assert (if GCC < 4.6 or
219-
* __STRICT_ANSI__) using an extern declaration, which doesn't work in a
220-
* struct/union.
221-
*
222-
* For GCC >= 4.6 and __STRICT_ANSI__, we can do better - just use
223-
* the built-in _Static_assert with __extension__. We have to do this, as
224-
* ns_list.h needs to use it in a union. No way to get at it though, without
225-
* overriding their define.
226-
*/
216+
/*
217+
* Some versions of glibc cdefs.h (which comes in via <stdint.h> above)
218+
* attempt to define their own _Static_assert (if GCC < 4.6 or
219+
* __STRICT_ANSI__) using an extern declaration, which doesn't work in a
220+
* struct/union.
221+
*
222+
* For GCC >= 4.6 and __STRICT_ANSI__, we can do better - just use
223+
* the built-in _Static_assert with __extension__. We have to do this, as
224+
* ns_list.h needs to use it in a union. No way to get at it though, without
225+
* overriding their define.
226+
*/
227227
# undef _Static_assert
228228
# define _Static_assert(x, y) __extension__ _Static_assert(x, y)
229229
# endif

features/frameworks/nanostack-libservice/source/libip4string/ip4tos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ uint_fast8_t ip4tos(const void *ip4addr, char *p)
4343
//Append a dot if this is not the last digit
4444
if (component < 3) {
4545
p[outputPos++] = '.';
46-
}
46+
}
4747
}
4848

4949
// Return length of generated string, excluding the terminating null character
@@ -59,7 +59,7 @@ static void ipv4_itoa(char *string, uint8_t byte)
5959
do {
6060
*string++ = '0' + byte % 10;
6161
byte /= 10;
62-
} while(byte);
62+
} while (byte);
6363

6464
//We put the final \0, then go back one step on the last digit for the swap
6565
*string-- = '\0';

features/frameworks/nanostack-libservice/source/libip6string/stoip6.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ bool stoip6(const char *ip6addr, size_t len, void *dest)
7474
coloncolon = field_no;
7575
q++;
7676
len -= 2;
77-
}
78-
else {
77+
} else {
7978
len -= 1;
8079
}
8180
}
@@ -150,11 +149,13 @@ int stoip6_prefix(const char *ip6addr, void *dest, int_fast16_t *prefix_len_out)
150149
static bool is_hex(char c)
151150
{
152151
// 'A' (0x41) and 'a' (0x61) are mapped in the ASCII table in such a way that masking the 0x20 bit turn 'a' in 'A'
153-
if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')
152+
if ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F') {
154153
return true;
154+
}
155155

156-
if (c >= '0' && c <= '9')
156+
if (c >= '0' && c <= '9') {
157157
return true;
158+
}
158159

159160
return false;
160161
}

features/frameworks/nanostack-libservice/source/nsdynmemLIB/nsdynmemLIB.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ const mem_stat_t *ns_dyn_mem_get_mem_stat(void)
8787

8888

8989
ns_mem_book_t *ns_mem_init(void *heap, ns_mem_heap_size_t h_size,
90-
void (*passed_fptr)(heap_fail_t),
91-
mem_stat_t *info_ptr)
90+
void (*passed_fptr)(heap_fail_t),
91+
mem_stat_t *info_ptr)
9292
{
9393
#ifndef STANDARD_MALLOC
9494
ns_mem_book_t *book;
@@ -108,7 +108,7 @@ ns_mem_book_t *ns_mem_init(void *heap, ns_mem_heap_size_t h_size,
108108
h_size -= (sizeof(ns_mem_word_size_t) - temp_int);
109109
}
110110
book = heap;
111-
book->heap_main = (ns_mem_word_size_t *)&(book[1]); // SET Heap Pointer
111+
book->heap_main = (ns_mem_word_size_t *) & (book[1]); // SET Heap Pointer
112112
book->heap_size = h_size - sizeof(ns_mem_book_t); //Set Heap Size
113113
temp_int = (book->heap_size / sizeof(ns_mem_word_size_t));
114114
temp_int -= 2;
@@ -127,7 +127,7 @@ ns_mem_book_t *ns_mem_init(void *heap, ns_mem_heap_size_t h_size,
127127
memset(book->mem_stat_info_ptr, 0, sizeof(mem_stat_t));
128128
book->mem_stat_info_ptr->heap_sector_size = book->heap_size;
129129
}
130-
book->temporary_alloc_heap_limit = book->heap_size/100 * (100-TEMPORARY_ALLOC_FREE_HEAP_THRESHOLD);
130+
book->temporary_alloc_heap_limit = book->heap_size / 100 * (100 - TEMPORARY_ALLOC_FREE_HEAP_THRESHOLD);
131131
#endif
132132
//There really is no support to standard malloc in this library anymore
133133
book->heap_failure_callback = passed_fptr;
@@ -154,12 +154,12 @@ int ns_mem_set_temporary_alloc_free_heap_threshold(ns_mem_book_t *book, uint8_t
154154
return -1;
155155
}
156156

157-
if (free_heap_amount && free_heap_amount < book->heap_size/2) {
157+
if (free_heap_amount && free_heap_amount < book->heap_size / 2) {
158158
heap_limit = book->heap_size - free_heap_amount;
159159
}
160160

161161
if (!free_heap_amount && free_heap_percentage && free_heap_percentage < 50) {
162-
heap_limit = book->heap_size/100 * (100 - free_heap_percentage);
162+
heap_limit = book->heap_size / 100 * (100 - free_heap_percentage);
163163
}
164164

165165
if (free_heap_amount == 0 && free_heap_percentage == 0) {
@@ -215,7 +215,7 @@ static ns_mem_word_size_t convert_allocation_size(ns_mem_book_t *book, ns_mem_bl
215215
heap_failure(book, NS_DYN_MEM_HEAP_SECTOR_UNITIALIZED);
216216
} else if (requested_bytes < 1) {
217217
heap_failure(book, NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID);
218-
} else if (requested_bytes > (book->heap_size - 2 * sizeof(ns_mem_word_size_t)) ) {
218+
} else if (requested_bytes > (book->heap_size - 2 * sizeof(ns_mem_word_size_t))) {
219219
heap_failure(book, NS_DYN_MEM_ALLOCATE_SIZE_NOT_VALID);
220220
}
221221
return (requested_bytes + sizeof(ns_mem_word_size_t) - 1) / sizeof(ns_mem_word_size_t);
@@ -266,10 +266,10 @@ static void *ns_mem_internal_alloc(ns_mem_book_t *book, const ns_mem_block_size_
266266

267267
// ns_list_foreach, either forwards or backwards, result to ptr
268268
for (hole_t *cur_hole = direction > 0 ? ns_list_get_first(&book->holes_list)
269-
: ns_list_get_last(&book->holes_list);
270-
cur_hole;
271-
cur_hole = direction > 0 ? ns_list_get_next(&book->holes_list, cur_hole)
272-
: ns_list_get_previous(&book->holes_list, cur_hole)
269+
: ns_list_get_last(&book->holes_list);
270+
cur_hole;
271+
cur_hole = direction > 0 ? ns_list_get_next(&book->holes_list, cur_hole)
272+
: ns_list_get_previous(&book->holes_list, cur_hole)
273273
) {
274274
ns_mem_word_size_t *p = block_start_from_hole(cur_hole);
275275
if (ns_mem_block_validate(p) != 0 || *p >= 0) {
@@ -295,7 +295,7 @@ static void *ns_mem_internal_alloc(ns_mem_book_t *book, const ns_mem_block_size_
295295
ns_mem_word_size_t hole_size = block_data_size - data_size - 2;
296296
ns_mem_word_size_t *hole_ptr;
297297
//There is enough room for a new hole so create it first
298-
if ( direction > 0 ) {
298+
if (direction > 0) {
299299
hole_ptr = block_ptr + 1 + data_size + 1;
300300
// Hole will be left at end of area.
301301
// Would like to just replace this block_ptr with new descriptor, but
@@ -324,7 +324,7 @@ static void *ns_mem_internal_alloc(ns_mem_book_t *book, const ns_mem_block_size_
324324
block_ptr[0] = data_size;
325325
block_ptr[1 + data_size] = data_size;
326326

327-
done:
327+
done:
328328
if (book->mem_stat_info_ptr) {
329329
if (block_ptr) {
330330
//Update Allocate OK
@@ -433,7 +433,7 @@ static void ns_mem_free_and_merge_with_adjacent_blocks(ns_mem_book_t *book, ns_m
433433
} else {
434434
// Didn't find adjacent descriptors, but may still
435435
// be merging with small blocks without descriptors.
436-
if ( merged_data_size >= HOLE_T_SIZE ) {
436+
if (merged_data_size >= HOLE_T_SIZE) {
437437
// Locate hole position in list, if we don't already know
438438
// from merging with the block above.
439439
if (!existing_end) {

features/frameworks/nanostack-libservice/source/nvmHelper/ns_nvm_helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static NS_LIST_DEFINE(ns_nvm_request_list, ns_nvm_request_t, link);
6060
*/
6161
void ns_nvm_callback_func(platform_nvm_status status, void *args)
6262
{
63-
ns_nvm_request_t *ns_nvm_request_ptr = (ns_nvm_request_t*)args;
63+
ns_nvm_request_t *ns_nvm_request_ptr = (ns_nvm_request_t *)args;
6464
int client_retval = NS_NVM_OK;
6565

6666
if (status == PLATFORM_NVM_ERROR) {
@@ -69,7 +69,7 @@ void ns_nvm_callback_func(platform_nvm_status status, void *args)
6969
client_retval = NS_NVM_DATA_NOT_FOUND;
7070
}
7171

72-
switch(ns_nvm_request_ptr->operation) {
72+
switch (ns_nvm_request_ptr->operation) {
7373
case NS_NVM_INIT:
7474
ns_nvm_operation_continue(ns_nvm_request_ptr->original_request, true);
7575
ns_dyn_mem_free(ns_nvm_request_ptr);
@@ -185,7 +185,7 @@ static int ns_nvm_operation_continue(ns_nvm_request_t *request, bool free_reques
185185
platform_nvm_status ret = PLATFORM_NVM_OK;
186186

187187
ns_nvm_operation_in_progress = true;
188-
switch(request->operation) {
188+
switch (request->operation) {
189189
case NS_NVM_KEY_WRITE:
190190
request->operation = NS_NVM_KEY_CREATE;
191191
ret = platform_nvm_key_create(ns_nvm_callback_func, request->client_key_name, *request->buffer_len, 0, request);

features/frameworks/nanostack-libservice/test/libService/unittest/ip6tos/ip6tos_test.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ TEST(ip6tos, ip6_prefix_tos_func)
6464
/***********************************************************/
6565
/* Second test group for the old tests that were once lost */
6666

67-
const char string_addr[][40] =
68-
{
67+
const char string_addr[][40] = {
6968
"2001:db8::1:0:0:1", // 1
7069
"2001:db8:aaaa:bbbb:cccc:dddd:eeee:1", // 2
7170
"2001:db8::1", // 3
@@ -81,34 +80,31 @@ const char string_addr[][40] =
8180
};
8281

8382

84-
const uint8_t hex_addr[][16] =
85-
{
86-
{ 0x20, 0x01, 0xd, 0xb8, 0,0,0,0,0,1,0,0,0,0,0,1 },
83+
const uint8_t hex_addr[][16] = {
84+
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 },
8785
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0x00, 0x01 },
88-
{ 0x20, 0x01, 0xd, 0xb8, 0,0,0,0,0,0,0,0,0,0,0,1 },
89-
{ 0x20, 0x01, 0xd,0xb8, 0,0,0,0,0,0,0,0, 0,2,0,1 },
90-
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0,0, 0x00, 0x01 },
91-
{ 0x20, 0x01, 0xd, 0xb8, 0,0,0,0,0xaa,0xaa,0,0,0,0,0,1 },
92-
{ 0x20, 0x01, 0,0 ,0,0 ,0,1,0,0,0,0,0,0,0,1 },
93-
{ 0x20, 0x01, 0,0 ,0,0 ,0,1,0,0,0,0,0,0,0,0 },
86+
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
87+
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1 },
88+
{ 0x20, 0x01, 0xd, 0xb8, 0xaa, 0xaa, 0xbb, 0xbb, 0xcc, 0xcc, 0xdd, 0xdd, 0, 0, 0x00, 0x01 },
89+
{ 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0xaa, 0xaa, 0, 0, 0, 0, 0, 1 },
90+
{ 0x20, 0x01, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 },
91+
{ 0x20, 0x01, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
9492
{ 0x20, 0x01, 0xd, 0xb8 },
95-
{ 0,0,0,0,0,0,0,0,0xaa,0xaa,0,0,0,0,0,1 },
96-
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
97-
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
93+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0xaa, 0xaa, 0, 0, 0, 0, 0, 1 },
94+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
95+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
9896
};
9997

10098
char buf[40];
10199
int i = 0;
102100

103101
TEST_GROUP(ip6tos_2)
104102
{
105-
void setUp(void)
106-
{
103+
void setUp(void) {
107104
memset(buf, 0, 40);
108105
}
109106

110-
void tearDown(void)
111-
{
107+
void tearDown(void) {
112108
i++;
113109
}
114110
};

0 commit comments

Comments
 (0)