From 16d59c062d498b7db210d9dc57255ac5d1d945ad Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Mon, 2 Dec 2024 11:07:07 +0530 Subject: [PATCH] fix(nimble): Address few coverity reported issues 1. too_few_printf_args: Corrected print statement to pass arguments 2. Fixed nesting levels 3. Fixed unused value warnings --- nimble/host/src/ble_att_clt.c | 2 -- nimble/host/src/ble_gattc.c | 2 +- nimble/host/src/ble_hs_hci_evt.c | 3 ++- nimble/host/src/ble_sm.c | 3 ++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nimble/host/src/ble_att_clt.c b/nimble/host/src/ble_att_clt.c index db793bb66..aa201ed57 100644 --- a/nimble/host/src/ble_att_clt.c +++ b/nimble/host/src/ble_att_clt.c @@ -1108,7 +1108,6 @@ ble_att_clt_tx_notify_mult(uint16_t conn_handle, struct os_mbuf *txom) if (ble_att_cmd_get(BLE_ATT_OP_NOTIFY_MULTI_REQ, 0, &txom2) == NULL) { return BLE_HS_ENOMEM; - goto err; } os_mbuf_concat(txom2, txom); @@ -1119,7 +1118,6 @@ ble_att_clt_tx_notify_mult(uint16_t conn_handle, struct os_mbuf *txom) ble_eatt_release_chan(conn_handle, BLE_GATT_OP_DUMMY); } -err: return rc; } diff --git a/nimble/host/src/ble_gattc.c b/nimble/host/src/ble_gattc.c index 2f6decae6..c8b292f6c 100644 --- a/nimble/host/src/ble_gattc.c +++ b/nimble/host/src/ble_gattc.c @@ -4674,7 +4674,7 @@ ble_gatts_notify_multiple_custom(uint16_t conn_handle, */ rc = ble_att_svr_read_local(tuples[i].handle, &tuples[i].value); if (rc != 0) { - BLE_HS_LOG(ERROR, "Attribute read failed (err=0x%02x), rc"); + BLE_HS_LOG(ERROR, "Attribute read failed (err=0x%02x)", rc); goto done; } } diff --git a/nimble/host/src/ble_hs_hci_evt.c b/nimble/host/src/ble_hs_hci_evt.c index 6e5eed06b..fc3a30311 100644 --- a/nimble/host/src/ble_hs_hci_evt.c +++ b/nimble/host/src/ble_hs_hci_evt.c @@ -1297,8 +1297,9 @@ ble_hs_hci_evt_process(struct ble_hci_ev *ev) BLE_HS_LOG(DEBUG, "ble_hs_event_rx_hci_ev; opcode=0x%x ", ev->opcode); /* For LE Meta, print subevent code */ - if(ev->opcode == 0x3e) + if(ev->opcode == 0x3e) { BLE_HS_LOG(DEBUG, "subevent: 0x%x", ev->data[0]); + } BLE_HS_LOG(DEBUG, "\n"); } diff --git a/nimble/host/src/ble_sm.c b/nimble/host/src/ble_sm.c index 2f6661369..59e3acaa3 100644 --- a/nimble/host/src/ble_sm.c +++ b/nimble/host/src/ble_sm.c @@ -557,11 +557,12 @@ ble_sm_persist_keys(struct ble_sm_proc *proc) switch (peer_addr.type) { case BLE_ADDR_PUBLIC: case BLE_ADDR_PUBLIC_ID: - conn->bhc_peer_addr.type = BLE_ADDR_PUBLIC_ID; #if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY) /* In case of Host based privacy, we should not be changing * peer address type to BLE_ADDR_PUBLIC_ID */ conn->bhc_peer_addr.type = BLE_ADDR_PUBLIC; +#else + conn->bhc_peer_addr.type = BLE_ADDR_PUBLIC_ID; #endif break;