Skip to content

Commit 3be792a

Browse files
simplify for statement
1 parent dd1d473 commit 3be792a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,8 +2527,11 @@ ble_error_t GenericGap::setPeriodicAdvertisingPayload(
25272527
typedef pal::advertising_fragment_description_t op_t;
25282528

25292529
const size_t hci_length = _pal_gap.get_maximum_hci_advertising_data_length();
2530+
size_t i = 0;
2531+
size_t end = payload.size();
25302532

2531-
for (size_t i = 0, end = payload.size(); (i < end) || (i == 0 && end == 0); i += hci_length) {
2533+
/* always do at least one iteration for empty payload */
2534+
do {
25322535
// select the operation based on the index
25332536
op_t op(op_t::INTERMEDIATE_FRAGMENT);
25342537
if (end < hci_length) {
@@ -2555,7 +2558,9 @@ ble_error_t GenericGap::setPeriodicAdvertisingPayload(
25552558
if (err) {
25562559
return err;
25572560
}
2558-
}
2561+
2562+
i += hci_length;
2563+
} while (i < end);
25592564

25602565
return BLE_ERROR_NONE;
25612566
}

0 commit comments

Comments
 (0)