From 3d5bc69c8576b01032eed3611f11ceb74be8f4c3 Mon Sep 17 00:00:00 2001 From: Christopher Collins Date: Wed, 9 Aug 2017 17:28:34 -0700 Subject: [PATCH] BLE Host - Allow NULL output params in ID fns. X-Original-Commit: 27dc774b176b14b72e580050d98ba6b76da01337 --- nimble/host/src/ble_hs_id.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nimble/host/src/ble_hs_id.c b/nimble/host/src/ble_hs_id.c index 8dd0c0275..07ccf7297 100644 --- a/nimble/host/src/ble_hs_id.c +++ b/nimble/host/src/ble_hs_id.c @@ -117,10 +117,14 @@ done: * o BLE_ADDR_PUBLIC * o BLE_ADDR_RANDOM * @param out_id_addr On success, this is reseated to point to the - * retrieved 6-byte identity address. + * retrieved 6-byte identity address. Pass + * NULL if you do not require this + * information. + * @param out_is_nrpa On success, the pointed-to value indicates * whether the retrieved address is a - * non-resolvable private address. + * non-resolvable private address. Pass NULL + * if you do not require this information. * * @return 0 on success; * BLE_HS_EINVAL if an invalid address type was @@ -178,10 +182,12 @@ ble_hs_id_addr(uint8_t id_addr_type, const uint8_t **out_id_addr, * o BLE_ADDR_RANDOM * @param out_id_addr On success, the requested identity address is * copied into this buffer. The buffer must - * be at least six bytes in size. + * be at least six bytes in size. Pass NULL + * if you do not require this information. * @param out_is_nrpa On success, the pointed-to value indicates * whether the retrieved address is a - * non-resolvable private address. + * non-resolvable private address. Pass NULL + * if you do not require this information. * * @return 0 on success; * BLE_HS_EINVAL if an invalid address type was @@ -200,7 +206,7 @@ ble_hs_id_copy_addr(uint8_t id_addr_type, uint8_t *out_id_addr, ble_hs_lock(); rc = ble_hs_id_addr(id_addr_type, &addr, out_is_nrpa); - if (rc == 0) { + if (rc == 0 && out_id_addr != NULL) { memcpy(out_id_addr, addr, 6); }