Skip to content

Commit 2140254

Browse files
Replace lambda function with memcmp
1 parent 2f5f8bd commit 2140254

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/platform/silabs/efr32/BLEManagerImpl.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ extern "C" {
3939
#include "sl_bt_stack_config.h"
4040
#include "sl_bt_stack_init.h"
4141
#include "timers.h"
42-
#include <algorithm>
4342
#include <ble/CHIPBleServiceData.h>
4443
#include <crypto/RandUtils.h>
44+
#include <cstring>
4545
#include <lib/support/CodeUtils.h>
4646
#include <lib/support/logging/CHIPLogging.h>
4747
#include <platform/CommissionableDataProvider.h>
@@ -116,11 +116,8 @@ BLEManagerImpl BLEManagerImpl::sInstance;
116116

117117
CHIP_ERROR BLEManagerImpl::_Init()
118118
{
119-
CHIP_ERROR err;
120-
121119
// Initialize the CHIP BleLayer.
122-
err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer());
123-
SuccessOrExit(err);
120+
ReturnErrorOnFailure(BleLayer::Init(this, this, &DeviceLayer::SystemLayer()));
124121

125122
memset(mBleConnections, 0, sizeof(mBleConnections));
126123
memset(mIndConfId, kUnusedIndex, sizeof(mIndConfId));
@@ -139,8 +136,8 @@ CHIP_ERROR BLEManagerImpl::_Init()
139136

140137
// Check that an address was not already configured at boot.
141138
// This covers the init-shutdown-init case to comply with the BLE address change at boot only requirement
142-
if (std::all_of(randomizedAddr.addr, randomizedAddr.addr + (sizeof(randomizedAddr.addr) / sizeof(uint8_t)),
143-
[](uint8_t i) { return i == 0; }))
139+
bd_addr temp = { 0 };
140+
if (memcmp(&randomizedAddr, &temp, sizeof(bd_addr)) == 0)
144141
{
145142
// Since a random address is not configured, configure one
146143
uint64_t random = Crypto::GetRandU64();
@@ -152,9 +149,7 @@ CHIP_ERROR BLEManagerImpl::_Init()
152149
}
153150

154151
PlatformMgr().ScheduleWork(DriveBLEState, 0);
155-
156-
exit:
157-
return err;
152+
return CHIP_NO_ERROR;
158153
}
159154

160155
uint16_t BLEManagerImpl::_NumConnections(void)

0 commit comments

Comments
 (0)