Skip to contentSkip to conversation

media: Fix scan-build warnings

PATCH Superseded Luiz Augusto von Dentz 1 participant 1 message Aug 30, 2022 Bluetooth drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 media: Fix scan-build warnings

From: Luiz Augusto von Dentz <[email protected]>

This fixes the following warnings:

profiles/audio/media.c:1465:6: warning: 8th function call argument is an uninitialized value
if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3012:3: warning: Use of memory after it is freed

                release_endpoint(adapter->endpoints->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3015:3: warning: Use of memory after it is freed
                media_player_destroy(adapter->players->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 profiles/audio/media.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
profiles/audio/media.c +5 -4
index 85278a6d9be4..1d0fcec48fb6 100644
@@ -1434,7 +1434,7 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg,
 	gboolean delay_reporting = FALSE;
 	uint8_t codec = 0;
 	struct bt_bap_pac_qos qos = {};
-	uint8_t *capabilities;
+	uint8_t *capabilities = NULL;
 	int size = 0;
 	int err;
 
@@ -2998,13 +2998,14 @@ static const GDBusPropertyTable media_properties[] = {
 static void path_free(void *data)
 {
 	struct media_adapter *adapter = data;
+	GSList *l;
 
 	queue_destroy(adapter->apps, app_free);
 
-	while (adapter->endpoints)
-		release_endpoint(adapter->endpoints->data);
+	for (l = adapter->endpoints; l; l = g_slist_next(l))
+		release_endpoint(l->data);
 
-	while (adapter->players)
+	for (l = adapter->players; l; l = g_slist_next(l))
 		media_player_destroy(adapter->players->data);
 
 	adapters = g_slist_remove(adapters, adapter);
Signature · 1 line
2.37.2