Bluetooth: HFP_AG: Initialize variable to avoid warning

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 <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2025-04-04 13:50:19 +02:00 committed by Benjamin Cabé
commit 59b62243fa

View file

@ -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;