This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f01aed55 nimble/host: Fix maybe-uninitialized warning in periodic 
report
6f01aed55 is described below

commit 6f01aed55562c403e18035c1fde67085026955ff
Author: Szymon Janc <[email protected]>
AuthorDate: Tue Oct 20 01:22:32 2026 +0200

    nimble/host: Fix maybe-uninitialized warning in periodic report
    
    With -Og GCC is not able to figure out that cb and cb_arg are used
    only if psync was found and reports:
    
      ble_gap.c:1874:19: error: 'cb' may be used uninitialized
      [-Werror=maybe-uninitialized]
    
    Initialize both to NULL. This is the case for unit tests built with
    debug build profile once native debug builds use -Og.
    
    Assisted-by: Claude:claude-opus-5-5
---
 nimble/host/src/ble_gap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 362f16351..d76cdffae 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -1860,8 +1860,8 @@ ble_gap_rx_periodic_adv_rpt(const struct 
ble_hci_ev_le_subev_periodic_adv_rpt *e
 {
     struct ble_hs_periodic_sync *psync;
     struct ble_gap_event event;
-    ble_gap_event_fn *cb;
-    void *cb_arg;
+    ble_gap_event_fn *cb = NULL;
+    void *cb_arg = NULL;
 
     ble_hs_lock();
     psync = ble_hs_periodic_sync_find_by_handle(le16toh(ev->sync_handle));

Reply via email to