From fd31133ae0bfa4158ffe122168e4c940de9464e3 Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Mon, 7 Oct 2019 10:59:12 +0530 Subject: [PATCH] NimBLE: Fix misc warnings and return code in `ble_hs_tx_data` - Previously `ble_hs_tx_data` returned 0 irrespective of error code returned by `ble_hci_trans_hs_acl_tx`. - Minor changes in `porting/nimble/` and `ble_gattc.c` to remove discard const qualifier warnings, fixes #4028. --- porting/nimble/include/mem/mem.h | 2 +- porting/nimble/include/os/os.h | 12 ++++++++++++ porting/nimble/include/os/os_mempool.h | 6 +++--- porting/nimble/include/stats/stats.h | 2 +- porting/nimble/src/mem.c | 2 +- porting/nimble/src/os_mempool.c | 8 ++++---- porting/nimble/src/os_msys_init.c | 2 +- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/porting/nimble/include/mem/mem.h b/porting/nimble/include/mem/mem.h index 1c29efbeb..61994e8b9 100644 --- a/porting/nimble/include/mem/mem.h +++ b/porting/nimble/include/mem/mem.h @@ -42,7 +42,7 @@ int mem_malloc_mbufpkt_pool(struct os_mempool *mempool, void **out_buf); int mem_init_mbuf_pool(void *mem, struct os_mempool *mempool, struct os_mbuf_pool *mbuf_pool, int num_blocks, - int block_size, char *name); + int block_size, const char *name); /** * Specifies a function used as a callback. Functions of this type allocate an diff --git a/porting/nimble/include/os/os.h b/porting/nimble/include/os/os.h index da7427f6e..ec495df9b 100644 --- a/porting/nimble/include/os/os.h +++ b/porting/nimble/include/os/os.h @@ -26,6 +26,18 @@ extern "C" { #endif +#if !defined __cplusplus +#define static_assert _Static_assert +#endif + +#ifndef min +#define min(a, b) ((a)<(b)?(a):(b)) +#endif + +#ifndef max +#define max(a, b) ((a)>(b)?(a):(b)) +#endif + #include "syscfg/syscfg.h" #include "nimble/nimble_npl.h" diff --git a/porting/nimble/include/os/os_mempool.h b/porting/nimble/include/os/os_mempool.h index cb77583b3..f11df3a0d 100644 --- a/porting/nimble/include/os/os_mempool.h +++ b/porting/nimble/include/os/os_mempool.h @@ -70,7 +70,7 @@ struct os_mempool { STAILQ_ENTRY(os_mempool) mp_list; SLIST_HEAD(,os_memblock); /** Name for memory block */ - char *name; + const char *name; }; /** @@ -182,7 +182,7 @@ typedef __uint128_t os_membuf_t; * @return os_error_t */ os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks, - uint32_t block_size, void *membuf, char *name); + uint32_t block_size, void *membuf, const char *name); /** * Initializes an extended memory pool. Extended attributes (e.g., callbacks) @@ -198,7 +198,7 @@ os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks, * @return os_error_t */ os_error_t os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks, - uint32_t block_size, void *membuf, char *name); + uint32_t block_size, void *membuf, const char *name); /** * Removes the specified mempool from the list of initialized mempools. diff --git a/porting/nimble/include/stats/stats.h b/porting/nimble/include/stats/stats.h index 996bcbc72..2669ebe28 100644 --- a/porting/nimble/include/stats/stats.h +++ b/porting/nimble/include/stats/stats.h @@ -67,7 +67,7 @@ stats_register(void *a, void *b) } static inline int -stats_init_and_reg(void *a, uint8_t b, uint8_t c, void *d, uint8_t e, void *f) +stats_init_and_reg(void *a, uint8_t b, uint8_t c, void *d, uint8_t e, const char *f) { /* dummy */ return 0; diff --git a/porting/nimble/src/mem.c b/porting/nimble/src/mem.c index 6bd6eec7a..a56fa1710 100644 --- a/porting/nimble/src/mem.c +++ b/porting/nimble/src/mem.c @@ -206,7 +206,7 @@ mem_malloc_mbufpkt_pool(struct os_mempool *mempool, int mem_init_mbuf_pool(void *mem, struct os_mempool *mempool, struct os_mbuf_pool *mbuf_pool, int num_blocks, - int block_size, char *name) + int block_size, const char *name) { int rc; diff --git a/porting/nimble/src/os_mempool.c b/porting/nimble/src/os_mempool.c index 00fb08a0e..74c534e25 100644 --- a/porting/nimble/src/os_mempool.c +++ b/porting/nimble/src/os_mempool.c @@ -38,7 +38,7 @@ #define OS_MEMPOOL_TRUE_BLOCK_SIZE(mp) OS_MEM_TRUE_BLOCK_SIZE(mp->mp_block_size) #endif -STAILQ_HEAD(, os_mempool) g_os_mempool_list; +STAILQ_HEAD(, os_mempool) g_os_mempool_list = STAILQ_HEAD_INITIALIZER(g_os_mempool_list); #if MYNEWT_VAL(OS_MEMPOOL_POISON) static uint32_t os_mem_poison = 0xde7ec7ed; @@ -118,7 +118,7 @@ os_mempool_guard_check(const struct os_mempool *mp, void *start) static os_error_t os_mempool_init_internal(struct os_mempool *mp, uint16_t blocks, - uint32_t block_size, void *membuf, char *name, + uint32_t block_size, void *membuf, const char *name, uint8_t flags) { int true_block_size; @@ -181,14 +181,14 @@ os_mempool_init_internal(struct os_mempool *mp, uint16_t blocks, os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks, uint32_t block_size, - void *membuf, char *name) + void *membuf, const char *name) { return os_mempool_init_internal(mp, blocks, block_size, membuf, name, 0); } os_error_t os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks, - uint32_t block_size, void *membuf, char *name) + uint32_t block_size, void *membuf, const char *name) { int rc; diff --git a/porting/nimble/src/os_msys_init.c b/porting/nimble/src/os_msys_init.c index d22ae351f..f2f41b9bb 100644 --- a/porting/nimble/src/os_msys_init.c +++ b/porting/nimble/src/os_msys_init.c @@ -106,7 +106,7 @@ os_msys_sanity(struct os_sanity_check *sc, void *arg) static void os_msys_init_once(void *data, struct os_mempool *mempool, struct os_mbuf_pool *mbuf_pool, - int block_count, int block_size, char *name) + int block_count, int block_size, const char *name) { int rc;