mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04: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
|
|
@ -796,11 +796,14 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp, const char *name,
|
|||
pw->flags = flags;
|
||||
|
||||
if (node_name == NULL)
|
||||
err = asprintf(&pw->node_name, "ALSA %s",
|
||||
pw->node_name = spa_aprintf("ALSA %s",
|
||||
stream == SND_PCM_STREAM_PLAYBACK ? "Playback" : "Capture");
|
||||
else
|
||||
pw->node_name = strdup(node_name);
|
||||
|
||||
if (pw->node_name == NULL)
|
||||
return -errno;
|
||||
|
||||
pw->target = PW_ID_ANY;
|
||||
if (str != NULL)
|
||||
pw->target = atoi(str);
|
||||
|
|
|
|||
|
|
@ -2254,8 +2254,7 @@ char *jack_get_uuid_for_client_name (jack_client_t *client,
|
|||
|
||||
spa_list_for_each(o, &c->context.nodes, link) {
|
||||
if (strcmp(o->node.name, client_name) == 0) {
|
||||
char *uuid;
|
||||
asprintf(&uuid, "%" PRIu64, (cuuid << 32) | o->id);
|
||||
char *uuid = spa_aprintf( "%" PRIu64, (cuuid << 32) | o->id);
|
||||
pw_log_debug(NAME" %p: name %s -> %s",
|
||||
client, client_name, uuid);
|
||||
return uuid;
|
||||
|
|
@ -4053,9 +4052,7 @@ SPA_EXPORT
|
|||
char *jack_client_get_uuid (jack_client_t *client)
|
||||
{
|
||||
struct client *c = (struct client *) client;
|
||||
char *uuid = NULL;
|
||||
asprintf(&uuid, "%d", c->node_id);
|
||||
return uuid;
|
||||
return spa_aprintf("%d", c->node_id);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ static struct pw_command *parse_command_help(struct pw_properties *properties, c
|
|||
return this;
|
||||
|
||||
no_mem:
|
||||
asprintf(err, "alloc failed: %m");
|
||||
*err = spa_aprintf("alloc failed: %m");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -126,11 +126,11 @@ static struct pw_command *parse_command_set_prop(struct pw_properties *propertie
|
|||
return this;
|
||||
|
||||
error_arguments:
|
||||
asprintf(err, "%s requires <property-name> <value>", this->args[0]);
|
||||
*err = spa_aprintf("%s requires <property-name> <value>", this->args[0]);
|
||||
pw_free_strv(this->args);
|
||||
return NULL;
|
||||
error_alloc:
|
||||
asprintf(err, "alloc failed: %m");
|
||||
*err = spa_aprintf("alloc failed: %m");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ execute_command_add_spa_lib(struct pw_command *command, struct pw_context *conte
|
|||
|
||||
res = pw_context_add_spa_lib(context, command->args[1], command->args[2]);
|
||||
if (res < 0) {
|
||||
asprintf(err, "could not add spa library \"%s\"", command->args[1]);
|
||||
*err = spa_aprintf("could not add spa library \"%s\"", command->args[1]);
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -166,11 +166,11 @@ static struct pw_command *parse_command_add_spa_lib(struct pw_properties *proper
|
|||
return this;
|
||||
|
||||
no_library:
|
||||
asprintf(err, "%s requires <factory-regex> <library-name>", this->args[0]);
|
||||
*err = spa_aprintf("%s requires <factory-regex> <library-name>", this->args[0]);
|
||||
pw_free_strv(this->args);
|
||||
return NULL;
|
||||
no_mem:
|
||||
asprintf(err, "alloc failed: %m");
|
||||
*err = spa_aprintf("alloc failed: %m");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ execute_command_module_load(struct pw_command *command, struct pw_context *conte
|
|||
|
||||
module = pw_context_load_module(context, command->args[1], command->args[2], NULL);
|
||||
if (module == NULL) {
|
||||
asprintf(err, "could not load module \"%s\": %m", command->args[1]);
|
||||
*err = spa_aprintf("could not load module \"%s\": %m", command->args[1]);
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -206,11 +206,11 @@ static struct pw_command *parse_command_module_load(struct pw_properties *proper
|
|||
return this;
|
||||
|
||||
no_module:
|
||||
asprintf(err, "%s requires a module name", this->args[0]);
|
||||
*err = spa_aprintf("%s requires a module name", this->args[0]);
|
||||
pw_free_strv(this->args);
|
||||
return NULL;
|
||||
no_mem:
|
||||
asprintf(err, "alloc failed: %m");
|
||||
*err = spa_aprintf("alloc failed: %m");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ execute_command_exec(struct pw_command *command, struct pw_context *context, cha
|
|||
res = execvp(command->args[1], command->args);
|
||||
if (res == -1) {
|
||||
res = -errno;
|
||||
asprintf(err, "'%s': %m", command->args[1]);
|
||||
*err = spa_aprintf("'%s': %m", command->args[1]);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
@ -257,11 +257,11 @@ static struct pw_command *parse_command_exec(struct pw_properties *properties, c
|
|||
return this;
|
||||
|
||||
no_executable:
|
||||
asprintf(err, "requires an executable name");
|
||||
*err = spa_aprintf("requires an executable name");
|
||||
pw_free_strv(this->args);
|
||||
return NULL;
|
||||
no_mem:
|
||||
asprintf(err, "alloc failed: %m");
|
||||
*err = spa_aprintf("alloc failed: %m");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ struct pw_command *pw_command_parse(struct pw_properties *properties, const char
|
|||
}
|
||||
}
|
||||
|
||||
asprintf(err, "Command \"%s\" does not exist", name);
|
||||
*err = spa_aprintf("Command \"%s\" does not exist", name);
|
||||
out:
|
||||
free(name);
|
||||
return command;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ out:
|
|||
return 0;
|
||||
|
||||
error_parse:
|
||||
asprintf(err, "%s:%u: %s", filename, lineno, local_err);
|
||||
*err = spa_aprintf("%s:%u: %s", filename, lineno, local_err);
|
||||
free(local_err);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ int pw_daemon_config_load_file(struct pw_daemon_config *config, const char *file
|
|||
pw_log_debug("deamon-config %p: loading configuration file '%s'", config, filename);
|
||||
|
||||
if ((f = fopen(filename, "r")) == NULL) {
|
||||
asprintf(err, "failed to open configuration file '%s': %s", filename,
|
||||
*err = spa_aprintf("failed to open configuration file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
goto open_error;
|
||||
}
|
||||
|
|
@ -137,8 +137,7 @@ int pw_daemon_config_load_file(struct pw_daemon_config *config, const char *file
|
|||
if (!fgets(buf, sizeof(buf), f)) {
|
||||
if (feof(f))
|
||||
break;
|
||||
|
||||
asprintf(err, "failed to read configuration file '%s': %s",
|
||||
*err = spa_aprintf("failed to read configuration file '%s': %s",
|
||||
filename, strerror(errno));
|
||||
goto read_error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,12 +322,12 @@ rd_device_new(DBusConnection *connection, const char *device_name, const char *a
|
|||
|
||||
d->application_name = strdup(application_name);
|
||||
|
||||
asprintf(&d->object_path, OBJECT_PREFIX "%s", device_name);
|
||||
d->object_path = spa_aprintf(OBJECT_PREFIX "%s", device_name);
|
||||
if (d->object_path == NULL) {
|
||||
res = -errno;
|
||||
goto error_free;
|
||||
}
|
||||
asprintf(&d->service_name, SERVICE_PREFIX "%s", device_name);
|
||||
d->service_name = spa_aprintf(SERVICE_PREFIX "%s", device_name);
|
||||
if (d->service_name == NULL) {
|
||||
res = -errno;
|
||||
goto error_free;
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ struct pw_impl_port *pw_context_find_port(struct pw_context *context,
|
|||
}
|
||||
}
|
||||
if (best == NULL) {
|
||||
asprintf(error, "No matching Node found");
|
||||
*error = spa_aprintf("No matching Node found");
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
|
@ -600,9 +600,9 @@ int pw_context_find_format(struct pw_context *context,
|
|||
SPA_PARAM_Format, &oidx,
|
||||
NULL, &filter, &fb)) != 1) {
|
||||
if (res < 0)
|
||||
asprintf(error, "error get output format: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error get output format: %s", spa_strerror(res));
|
||||
else
|
||||
asprintf(error, "no output formats");
|
||||
*error = spa_aprintf("no output formats");
|
||||
goto error;
|
||||
}
|
||||
pw_log_debug(NAME" %p: Got output format:", context);
|
||||
|
|
@ -614,9 +614,9 @@ int pw_context_find_format(struct pw_context *context,
|
|||
SPA_PARAM_EnumFormat, &iidx,
|
||||
filter, format, builder)) <= 0) {
|
||||
if (res < 0)
|
||||
asprintf(error, "error input enum formats: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
|
||||
else
|
||||
asprintf(error, "no input formats");
|
||||
*error = spa_aprintf("no input formats");
|
||||
goto error;
|
||||
}
|
||||
} else if (out_state >= PW_IMPL_PORT_STATE_CONFIGURE && in_state > PW_IMPL_PORT_STATE_CONFIGURE) {
|
||||
|
|
@ -627,9 +627,9 @@ int pw_context_find_format(struct pw_context *context,
|
|||
SPA_PARAM_Format, &iidx,
|
||||
NULL, &filter, &fb)) != 1) {
|
||||
if (res < 0)
|
||||
asprintf(error, "error get input format: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error get input format: %s", spa_strerror(res));
|
||||
else
|
||||
asprintf(error, "no input format");
|
||||
*error = spa_aprintf("no input format");
|
||||
goto error;
|
||||
}
|
||||
pw_log_debug(NAME" %p: Got input format:", context);
|
||||
|
|
@ -641,9 +641,9 @@ int pw_context_find_format(struct pw_context *context,
|
|||
SPA_PARAM_EnumFormat, &oidx,
|
||||
filter, format, builder)) <= 0) {
|
||||
if (res < 0)
|
||||
asprintf(error, "error output enum formats: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error output enum formats: %s", spa_strerror(res));
|
||||
else
|
||||
asprintf(error, "no output format");
|
||||
*error = spa_aprintf("no output format");
|
||||
goto error;
|
||||
}
|
||||
} else if (in_state == PW_IMPL_PORT_STATE_CONFIGURE && out_state == PW_IMPL_PORT_STATE_CONFIGURE) {
|
||||
|
|
@ -656,13 +656,13 @@ int pw_context_find_format(struct pw_context *context,
|
|||
SPA_PARAM_EnumFormat, &iidx,
|
||||
NULL, &filter, &fb)) != 1) {
|
||||
if (res == 0 && iidx == 0) {
|
||||
asprintf(error, "no compatible formats");
|
||||
*error = spa_aprintf("no compatible formats");
|
||||
goto error;
|
||||
}
|
||||
if (res < 0)
|
||||
asprintf(error, "error input enum formats: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
|
||||
else
|
||||
asprintf(error, "no more input formats");
|
||||
*error = spa_aprintf("no more input formats");
|
||||
goto error;
|
||||
}
|
||||
pw_log_debug(NAME" %p: enum output %d with filter: %p", context, oidx, filter);
|
||||
|
|
@ -677,7 +677,7 @@ int pw_context_find_format(struct pw_context *context,
|
|||
oidx = 0;
|
||||
goto again;
|
||||
}
|
||||
asprintf(error, "error output enum formats: %s", spa_strerror(res));
|
||||
*error = spa_aprintf("error output enum formats: %s", spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ int pw_context_find_format(struct pw_context *context,
|
|||
spa_debug_format(2, NULL, *format);
|
||||
} else {
|
||||
res = -EBADF;
|
||||
asprintf(error, "error bad node state");
|
||||
*error = spa_aprintf("error bad node state");
|
||||
goto error;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -1393,7 +1393,8 @@ int pw_filter_set_error(struct pw_filter *filter,
|
|||
char *value;
|
||||
|
||||
va_start(args, error);
|
||||
vasprintf(&value, error, args);
|
||||
if (vasprintf(&value, error, args) < 0)
|
||||
return -errno;
|
||||
|
||||
if (filter->proxy)
|
||||
pw_proxy_error(filter->proxy, res, value);
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
res = -EBADF;
|
||||
/* fallthrough */
|
||||
default:
|
||||
asprintf(&error, "error get output format: %s", spa_strerror(res));
|
||||
error = spa_aprintf("error get output format: %s", spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
||||
|
|
@ -282,7 +282,7 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
res = -EBADF;
|
||||
/* fallthrough */
|
||||
default:
|
||||
asprintf(&error, "error get input format: %s", spa_strerror(res));
|
||||
error = spa_aprintf("error get input format: %s", spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
||||
|
|
@ -312,7 +312,7 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
if ((res = pw_impl_port_set_param(output,
|
||||
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
||||
format)) < 0) {
|
||||
asprintf(&error, "error set output format: %d (%s)", res, spa_strerror(res));
|
||||
error = spa_aprintf("error set output format: %d (%s)", res, spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
if (SPA_RESULT_IS_ASYNC(res)) {
|
||||
|
|
@ -328,7 +328,7 @@ static int do_negotiate(struct pw_impl_link *this)
|
|||
if ((res2 = pw_impl_port_set_param(input,
|
||||
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
||||
format)) < 0) {
|
||||
asprintf(&error, "error set input format: %d (%s)", res2, spa_strerror(res2));
|
||||
error = spa_aprintf("error set input format: %d (%s)", res2, spa_strerror(res2));
|
||||
goto error;
|
||||
}
|
||||
if (SPA_RESULT_IS_ASYNC(res2)) {
|
||||
|
|
@ -450,7 +450,7 @@ static int do_allocation(struct pw_impl_link *this)
|
|||
output->node->node, output->port_id,
|
||||
input->node->node, input->port_id,
|
||||
&output->buffers)) < 0) {
|
||||
asprintf(&error, "error alloc buffers: %s", spa_strerror(res));
|
||||
error = spa_aprintf("error alloc buffers: %s", spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ static int do_allocation(struct pw_impl_link *this)
|
|||
if ((res = pw_impl_port_use_buffers(output, &this->rt.out_mix, flags,
|
||||
output->buffers.buffers,
|
||||
output->buffers.n_buffers)) < 0) {
|
||||
asprintf(&error, "error use output buffers: %d (%s)", res,
|
||||
error = spa_aprintf("error use output buffers: %d (%s)", res,
|
||||
spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ static int do_allocation(struct pw_impl_link *this)
|
|||
if ((res = pw_impl_port_use_buffers(input, &this->rt.in_mix, 0,
|
||||
output->buffers.buffers,
|
||||
output->buffers.n_buffers)) < 0) {
|
||||
asprintf(&error, "error use input buffers: %d (%s)", res,
|
||||
error = spa_aprintf("error use input buffers: %d (%s)", res,
|
||||
spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ static char *find_module(const char *path, const char *name)
|
|||
DIR *dir;
|
||||
int res;
|
||||
|
||||
asprintf(&filename, "%s/%s.so", path, name);
|
||||
filename = spa_aprintf("%s/%s.so", path, name);
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
if (stat(filename, &s) == 0 && S_ISREG(s.st_mode)) {
|
||||
/* found a regular file with name */
|
||||
|
|
@ -83,7 +85,7 @@ static char *find_module(const char *path, const char *name)
|
|||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
asprintf(&newpath, "%s/%s", path, entry->d_name);
|
||||
newpath = spa_aprintf("%s/%s", path, entry->d_name);
|
||||
if (newpath == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -1713,7 +1713,7 @@ static void on_state_complete(void *obj, void *data, int res, uint32_t seq)
|
|||
|
||||
pw_log_debug(NAME" %p: state complete %d", node, res);
|
||||
if (SPA_RESULT_IS_ERROR(res)) {
|
||||
asprintf(&error, "error changing node state: %s", spa_strerror(res));
|
||||
error = spa_aprintf("error changing node state: %s", spa_strerror(res));
|
||||
state = PW_NODE_STATE_ERROR;
|
||||
}
|
||||
node_update_state(node, state, error);
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ open_plugin(struct registry *registry,
|
|||
spa_handle_factory_enum_func_t enum_func;
|
||||
int res;
|
||||
|
||||
if (asprintf(&filename, "%s/%s.so", path, lib) < 0) {
|
||||
res = -ENOMEM;
|
||||
if ((filename = spa_aprintf("%s/%s.so", path, lib)) == NULL) {
|
||||
res = -errno;
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -402,8 +402,10 @@ int pw_properties_setva(struct pw_properties *properties,
|
|||
const char *key, const char *format, va_list args)
|
||||
{
|
||||
char *value = NULL;
|
||||
if (format != NULL)
|
||||
vasprintf(&value, format, args);
|
||||
if (format != NULL) {
|
||||
if (vasprintf(&value, format, args) < 0)
|
||||
return -errno;
|
||||
}
|
||||
return do_replace(properties, key, value, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1511,7 +1511,8 @@ int pw_stream_set_error(struct pw_stream *stream,
|
|||
char *value;
|
||||
|
||||
va_start(args, error);
|
||||
vasprintf(&value, error, args);
|
||||
if (vasprintf(&value, error, args) < 0)
|
||||
return -errno;
|
||||
|
||||
if (stream->proxy)
|
||||
pw_proxy_error(stream->proxy, res, value);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ static void print_params(struct spa_param_info *params, uint32_t n_params, char
|
|||
|
||||
static bool do_not_implemented(struct data *data, const char *cmd, char *args, char **error)
|
||||
{
|
||||
asprintf(error, "Command \"%s\" not yet implemented", cmd);
|
||||
*error = spa_aprintf("Command \"%s\" not yet implemented", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -245,13 +245,13 @@ static bool do_load_module(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 2, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <module-name> [<module-arguments>]", cmd);
|
||||
*error = spa_aprintf("%s <module-name> [<module-arguments>]", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
module = pw_context_load_module(data->context, a[0], n == 2 ? a[1] : NULL, NULL);
|
||||
if (module == NULL) {
|
||||
asprintf(error, "Could not load module");
|
||||
*error = spa_aprintf("Could not load module");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ static bool do_connect(struct data *data, const char *cmd, char *args, char **er
|
|||
}
|
||||
core = pw_context_connect(data->context, props, sizeof(struct remote_data));
|
||||
if (core == NULL) {
|
||||
asprintf(error, "failed to connect: %m");
|
||||
*error = spa_aprintf("failed to connect: %m");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ static bool do_disconnect(struct data *data, const char *cmd, char *args, char *
|
|||
return true;
|
||||
|
||||
no_remote:
|
||||
asprintf(error, "Remote %d does not exist", idx);
|
||||
*error = spa_aprintf("Remote %d does not exist", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ static bool do_switch_remote(struct data *data, const char *cmd, char *args, cha
|
|||
return true;
|
||||
|
||||
no_remote:
|
||||
asprintf(error, "Remote %d does not exist", idx);
|
||||
*error = spa_aprintf("Remote %d does not exist", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1140,7 +1140,7 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
|
|||
destroy = (pw_destroy_t) endpoint_stream_info_free;
|
||||
info_func = info_endpoint_stream;
|
||||
} else {
|
||||
asprintf(error, "unsupported type %s", global->type);
|
||||
*error = spa_aprintf("unsupported type %s", global->type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1205,7 +1205,7 @@ static bool do_info(struct data *data, const char *cmd, char *args, char **error
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 1, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <object-id>|all", cmd);
|
||||
*error = spa_aprintf("%s <object-id>|all", cmd);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(a[0], "all") == 0) {
|
||||
|
|
@ -1215,7 +1215,7 @@ static bool do_info(struct data *data, const char *cmd, char *args, char **error
|
|||
id = atoi(a[0]);
|
||||
global = pw_map_lookup(&rd->globals, id);
|
||||
if (global == NULL) {
|
||||
asprintf(error, "%s: unknown global %d", cmd, id);
|
||||
*error = spa_aprintf("%s: unknown global %d", cmd, id);
|
||||
return false;
|
||||
}
|
||||
return do_global_info(global, error);
|
||||
|
|
@ -1235,7 +1235,7 @@ static bool do_create_device(struct data *data, const char *cmd, char *args, cha
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 2, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <factory-name> [<properties>]", cmd);
|
||||
*error = spa_aprintf("%s <factory-name> [<properties>]", cmd);
|
||||
return false;
|
||||
}
|
||||
if (n == 2)
|
||||
|
|
@ -1272,7 +1272,7 @@ static bool do_create_node(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 2, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <factory-name> [<properties>]", cmd);
|
||||
*error = spa_aprintf("%s <factory-name> [<properties>]", cmd);
|
||||
return false;
|
||||
}
|
||||
if (n == 2)
|
||||
|
|
@ -1307,13 +1307,13 @@ static bool do_destroy(struct data *data, const char *cmd, char *args, char **er
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 1, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <object-id>", cmd);
|
||||
*error = spa_aprintf("%s <object-id>", cmd);
|
||||
return false;
|
||||
}
|
||||
id = atoi(a[0]);
|
||||
global = pw_map_lookup(&rd->globals, id);
|
||||
if (global == NULL) {
|
||||
asprintf(error, "%s: unknown global %d", cmd, id);
|
||||
*error = spa_aprintf("%s: unknown global %d", cmd, id);
|
||||
return false;
|
||||
}
|
||||
pw_registry_destroy(rd->registry, id);
|
||||
|
|
@ -1333,7 +1333,7 @@ static bool do_create_link(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 5, a);
|
||||
if (n < 4) {
|
||||
asprintf(error, "%s <node-id> <port> <node-id> <port> [<properties>]", cmd);
|
||||
*error = spa_aprintf("%s <node-id> <port> <node-id> <port> [<properties>]", cmd);
|
||||
return false;
|
||||
}
|
||||
if (n == 5)
|
||||
|
|
@ -1378,7 +1378,7 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 2, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <node-id> [<remote-var>]", cmd);
|
||||
*error = spa_aprintf("%s <node-id> [<remote-var>]", cmd);
|
||||
return false;
|
||||
}
|
||||
if (n == 2) {
|
||||
|
|
@ -1390,11 +1390,11 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
global = pw_context_find_global(data->context, atoi(a[0]));
|
||||
if (global == NULL) {
|
||||
asprintf(error, "object %d does not exist", atoi(a[0]));
|
||||
*error = spa_aprintf("object %d does not exist", atoi(a[0]));
|
||||
return false;
|
||||
}
|
||||
if (!pw_global_is_type(global, PW_TYPE_INTERFACE_Node)) {
|
||||
asprintf(error, "object %d is not a node", atoi(a[0]));
|
||||
*error = spa_aprintf("object %d is not a node", atoi(a[0]));
|
||||
return false;
|
||||
}
|
||||
node = pw_global_get_object(global);
|
||||
|
|
@ -1406,7 +1406,7 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
|
|||
return true;
|
||||
|
||||
no_remote:
|
||||
asprintf(error, "Remote %d does not exist", idx);
|
||||
*error = spa_aprintf("Remote %d does not exist", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1420,7 +1420,7 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 2, a);
|
||||
if (n < 2) {
|
||||
asprintf(error, "%s <object-id> <param-id>", cmd);
|
||||
*error = spa_aprintf("%s <object-id> <param-id>", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1429,7 +1429,7 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
global = pw_map_lookup(&rd->globals, id);
|
||||
if (global == NULL) {
|
||||
asprintf(error, "%s: unknown global %d", cmd, id);
|
||||
*error = spa_aprintf("%s: unknown global %d", cmd, id);
|
||||
return false;
|
||||
}
|
||||
if (global->proxy == NULL) {
|
||||
|
|
@ -1450,7 +1450,7 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
|
|||
pw_endpoint_enum_params((struct pw_endpoint*)global->proxy, 0,
|
||||
param_id, 0, 0, NULL);
|
||||
else {
|
||||
asprintf(error, "enum-params not implemented on object %d type:%s",
|
||||
*error = spa_aprintf("enum-params not implemented on object %d type:%s",
|
||||
atoi(a[0]), global->type);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1468,18 +1468,18 @@ static bool do_permissions(struct data *data, const char *cmd, char *args, char
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 3, a);
|
||||
if (n < 3) {
|
||||
asprintf(error, "%s <client-id> <object> <permission>", cmd);
|
||||
*error = spa_aprintf("%s <client-id> <object> <permission>", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = atoi(a[0]);
|
||||
global = pw_map_lookup(&rd->globals, id);
|
||||
if (global == NULL) {
|
||||
asprintf(error, "%s: unknown global %d", cmd, id);
|
||||
*error = spa_aprintf("%s: unknown global %d", cmd, id);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) {
|
||||
asprintf(error, "object %d is not a client", atoi(a[0]));
|
||||
*error = spa_aprintf("object %d is not a client", atoi(a[0]));
|
||||
return false;
|
||||
}
|
||||
if (global->proxy == NULL) {
|
||||
|
|
@ -1505,18 +1505,18 @@ static bool do_get_permissions(struct data *data, const char *cmd, char *args, c
|
|||
|
||||
n = pw_split_ip(args, WHITESPACE, 1, a);
|
||||
if (n < 1) {
|
||||
asprintf(error, "%s <client-id>", cmd);
|
||||
*error = spa_aprintf("%s <client-id>", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = atoi(a[0]);
|
||||
global = pw_map_lookup(&rd->globals, id);
|
||||
if (global == NULL) {
|
||||
asprintf(error, "%s: unknown global %d", cmd, id);
|
||||
*error = spa_aprintf("%s: unknown global %d", cmd, id);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) {
|
||||
asprintf(error, "object %d is not a client", atoi(a[0]));
|
||||
*error = spa_aprintf("object %d is not a client", atoi(a[0]));
|
||||
return false;
|
||||
}
|
||||
if (global->proxy == NULL) {
|
||||
|
|
@ -1557,7 +1557,7 @@ static bool parse(struct data *data, char *buf, size_t size, char **error)
|
|||
return command_list[i].func(data, cmd, args, error);
|
||||
}
|
||||
}
|
||||
asprintf(error, "Command \"%s\" does not exist. Type 'help' for usage.", cmd);
|
||||
*error = spa_aprintf("Command \"%s\" does not exist. Type 'help' for usage.", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue