From f060c3a5dc22ab50692b07c1da65e598f6e92535 Mon Sep 17 00:00:00 2001 From: Francois Beaufort Date: Thu, 21 Apr 2016 10:18:49 +0200 Subject: [PATCH] audio/avrcp: Fix uninitialized variable This fixes the following error: profiles/audio/avrcp.c:2847:6: error: variable 'num_of_items' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (pdu->params[0] == AVRCP_STATUS_OUT_OF_BOUNDS) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ profiles/audio/avrcp.c:2857:40: note: uninitialized use occurs here media_player_total_items_complete(mp, num_of_items); ^~~~~~~~~~~~ profiles/audio/avrcp.c:2847:2: note: remove the 'if' if its condition is always false if (pdu->params[0] == AVRCP_STATUS_OUT_OF_BOUNDS) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ profiles/audio/avrcp.c:2839:23: note: initialize the variable 'num_of_items' to silence this warning uint32_t num_of_items; ^ = 0 --- profiles/audio/avrcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 37bc29137..70c184b1c 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3112,7 +3112,7 @@ static gboolean avrcp_get_total_numberofitems_rsp(struct avctp *conn, struct avrcp *session = user_data; struct avrcp_player *player = session->controller->player; struct media_player *mp = player->user_data; - uint32_t num_of_items; + uint32_t num_of_items = 0; if (pdu == NULL) return -ETIMEDOUT; -- 2.47.3