Skip to content

Commit f327ea1

Browse files
committed
NimBLEL2CAP: Refactor to support C++ 11 as requested by review h2zero#324.
1 parent a1d19e6 commit f327ea1

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/NimBLEL2CAPChannel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ bool NimBLEL2CAPChannel::setupMemPool() {
4747
return false;
4848
}
4949

50-
if (auto rc = os_mempool_init(&_coc_mempool, buf_blocks, L2CAP_BUF_BLOCK_SIZE, _coc_memory, "appbuf"); rc != 0) {
50+
auto rc = os_mempool_init(&_coc_mempool, buf_blocks, L2CAP_BUF_BLOCK_SIZE, _coc_memory, "appbuf");
51+
if (rc != 0) {
5152
NIMBLE_LOGE(LOG_TAG, "Can't os_mempool_init: %d", rc);
5253
return false;
5354
}
54-
if (auto rc = os_mbuf_pool_init(&_coc_mbuf_pool, &_coc_mempool, L2CAP_BUF_BLOCK_SIZE, buf_blocks); rc != 0) {
55+
56+
auto rc2 = os_mbuf_pool_init(&_coc_mbuf_pool, &_coc_mempool, L2CAP_BUF_BLOCK_SIZE, buf_blocks);
57+
if (rc2 != 0) {
5558
NIMBLE_LOGE(LOG_TAG, "Can't os_mbuf_pool_init: %d", rc);
5659
return false;
5760
}

src/NimBLEL2CAPChannel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class NimBLEL2CAPChannel {
7474
struct os_mbuf_pool _coc_mbuf_pool;
7575

7676
// Runtime handling
77-
std::atomic<bool> stalled = false;
77+
std::atomic<bool> stalled{false};
7878
SemaphoreHandle_t stalledSemaphore = nullptr;
7979

8080
// Allocate / deallocate NimBLE memory pool
@@ -112,4 +112,4 @@ class NimBLEL2CAPChannelCallbacks {
112112
virtual void onDisconnect(NimBLEL2CAPChannel* channel) {};
113113
};
114114

115-
#endif
115+
#endif

src/NimBLEL2CAPServer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ NimBLEL2CAPServer::~NimBLEL2CAPServer() {
2424
NimBLEL2CAPChannel* NimBLEL2CAPServer::createService(const uint16_t psm, const uint16_t mtu, NimBLEL2CAPChannelCallbacks* callbacks) {
2525

2626
auto service = new NimBLEL2CAPChannel(psm, mtu, callbacks);
27+
auto rc = ble_l2cap_create_server(psm, mtu, NimBLEL2CAPChannel::handleL2capEvent, service);
2728

28-
if (auto rc = ble_l2cap_create_server(psm, mtu, NimBLEL2CAPChannel::handleL2capEvent, service); rc != 0) {
29+
if (rc != 0) {
2930
NIMBLE_LOGE(LOG_TAG, "Could not ble_l2cap_create_server: %d", rc);
3031
return nullptr;
3132
}
3233

3334
this->services.push_back(service);
34-
return service;
35+
return service;
3536
}

0 commit comments

Comments
 (0)