From 827f63220e26d4235e6343a6cd6ccb2982c08051 Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Fri, 4 Apr 2025 13:50:19 +0200 Subject: [PATCH] Bluetooth: HFP_AG: Initialize variable to avoid warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 11.4.0, seems to believe this variable may be used uninitialized, and warns about it (causing a test build failure due to warnings being treated as errors). Let's just initialize the variable to 0 to avoid the issue, as the cost is trivial. subsys/bluetooth/host/classic/hfp_ag.c: In function ‘bt_hfp_ag_vts_handler’: 1095 subsys/bluetooth/host/classic/hfp_ag.c:3091:17: error: ‘code’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1096 3091 | bt_ag->transmit_dtmf_code(ag, code); 1097 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1098 The issue can be reproduced for ex. with: $ mkdir build ; cd build $ cmake -GNinja -DBOARD=native_sim/native/64 ../tests/bluetooth/shell \ -DCONF_FILE="prj_br.conf" $ ninja Signed-off-by: Alberto Escolar Piedras --- subsys/bluetooth/host/classic/hfp_ag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/classic/hfp_ag.c b/subsys/bluetooth/host/classic/hfp_ag.c index 8c12dde09a067..4813606f703f8 100644 --- a/subsys/bluetooth/host/classic/hfp_ag.c +++ b/subsys/bluetooth/host/classic/hfp_ag.c @@ -3062,7 +3062,7 @@ static int bt_hfp_ag_binp_handler(struct bt_hfp_ag *ag, struct net_buf *buf) static int bt_hfp_ag_vts_handler(struct bt_hfp_ag *ag, struct net_buf *buf) { int err; - char code; + char code = 0; if (!is_char(buf, '=')) { return -ENOTSUP;