mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: add spa_aprintf helper
Add a asprintf helper function that handles errors correctly. Use this in places where we use asprintf to avoid warnings when we don't check the return value.
This commit is contained in:
parent
aee3191bad
commit
6ac9b7b3a7
16 changed files with 102 additions and 85 deletions
|
|
@ -241,6 +241,14 @@ struct spa_fraction {
|
|||
#define spa_memmove(d,s,n) memmove(d,s,n)
|
||||
#endif
|
||||
|
||||
#define spa_aprintf(_fmt, ...) \
|
||||
({ \
|
||||
char *_strp; \
|
||||
if (asprintf(&(_strp), (_fmt), ## __VA_ARGS__ ) == -1) \
|
||||
_strp = NULL; \
|
||||
_strp; \
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1266,7 +1266,9 @@ static int register_a2dp_endpoint(struct spa_bt_monitor *monitor,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
asprintf(&object_path, "%s/%d", profile_path, monitor->count++);
|
||||
object_path = spa_aprintf("%s/%d", profile_path, monitor->count++);
|
||||
if (object_path == NULL)
|
||||
return -errno;
|
||||
|
||||
spa_log_debug(monitor->log, "Registering endpoint: %s", object_path);
|
||||
|
||||
|
|
@ -1714,7 +1716,9 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
|
|||
|
||||
spa_log_debug(monitor->log, "NewConnection path=%s, fd=%d, profile %s", path, fd, handler);
|
||||
|
||||
asprintf(&pathfd, "%s/fd%d", path, fd);
|
||||
if ((pathfd = spa_aprintf("%s/fd%d", path, fd)) == NULL)
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
||||
t = transport_create(monitor, pathfd, sizeof(struct transport_data));
|
||||
if (t == NULL) {
|
||||
spa_log_warn(monitor->log, "can't create transport: %m");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue