diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-11-21 16:09:05 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-11-21 16:09:05 +0100 |
commit | e40fbf8cc426ff8d6bcb4e28647105ed6a759642 (patch) | |
tree | 4539fac5be2a6d20724de590b1693e36fbd7f042 | |
parent | f2b7f2dc6d028b9295157ec9b00e0d221844900f (diff) |
Add printf checks for proxy_error and resource_error
Add an error variant without checks.
-rw-r--r-- | pipewire-jack/src/pipewire-jack.c | 2 | ||||
-rw-r--r-- | src/modules/module-adapter.c | 2 | ||||
-rw-r--r-- | src/modules/module-client-device.c | 6 | ||||
-rw-r--r-- | src/modules/module-client-node.c | 4 | ||||
-rw-r--r-- | src/modules/module-client-node/remote-node.c | 10 | ||||
-rw-r--r-- | src/modules/module-link-factory.c | 14 | ||||
-rw-r--r-- | src/modules/module-metadata.c | 4 | ||||
-rw-r--r-- | src/modules/module-protocol-native.c | 10 | ||||
-rw-r--r-- | src/modules/module-protocol-native/protocol-native.c | 2 | ||||
-rw-r--r-- | src/modules/module-protocol-native/v0/protocol-native.c | 2 | ||||
-rw-r--r-- | src/modules/module-session-manager/client-endpoint.c | 2 | ||||
-rw-r--r-- | src/modules/module-session-manager/client-session.c | 2 | ||||
-rw-r--r-- | src/modules/module-session-manager/endpoint-link.c | 4 | ||||
-rw-r--r-- | src/modules/spa/module-device-factory.c | 2 | ||||
-rw-r--r-- | src/modules/spa/module-node-factory.c | 2 | ||||
-rw-r--r-- | src/pipewire/core.c | 10 | ||||
-rw-r--r-- | src/pipewire/proxy.c | 13 | ||||
-rw-r--r-- | src/pipewire/proxy.h | 3 | ||||
-rw-r--r-- | src/pipewire/resource.c | 11 | ||||
-rw-r--r-- | src/pipewire/resource.h | 3 |
20 files changed, 65 insertions, 43 deletions
diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index f404ab37..41fe9ec0 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -1218,7 +1218,7 @@ static int client_node_command(void *object, const struct spa_command *command) break; default: pw_log_warn(NAME" %p: unhandled node command %d", c, SPA_COMMAND_TYPE(command)); - pw_proxy_error((struct pw_proxy*)c->node_proxy, -ENOTSUP, + pw_proxy_errorf((struct pw_proxy*)c->node_proxy, -ENOTSUP, "unhandled command %d", SPA_COMMAND_TYPE(command)); } return 0; diff --git a/src/modules/module-adapter.c b/src/modules/module-adapter.c index 5512199a..afc0e3c3 100644 --- a/src/modules/module-adapter.c +++ b/src/modules/module-adapter.c @@ -201,7 +201,7 @@ error_no_mem: res = -errno; pw_log_error("can't create node: %m"); if (resource) - pw_resource_error(resource, res, "can't create node: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create node: %s", spa_strerror(res)); goto error_cleanup; error_usage: res = -EINVAL; diff --git a/src/modules/module-client-device.c b/src/modules/module-client-device.c index 4a7fbe57..64091971 100644 --- a/src/modules/module-client-device.c +++ b/src/modules/module-client-device.c @@ -99,15 +99,15 @@ static void *create_object(void *_data, error_resource: pw_log_error("can't create resource: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create resource: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create resource: %s", spa_strerror(res)); goto error_exit; error_properties: pw_log_error("can't create properties: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create properties: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create properties: %s", spa_strerror(res)); goto error_exit_free; error_device: pw_log_error("can't create device: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create device: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create device: %s", spa_strerror(res)); goto error_exit_free; error_exit_free: diff --git a/src/modules/module-client-node.c b/src/modules/module-client-node.c index 6e42674d..5b470ab0 100644 --- a/src/modules/module-client-node.c +++ b/src/modules/module-client-node.c @@ -93,11 +93,11 @@ static void *create_object(void *_data, error_resource: pw_log_error("can't create resource: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create resource: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create resource: %s", spa_strerror(res)); goto error_exit; error_node: pw_log_error("can't create node: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create node: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create node: %s", spa_strerror(res)); goto error_exit_free; error_exit_free: diff --git a/src/modules/module-client-node/remote-node.c b/src/modules/module-client-node/remote-node.c index b6844937..23b3c3c4 100644 --- a/src/modules/module-client-node/remote-node.c +++ b/src/modules/module-client-node/remote-node.c @@ -485,7 +485,7 @@ static int client_node_command(void *object, const struct spa_command *command) default: pw_log_warn("unhandled node command %d", SPA_NODE_COMMAND_ID(command)); res = -ENOTSUP; - pw_proxy_error(proxy, res, "command %d not supported", SPA_NODE_COMMAND_ID(command)); + pw_proxy_errorf(proxy, res, "command %d not supported", SPA_NODE_COMMAND_ID(command)); } return res; } @@ -567,7 +567,7 @@ client_node_port_set_param(void *object, error_exit: pw_log_error("port %p: set_param %d %p: %s", port, id, param, spa_strerror(res)); - pw_proxy_error(proxy, res, "port_set_param: %s", spa_strerror(res)); + pw_proxy_errorf(proxy, res, "port_set_param: %s", spa_strerror(res)); return res; } @@ -706,7 +706,7 @@ error_exit_cleanup: clear_buffers(data, mix); error_exit: pw_log_error("port %p: use_buffers: %d %s", mix, res, spa_strerror(res)); - pw_proxy_error(proxy, res, "port_use_buffers error: %s", spa_strerror(res)); + pw_proxy_errorf(proxy, res, "port_use_buffers error: %s", spa_strerror(res)); return res; } @@ -773,7 +773,7 @@ client_node_port_set_io(void *object, error_exit: pw_log_error("port %p: set_io: %s", mix, spa_strerror(res)); - pw_proxy_error(proxy, res, "port_set_io failed: %s", spa_strerror(res)); + pw_proxy_errorf(proxy, res, "port_set_io failed: %s", spa_strerror(res)); return res; } @@ -867,7 +867,7 @@ client_node_set_activation(void *object, error_exit: pw_log_error("node %p: set activation %d: %s", node, node_id, spa_strerror(res)); - pw_proxy_error(proxy, res, "set_activation: %s", spa_strerror(res)); + pw_proxy_errorf(proxy, res, "set_activation: %s", spa_strerror(res)); return res; } diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 4cdba033..502e73c2 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -266,33 +266,33 @@ error_properties: error_output: res = -EINVAL; pw_log_error(NAME" unknown output node %u", output_node_id); - pw_resource_error(resource, res, "unknown output node %u", output_node_id); + pw_resource_errorf(resource, res, "unknown output node %u", output_node_id); goto error_exit; error_input: res = -EINVAL; pw_log_error(NAME" unknown input node %u", input_node_id); - pw_resource_error(resource, res, "unknown input node %u", input_node_id); + pw_resource_errorf(resource, res, "unknown input node %u", input_node_id); goto error_exit; error_output_port: res = -EINVAL; pw_log_error(NAME" unknown output port %u", output_port_id); - pw_resource_error(resource, res, "unknown output port %u", output_port_id); + pw_resource_errorf(resource, res, "unknown output port %u", output_port_id); goto error_exit; error_input_port: res = -EINVAL; pw_log_error(NAME" unknown input port %u", input_port_id); - pw_resource_error(resource, res, "unknown input port %u", input_port_id); + pw_resource_errorf(resource, res, "unknown input port %u", input_port_id); goto error_exit; error_create_link: pw_log_error("can't create link: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create link: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create link: %s", spa_strerror(res)); goto error_exit; error_link_register: pw_log_error("can't register link: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't register link: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't register link: %s", spa_strerror(res)); goto error_exit; error_bind: - pw_resource_error(resource, res, "can't bind link: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't bind link: %s", spa_strerror(res)); goto error_exit; error_exit: if (properties) diff --git a/src/modules/module-metadata.c b/src/modules/module-metadata.c index d2b17fd5..1aaf1585 100644 --- a/src/modules/module-metadata.c +++ b/src/modules/module-metadata.c @@ -89,11 +89,11 @@ static void *create_object(void *_data, error_resource: pw_log_error("can't create resource: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create resource: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create resource: %s", spa_strerror(res)); goto error_exit; error_node: pw_log_error("can't create metadata: %s", spa_strerror(res)); - pw_resource_error(resource, res, "can't create metadata: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create metadata: %s", spa_strerror(res)); goto error_exit_free; error_exit_free: diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 2d9f0909..6c54e26d 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -164,7 +164,7 @@ process_messages(struct client_data *data) if (resource == NULL) { pw_log_error(NAME" %p: unknown resource %u op:%u", client->protocol, msg->id, msg->opcode); - pw_resource_error(client->core_resource, + pw_resource_errorf(client->core_resource, -EINVAL, "unknown resource %u op:%u", msg->id, msg->opcode); continue; } @@ -185,8 +185,8 @@ process_messages(struct client_data *data) if ((required & permissions) != required) { pw_log_error(NAME" %p: method %u on %u requires %08x, have %08x", client->protocol, msg->opcode, msg->id, required, permissions); - pw_resource_error(resource, - -EACCES, "no permission to call method %u ", msg->opcode, msg->id); + pw_resource_errorf(resource, + -EACCES, "no permission to call method %u on %u", msg->opcode, msg->id); continue; } @@ -200,14 +200,14 @@ done: invalid_method: pw_log_error(NAME" %p: invalid method id:%u op:%u", client->protocol, msg->id, msg->opcode); - pw_resource_error(resource, -EINVAL, "invalid method id:%u op:%u", + pw_resource_errorf(resource, -EINVAL, "invalid method id:%u op:%u", msg->id, msg->opcode); pw_client_destroy(client); goto done; invalid_message: pw_log_error(NAME" %p: invalid message received id:%u op:%u (%s)", client->protocol, msg->id, msg->opcode, spa_strerror(res)); - pw_resource_error(resource, res, "invalid message received id:%u op:%u (%s)", + pw_resource_errorf(resource, res, "invalid message received id:%u op:%u (%s)", msg->id, msg->opcode, spa_strerror(res)); spa_debug_pod(0, NULL, (struct spa_pod *)msg->data); pw_client_destroy(client); diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 37fadb67..8cbffe3d 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -620,7 +620,7 @@ static int core_method_demarshal_destroy(void *object, const struct pw_protocol_ no_resource: pw_log_error("client %p: unknown resouce %u op:%u", client, id, msg->opcode); - pw_resource_error(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode); + pw_resource_errorf(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode); return 0; } diff --git a/src/modules/module-protocol-native/v0/protocol-native.c b/src/modules/module-protocol-native/v0/protocol-native.c index c0d72358..484553c6 100644 --- a/src/modules/module-protocol-native/v0/protocol-native.c +++ b/src/modules/module-protocol-native/v0/protocol-native.c @@ -648,7 +648,7 @@ static int core_demarshal_destroy(void *object, const struct pw_protocol_native_ no_resource: pw_log_error("client %p: unknown resouce %u op:%u", client, id, msg->opcode); - pw_resource_error(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode); + pw_resource_errorf(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode); return 0; } diff --git a/src/modules/module-session-manager/client-endpoint.c b/src/modules/module-session-manager/client-endpoint.c index efd522a5..5ff32cb5 100644 --- a/src/modules/module-session-manager/client-endpoint.c +++ b/src/modules/module-session-manager/client-endpoint.c @@ -124,7 +124,7 @@ static int client_endpoint_stream_update(void *object, pw_properties_free(props); free(stream); pw_log_error(NAME" %p: cannot update stream: no memory", this); - pw_resource_error(this->resource, -ENOMEM, + pw_resource_errorf(this->resource, -ENOMEM, NAME" %p: cannot update stream: no memory", this); return -ENOMEM; } diff --git a/src/modules/module-session-manager/client-session.c b/src/modules/module-session-manager/client-session.c index eb959861..c949abc4 100644 --- a/src/modules/module-session-manager/client-session.c +++ b/src/modules/module-session-manager/client-session.c @@ -118,7 +118,7 @@ static int client_session_link_update(void *object, free(link); pw_log_error(NAME" %p: cannot update link: no memory", this); pw_resource_error(this->resource, -ENOMEM, - NAME" %p: cannot update link: no memory", this); + "cannot update link: no memory"); return -ENOMEM; } diff --git a/src/modules/module-session-manager/endpoint-link.c b/src/modules/module-session-manager/endpoint-link.c index bce06598..215ceb71 100644 --- a/src/modules/module-session-manager/endpoint-link.c +++ b/src/modules/module-session-manager/endpoint-link.c @@ -253,7 +253,7 @@ int endpoint_link_update(struct endpoint_link *this, no_mem: pw_log_error(NAME" %p: can't update: no memory", this); pw_resource_error(this->client_sess->resource, -ENOMEM, - NAME" %p: can't update: no memory", this); + "can't update: no memory"); return -ENOMEM; } @@ -300,7 +300,7 @@ static int endpoint_link_bind(void *_data, struct pw_client *client, no_mem: pw_log_error(NAME" %p: can't create resource: no memory", this); pw_resource_error(this->client_sess->resource, -ENOMEM, - NAME" %p: can't create resource: no memory", this); + "can't create resource: no memory"); return -ENOMEM; } diff --git a/src/modules/spa/module-device-factory.c b/src/modules/spa/module-device-factory.c index 2784283c..4cce726b 100644 --- a/src/modules/spa/module-device-factory.c +++ b/src/modules/spa/module-device-factory.c @@ -140,7 +140,7 @@ error_properties: error_device: pw_log_error("can't create device: %s", spa_strerror(res)); if (resource) - pw_resource_error(resource, res, "can't create device: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create device: %s", spa_strerror(res)); goto error_exit; error_exit: errno = -res; diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index d24d5813..a07976b7 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -167,7 +167,7 @@ error_create_node: res = -errno; pw_log_error("can't create node: %m"); if (resource) - pw_resource_error(resource, res, "can't create node: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create node: %s", spa_strerror(res)); goto error_exit; error_bind: pw_resource_error(resource, res, "can't bind node"); diff --git a/src/pipewire/core.c b/src/pipewire/core.c index b803af0c..e2d97ea2 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -98,11 +98,11 @@ static void * registry_bind(void *object, uint32_t id, error_no_id: pw_log_debug("registry %p: no global with id %u to bind to %u", resource, id, new_id); - pw_resource_error(resource, -ENOENT, "no such global %u", id); + pw_resource_errorf(resource, -ENOENT, "no such global %u", id); goto error_exit_clean; error_wrong_interface: pw_log_debug("registry %p: global with id %u has no interface %u", resource, id, type); - pw_resource_error(resource, -ENOENT, "no such interface %u", type); + pw_resource_errorf(resource, -ENOENT, "no such interface %u", type); goto error_exit_clean; error_exit_clean: /* unmark the new_id the map, the client does not yet know about the failed @@ -345,18 +345,18 @@ core_create_object(void *object, error_no_factory: res = -ENOENT; pw_log_error(NAME" %p: can't find factory '%s'", this, factory_name); - pw_resource_error(resource, res, "unknown factory name %s", factory_name); + pw_resource_errorf(resource, res, "unknown factory name %s", factory_name); goto error_exit; error_version: error_type: res = -EPROTO; pw_log_error(NAME" %p: invalid resource type/version", this); - pw_resource_error(resource, res, "wrong resource type/version"); + pw_resource_errorf(resource, res, "wrong resource type/version"); goto error_exit; error_properties: res = -errno; pw_log_error(NAME" %p: can't create properties: %m", this); - pw_resource_error(resource, res, "can't create properties: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, "can't create properties: %s", spa_strerror(res)); goto error_exit; error_create_failed: res = -errno; diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index 2dbb1d48..69ce3f7d 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -220,7 +220,7 @@ int pw_proxy_sync(struct pw_proxy *proxy, int seq) } SPA_EXPORT -int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error, ...) +int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) { va_list ap; int r = -EIO; @@ -235,6 +235,17 @@ int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error, ...) } SPA_EXPORT +int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error) +{ + int r = -EIO; + struct pw_remote *remote = proxy->remote; + if (remote->core_proxy != NULL) + r = pw_core_proxy_error(remote->core_proxy, proxy->id, + remote->recv_seq, res, error); + return r; +} + +SPA_EXPORT struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy) { return &proxy->object_listener_list; diff --git a/src/pipewire/proxy.h b/src/pipewire/proxy.h index 8d8b249b..48a37704 100644 --- a/src/pipewire/proxy.h +++ b/src/pipewire/proxy.h @@ -156,7 +156,8 @@ struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy); int pw_proxy_sync(struct pw_proxy *proxy, int seq); /** Generate an error for a proxy */ -int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error, ...); +int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error); +int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4); /** Get the listener of proxy */ struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy); diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c index 13406f1c..47dec499 100644 --- a/src/pipewire/resource.c +++ b/src/pipewire/resource.c @@ -206,7 +206,7 @@ int pw_resource_ping(struct pw_resource *resource, int seq) } SPA_EXPORT -void pw_resource_error(struct pw_resource *resource, int res, const char *error, ...) +void pw_resource_errorf(struct pw_resource *resource, int res, const char *error, ...) { va_list ap; struct pw_client *client = resource->client; @@ -219,6 +219,15 @@ void pw_resource_error(struct pw_resource *resource, int res, const char *error, } SPA_EXPORT +void pw_resource_error(struct pw_resource *resource, int res, const char *error) +{ + struct pw_client *client = resource->client; + if (client->core_resource != NULL) + pw_core_resource_error(client->core_resource, + resource->id, client->recv_seq, res, error); +} + +SPA_EXPORT void pw_resource_destroy(struct pw_resource *resource) { struct pw_client *client = resource->client; diff --git a/src/pipewire/resource.h b/src/pipewire/resource.h index 2de3d433..4a32c74f 100644 --- a/src/pipewire/resource.h +++ b/src/pipewire/resource.h @@ -122,7 +122,8 @@ void pw_resource_add_object_listener(struct pw_resource *resource, int pw_resource_ping(struct pw_resource *resource, int seq); /** Generate an error for a resource */ -void pw_resource_error(struct pw_resource *resource, int res, const char *error, ...); +void pw_resource_error(struct pw_resource *resource, int res, const char *error); +void pw_resource_errorf(struct pw_resource *resource, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4); /** Get the list of object listeners from a resource */ struct spa_hook_list *pw_resource_get_object_listeners(struct pw_resource *resource); |