Skip to content

Commit 40b8976

Browse files
committed
nimble/gatt: Fix GCC 10 build with no BLE_GATT_WRITE_RELIABLE
When BLE_GATT_WRITE_RELIABLE handling of BLE_GATT_OP_WRITE_RELIABLE is not needed and is detected by gcc as: Error: repos/apache-mynewt-nimble/nimble/host/src/ble_gattc.c: In function 'ble_gattc_proc_free': repos/apache-mynewt-nimble/nimble/host/src/ble_gattc.c:709:66: error: array subscript 254 is outside the bounds of an interior zero-length array 'struct ble_gatt_attr[0]' [-Werror=zero-length-bounds] 709 | os_mbuf_free_chain(proc->write_reliable.attrs[i].om); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ repos/apache-mynewt-nimble/nimble/host/src/ble_gattc.c:199:34: note: while referencing 'attrs' 199 | struct ble_gatt_attr attrs[MYNEWT_VAL(BLE_GATT_WRITE_MAX_ATTRS)]; | ^~~~~ cc1: all warnings being treated as errors This change gets rid of offending code that is not needed when BLE_GATT_WRITE_LONG or BLE_GATT_WRITE_RELIABLE are 0.
1 parent f5b2ed5 commit 40b8976

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nimble/host/src/ble_gattc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,16 @@ ble_gattc_proc_free(struct ble_gattc_proc *proc)
698698

699699
switch (proc->op) {
700700
case BLE_GATT_OP_WRITE_LONG:
701-
os_mbuf_free_chain(proc->write_long.attr.om);
701+
if (MYNEWT_VAL(BLE_GATT_WRITE_LONG)) {
702+
os_mbuf_free_chain(proc->write_long.attr.om);
703+
}
702704
break;
703705

704706
case BLE_GATT_OP_WRITE_RELIABLE:
705-
for (i = 0; i < proc->write_reliable.num_attrs; i++) {
706-
os_mbuf_free_chain(proc->write_reliable.attrs[i].om);
707+
if (MYNEWT_VAL(BLE_GATT_WRITE_RELIABLE)) {
708+
for (i = 0; i < proc->write_reliable.num_attrs; i++) {
709+
os_mbuf_free_chain(proc->write_reliable.attrs[i].om);
710+
}
707711
}
708712
break;
709713

0 commit comments

Comments
 (0)