a2dp: Fixed warn_unused_result warning
authorMichał Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>
Tue, 30 Apr 2019 10:30:00 +0000 (12:30 +0200)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:47 +0000 (14:27 +0530)
This used to break builds when using maintainer mode via
./bootstrap-configure:

profiles/audio/a2dp.c:1775:2: error: ignoring return value of
    ‘asprintf’, declared with attribute warn_unused_result
    [-Werror=unused-result]
  asprintf(&sep->path, "%s/sep%d",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ice4d01f47db1dcecadf3f0b57361855baad941fb
Signed-off-by: himanshu <h.himanshu@samsung.com>
profiles/audio/a2dp.c

index 0c01e2b..4c66c92 100644 (file)
@@ -1913,8 +1913,15 @@ static void register_remote_sep(void *data, void *user_data)
        if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
                goto done;
 
-       asprintf(&sep->path, "%s/sep%d", device_get_path(chan->device),
-                                                       avdtp_get_seid(rsep));
+       if (asprintf(&sep->path, "%s/sep%d",
+                               device_get_path(chan->device),
+                               avdtp_get_seid(rsep)) < 0) {
+               error("Could not allocate path for remote sep %s/sep%d",
+                               device_get_path(chan->device),
+                               avdtp_get_seid(rsep));
+               sep->path = NULL;
+               goto done;
+       }
 
        if (g_dbus_register_interface(btd_get_dbus_connection(),
                                sep->path, MEDIA_ENDPOINT_INTERFACE,