From e0471c6757543420c84b4980b085261c60ddc4f5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 1 Jun 2021 11:21:17 +1000 Subject: [PATCH] pipewire: allow NULL pointers in pw_properties_free() Just like the real free() we should just ignore a NULL pointer, makes the caller code easier for those instances where properties are optional. Patch generated with concinelle with a few manual fixes. --- pipewire-alsa/alsa-plugins/pcm_pipewire.c | 3 +- src/examples/media-session/alsa-monitor.c | 6 ++-- src/examples/media-session/bluez-monitor.c | 6 ++-- src/examples/media-session/media-session.c | 21 +++++-------- src/examples/media-session/restore-stream.c | 3 +- .../session-manager/introspect-funcs.h | 12 +++----- src/modules/module-access.c | 3 +- src/modules/module-adapter.c | 3 +- src/modules/module-adapter/adapter.c | 3 +- src/modules/module-client-node/client-node.c | 6 ++-- .../module-client-node/v0/client-node.c | 3 +- src/modules/module-echo-cancel.c | 9 ++---- src/modules/module-filter-chain.c | 9 ++---- src/modules/module-link-factory.c | 3 +- src/modules/module-loopback.c | 9 ++---- src/modules/module-portal.c | 3 +- src/modules/module-profiler.c | 3 +- src/modules/module-protocol-pulse/format.c | 3 +- src/modules/module-protocol-pulse/manager.c | 3 +- src/modules/module-protocol-pulse/module.c | 3 +- .../modules/module-combine-sink.c | 3 +- .../modules/module-ladspa-sink.c | 9 ++---- .../modules/module-ladspa-source.c | 9 ++---- .../modules/module-loopback.c | 9 ++---- .../modules/module-native-protocol-tcp.c | 3 +- .../modules/module-null-sink.c | 3 +- .../modules/module-pipe-sink.c | 9 ++---- .../modules/module-remap-sink.c | 9 ++---- .../modules/module-remap-source.c | 9 ++---- .../modules/module-simple-protocol-tcp.c | 6 ++-- .../modules/module-tunnel-sink.c | 6 ++-- .../modules/module-tunnel-source.c | 6 ++-- .../modules/module-zeroconf-discover.c | 3 +- .../module-protocol-pulse/pulse-server.c | 30 +++++++------------ src/modules/module-protocol-pulse/sample.c | 3 +- src/modules/module-protocol-simple.c | 6 ++-- src/modules/module-pulse-tunnel.c | 6 ++-- src/modules/module-rtkit.c | 3 +- .../client-endpoint/client-endpoint.c | 6 ++-- .../client-endpoint/endpoint-stream.c | 3 +- .../client-endpoint/endpoint.c | 3 +- .../client-session/client-session.c | 6 ++-- .../client-session/endpoint-link.c | 3 +- .../client-session/session.c | 3 +- src/modules/module-zeroconf-discover.c | 3 +- src/modules/spa/module-device-factory.c | 3 +- src/modules/spa/module-node-factory.c | 3 +- src/modules/spa/spa-device.c | 3 +- src/modules/spa/spa-node.c | 3 +- src/pipewire/context.c | 6 ++-- src/pipewire/core.c | 3 +- src/pipewire/filter.c | 9 ++---- src/pipewire/global.c | 3 +- src/pipewire/impl-client.c | 6 ++-- src/pipewire/impl-core.c | 6 ++-- src/pipewire/impl-device.c | 6 ++-- src/pipewire/impl-factory.c | 6 ++-- src/pipewire/impl-link.c | 6 ++-- src/pipewire/impl-module.c | 3 +- src/pipewire/impl-node.c | 6 ++-- src/pipewire/mem.c | 3 +- src/pipewire/properties.c | 7 ++++- src/pipewire/stream.c | 12 +++----- src/tools/pw-cat.c | 3 +- src/tools/pw-cli.c | 30 +++++++------------ src/tools/pw-dot.c | 3 +- src/tools/pw-dump.c | 6 ++-- src/tools/pw-loopback.c | 6 ++-- 68 files changed, 142 insertions(+), 273 deletions(-) diff --git a/pipewire-alsa/alsa-plugins/pcm_pipewire.c b/pipewire-alsa/alsa-plugins/pcm_pipewire.c index 907e26f2a..933de97c0 100644 --- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c +++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c @@ -1078,8 +1078,7 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp, const char *name, return 0; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); snd_pcm_pipewire_free(pw); return err; } diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index a9f2cbcaa..50af8cdb0 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -1157,10 +1157,8 @@ int sm_alsa_monitor_start(struct sm_media_session *session) out_free: if (impl->handle) pw_unload_spa_handle(impl->handle); - if (impl->conf) - pw_properties_free(impl->conf); - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->conf); + pw_properties_free(impl->props); free(impl); return res; } diff --git a/src/examples/media-session/bluez-monitor.c b/src/examples/media-session/bluez-monitor.c index 49301d7b0..57eed8ce2 100644 --- a/src/examples/media-session/bluez-monitor.c +++ b/src/examples/media-session/bluez-monitor.c @@ -750,10 +750,8 @@ int sm_bluez5_monitor_start(struct sm_media_session *session) return 0; out_free: - if (impl->conf) - pw_properties_free(impl->conf); - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->conf); + pw_properties_free(impl->props); free(impl); out: return res; diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index d51d6385b..03aa41dcd 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -341,10 +341,8 @@ unref: if (!obj->discarded) return 0; - if (obj->props) { - pw_properties_free(obj->props); - obj->props = NULL; - } + pw_properties_free(obj->props); + obj->props = NULL; spa_list_consume(d, &obj->data, link) { spa_list_remove(&d->link); @@ -818,8 +816,7 @@ static void session_event_info(void *object, const struct pw_session_info *info) if (info) { i->change_mask = info->change_mask; if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS) { - if (i->props) - pw_properties_free ((struct pw_properties *)i->props); + pw_properties_free ((struct pw_properties *)i->props); i->props = (struct spa_dict *) pw_properties_new_dict (info->props); } } @@ -857,8 +854,7 @@ static void session_destroy(void *object) spa_list_remove(&endpoint->link); } if (i) { - if (i->props) - pw_properties_free ((struct pw_properties *)i->props); + pw_properties_free ((struct pw_properties *)i->props); free(i); } @@ -898,8 +894,7 @@ static void endpoint_event_info(void *object, const struct pw_endpoint_info *inf i->session_id = info->session_id; } if (info->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { - if (i->props) - pw_properties_free ((struct pw_properties *)i->props); + pw_properties_free ((struct pw_properties *)i->props); i->props = (struct spa_dict *) pw_properties_new_dict (info->props); if ((str = spa_dict_lookup(i->props, PW_KEY_PRIORITY_SESSION)) != NULL) endpoint->priority = pw_properties_parse_int(str); @@ -954,8 +949,7 @@ static void endpoint_destroy(void *object) spa_list_remove(&endpoint->link); } if (i) { - if (i->props) - pw_properties_free ((struct pw_properties *)i->props); + pw_properties_free ((struct pw_properties *)i->props); free(i->name); free(i->media_class); free(i); @@ -1321,8 +1315,7 @@ static void registry_event_free(struct registry_event *re) { if (re->proxy) pw_proxy_destroy(re->proxy); - if (re->props_store) - pw_properties_free(re->props_store); + pw_properties_free(re->props_store); if (re->allocated) { spa_list_remove(&re->link); free(re); diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index 897214e9d..b91590103 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -557,8 +557,7 @@ int sm_restore_stream_start(struct sm_media_session *session) exit_errno: res = -errno; - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->props); free(impl); return res; } diff --git a/src/extensions/session-manager/introspect-funcs.h b/src/extensions/session-manager/introspect-funcs.h index 1baaad276..89e0f98cf 100644 --- a/src/extensions/session-manager/introspect-funcs.h +++ b/src/extensions/session-manager/introspect-funcs.h @@ -89,8 +89,7 @@ pw_session_info_free (struct pw_session_info *info) struct pw_session_info info; } *ext = SPA_CONTAINER_OF(info, struct extended_info, info); - if (ext->props_storage) - pw_properties_free(ext->props_storage); + pw_properties_free(ext->props_storage); free((void *) info->params); free(ext); } @@ -160,8 +159,7 @@ pw_endpoint_info_free (struct pw_endpoint_info *info) struct pw_endpoint_info info; } *ext = SPA_CONTAINER_OF(info, struct extended_info, info); - if (ext->props_storage) - pw_properties_free(ext->props_storage); + pw_properties_free(ext->props_storage); free(info->name); free(info->media_class); free((void *) info->params); @@ -230,8 +228,7 @@ pw_endpoint_stream_info_free (struct pw_endpoint_stream_info *info) struct pw_endpoint_stream_info info; } *ext = SPA_CONTAINER_OF(info, struct extended_info, info); - if (ext->props_storage) - pw_properties_free(ext->props_storage); + pw_properties_free(ext->props_storage); free(info->name); free(info->link_params); free((void *) info->params); @@ -304,8 +301,7 @@ pw_endpoint_link_info_free (struct pw_endpoint_link_info *info) struct pw_endpoint_link_info info; } *ext = SPA_CONTAINER_OF(info, struct extended_info, info); - if (ext->props_storage) - pw_properties_free(ext->props_storage); + pw_properties_free(ext->props_storage); free(info->error); free((void *) info->params); free(ext); diff --git a/src/modules/module-access.c b/src/modules/module-access.c index cc7b06aa0..0bd5a39cb 100644 --- a/src/modules/module-access.c +++ b/src/modules/module-access.c @@ -274,8 +274,7 @@ static void module_destroy(void *data) spa_hook_remove(&impl->context_listener); spa_hook_remove(&impl->module_listener); - if (impl->properties) - pw_properties_free(impl->properties); + pw_properties_free(impl->properties); free(impl); } diff --git a/src/modules/module-adapter.c b/src/modules/module-adapter.c index 2f4b73d88..9cd10713d 100644 --- a/src/modules/module-adapter.c +++ b/src/modules/module-adapter.c @@ -243,8 +243,7 @@ error_usage: pw_resource_errorf_id(resource, new_id, res, "usage: "ADAPTER_USAGE); goto error_cleanup; error_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 4c433091b..d6e87d20c 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -300,8 +300,7 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context, return node; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index a9de25407..8348ac7da 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -497,8 +497,7 @@ do_update_port(struct node *this, } if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) { - if (port->properties) - pw_properties_free(port->properties); + pw_properties_free(port->properties); port->properties = NULL; port->info.props = NULL; port->info.n_params = 0; @@ -1764,8 +1763,7 @@ error_exit_free: error_exit_cleanup: if (resource) pw_resource_destroy(resource); - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/modules/module-client-node/v0/client-node.c b/src/modules/module-client-node/v0/client-node.c index c210c8554..800925737 100644 --- a/src/modules/module-client-node/v0/client-node.c +++ b/src/modules/module-client-node/v0/client-node.c @@ -482,8 +482,7 @@ do_update_port(struct node *this, } if (change_mask & PW_CLIENT_NODE0_PORT_UPDATE_INFO) { - if (port->properties) - pw_properties_free(port->properties); + pw_properties_free(port->properties); port->properties = NULL; port->info.props = NULL; port->info.n_params = 0; diff --git a/src/modules/module-echo-cancel.c b/src/modules/module-echo-cancel.c index 163bfc81d..6463e5017 100644 --- a/src/modules/module-echo-cancel.c +++ b/src/modules/module-echo-cancel.c @@ -462,10 +462,8 @@ static void impl_destroy(struct impl *impl) pw_core_disconnect(impl->core); if (impl->aec) echo_cancel_destroy(impl->aec_info, impl->aec); - if (impl->source_props) - pw_properties_free(impl->source_props); - if (impl->sink_props) - pw_properties_free(impl->sink_props); + pw_properties_free(impl->source_props); + pw_properties_free(impl->sink_props); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); free(impl); } @@ -647,8 +645,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) return 0; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); impl_destroy(impl); return res; } diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index 174fbc634..91d79e1ce 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -1633,10 +1633,8 @@ static void impl_destroy(struct impl *impl) pw_stream_destroy(impl->playback); if (impl->core && impl->do_disconnect) pw_core_disconnect(impl->core); - if (impl->capture_props) - pw_properties_free(impl->capture_props); - if (impl->playback_props) - pw_properties_free(impl->playback_props); + pw_properties_free(impl->capture_props); + pw_properties_free(impl->playback_props); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); graph_free(&impl->graph); free(impl); @@ -1818,8 +1816,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) return 0; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); impl_destroy(impl); return res; } diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 44382c68c..600d77373 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -447,8 +447,7 @@ error_link_register: pw_resource_errorf_id(resource, new_id, res, NAME": can't register link: %s", spa_strerror(res)); goto error_exit; error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c index 08074721c..8d42678a7 100644 --- a/src/modules/module-loopback.c +++ b/src/modules/module-loopback.c @@ -307,10 +307,8 @@ static void impl_destroy(struct impl *impl) pw_stream_destroy(impl->playback); if (impl->core && impl->do_disconnect) pw_core_disconnect(impl->core); - if (impl->capture_props) - pw_properties_free(impl->capture_props); - if (impl->playback_props) - pw_properties_free(impl->playback_props); + pw_properties_free(impl->capture_props); + pw_properties_free(impl->playback_props); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); free(impl); } @@ -473,8 +471,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) return 0; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); impl_destroy(impl); return res; } diff --git a/src/modules/module-portal.c b/src/modules/module-portal.c index fdbe705c5..f58d2ce4a 100644 --- a/src/modules/module-portal.c +++ b/src/modules/module-portal.c @@ -110,8 +110,7 @@ static void module_destroy(void *data) spa_dbus_connection_destroy(impl->conn); - if (impl->properties) - pw_properties_free(impl->properties); + pw_properties_free(impl->properties); free(impl); } diff --git a/src/modules/module-profiler.c b/src/modules/module-profiler.c index bb10db7ac..06d52b9a0 100644 --- a/src/modules/module-profiler.c +++ b/src/modules/module-profiler.c @@ -332,8 +332,7 @@ static void module_destroy(void *data) spa_hook_remove(&impl->module_listener); - if (impl->properties) - pw_properties_free(impl->properties); + pw_properties_free(impl->properties); free(impl); } diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index 6145e7bd8..0304613a3 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -400,8 +400,7 @@ struct format_info { static void format_info_clear(struct format_info *info) { - if (info->props) - pw_properties_free(info->props); + pw_properties_free(info->props); spa_zero(*info); } diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index bc4ad3899..a80940b1a 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -194,8 +194,7 @@ static void object_destroy(struct object *o) m->this.n_objects--; if (o->this.proxy) pw_proxy_destroy(o->this.proxy); - if (o->this.props) - pw_properties_free(o->this.props); + pw_properties_free(o->this.props); if (o->this.message_object_path) free(o->this.message_object_path); clear_params(&o->this.param_list, SPA_ID_INVALID); diff --git a/src/modules/module-protocol-pulse/module.c b/src/modules/module-protocol-pulse/module.c index 952a12774..7fd8e09af 100644 --- a/src/modules/module-protocol-pulse/module.c +++ b/src/modules/module-protocol-pulse/module.c @@ -83,8 +83,7 @@ static void module_free(struct module *module) pw_work_queue_cancel(impl->work_queue, module, SPA_ID_INVALID); free((char*)module->name); free((char*)module->args); - if (module->props) - pw_properties_free(module->props); + pw_properties_free(module->props); free(module); } diff --git a/src/modules/module-protocol-pulse/modules/module-combine-sink.c b/src/modules/module-protocol-pulse/modules/module-combine-sink.c index e3f8921a0..8d3f61ffd 100644 --- a/src/modules/module-protocol-pulse/modules/module-combine-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-combine-sink.c @@ -461,8 +461,7 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen return module; out: - if (props) - pw_properties_free(props); + pw_properties_free(props); if (sink_names) pw_free_strv(sink_names); errno = -res; diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c index 25454cf37..3270f8bd9 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c @@ -233,12 +233,9 @@ struct module *create_module_ladspa_sink(struct impl *impl, const char *argument return module; out: - if (props) - pw_properties_free(props); - if (playback_props) - pw_properties_free(playback_props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(playback_props); + pw_properties_free(capture_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c index 2112ea2cc..d84ec1fd3 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c @@ -233,12 +233,9 @@ struct module *create_module_ladspa_source(struct impl *impl, const char *argume return module; out: - if (props) - pw_properties_free(props); - if (playback_props) - pw_properties_free(playback_props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(playback_props); + pw_properties_free(capture_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-loopback.c b/src/modules/module-protocol-pulse/modules/module-loopback.c index c97c67c06..fe41acc5c 100644 --- a/src/modules/module-protocol-pulse/modules/module-loopback.c +++ b/src/modules/module-protocol-pulse/modules/module-loopback.c @@ -236,12 +236,9 @@ struct module *create_module_loopback(struct impl *impl, const char *argument) return module; out: - if (props) - pw_properties_free(props); - if (playback_props) - pw_properties_free(playback_props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(playback_props); + pw_properties_free(capture_props); errno = -res; return NULL; diff --git a/src/modules/module-protocol-pulse/modules/module-native-protocol-tcp.c b/src/modules/module-protocol-pulse/modules/module-native-protocol-tcp.c index 045650515..e297d1722 100644 --- a/src/modules/module-protocol-pulse/modules/module-native-protocol-tcp.c +++ b/src/modules/module-protocol-pulse/modules/module-native-protocol-tcp.c @@ -127,8 +127,7 @@ struct module *create_module_native_protocol_tcp(struct impl *impl, const char * return module; out: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-null-sink.c b/src/modules/module-protocol-pulse/modules/module-null-sink.c index b979fc4f5..52b3fafb8 100644 --- a/src/modules/module-protocol-pulse/modules/module-null-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-null-sink.c @@ -203,8 +203,7 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument) return module; out: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c index 48f73fa0c..3f1d5c2cb 100644 --- a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c @@ -189,8 +189,7 @@ static int module_pipesink_unload(struct client *client, struct module *module) pw_log_info("unload module %p id:%u name:%s", module, module->idx, module->name); - if (d->capture_props != NULL) - pw_properties_free(d->capture_props); + pw_properties_free(d->capture_props); if (d->capture != NULL) pw_stream_destroy(d->capture); if (d->core != NULL) @@ -321,10 +320,8 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument) return module; out: - if (props) - pw_properties_free(props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(capture_props); if (filename) { if (do_unlink_fifo) unlink(filename); diff --git a/src/modules/module-protocol-pulse/modules/module-remap-sink.c b/src/modules/module-protocol-pulse/modules/module-remap-sink.c index d22ca2112..519f15aeb 100644 --- a/src/modules/module-protocol-pulse/modules/module-remap-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-remap-sink.c @@ -229,12 +229,9 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument) return module; out: - if (props) - pw_properties_free(props); - if (playback_props) - pw_properties_free(playback_props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(playback_props); + pw_properties_free(capture_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-remap-source.c b/src/modules/module-protocol-pulse/modules/module-remap-source.c index 4468e5276..dc4f7e21a 100644 --- a/src/modules/module-protocol-pulse/modules/module-remap-source.c +++ b/src/modules/module-protocol-pulse/modules/module-remap-source.c @@ -229,12 +229,9 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen return module; out: - if (props) - pw_properties_free(props); - if (playback_props) - pw_properties_free(playback_props); - if (capture_props) - pw_properties_free(capture_props); + pw_properties_free(props); + pw_properties_free(playback_props); + pw_properties_free(capture_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c b/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c index 4ad5ea9bb..b0e9f3c33 100644 --- a/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c +++ b/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c @@ -187,10 +187,8 @@ struct module *create_module_simple_protocol_tcp(struct impl *impl, const char * return module; out: - if (module_props) - pw_properties_free(module_props); - if (props) - pw_properties_free(props); + pw_properties_free(module_props); + pw_properties_free(props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c index 910c0a82a..9b8b6877d 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c @@ -214,10 +214,8 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument return module; out: - if (props) - pw_properties_free(props); - if (stream_props) - pw_properties_free(stream_props); + pw_properties_free(props); + pw_properties_free(stream_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c index 8eb5478ce..d572f2272 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c @@ -214,10 +214,8 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume return module; out: - if (props) - pw_properties_free(props); - if (stream_props) - pw_properties_free(stream_props); + pw_properties_free(props); + pw_properties_free(stream_props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/modules/module-zeroconf-discover.c b/src/modules/module-protocol-pulse/modules/module-zeroconf-discover.c index 6a85991f2..bd6db8afd 100644 --- a/src/modules/module-protocol-pulse/modules/module-zeroconf-discover.c +++ b/src/modules/module-protocol-pulse/modules/module-zeroconf-discover.c @@ -131,8 +131,7 @@ struct module *create_module_zeroconf_discover(struct impl *impl, const char *ar return module; out: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index fc226ac09..e29838919 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -134,8 +134,7 @@ static void sample_free(struct sample *sample) if (sample->index != SPA_ID_INVALID) pw_map_remove(&impl->samples, sample->index); - if (sample->props) - pw_properties_free(sample->props); + pw_properties_free(sample->props); free(sample->buffer); free(sample); } @@ -968,8 +967,7 @@ static void stream_free(struct stream *stream) if (stream->buffer) free(stream->buffer); - if (stream->props) - pw_properties_free(stream->props); + pw_properties_free(stream->props); free(stream); } @@ -1982,8 +1980,7 @@ error_invalid: res = -EINVAL; goto error; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); if (stream) stream_free(stream); return res; @@ -2234,8 +2231,7 @@ error_invalid: res = -EINVAL; goto error; error: - if (props) - pw_properties_free(props); + pw_properties_free(props); if (stream) stream_free(stream); return res; @@ -2453,8 +2449,7 @@ error_toolarge: res = -EOVERFLOW; goto error; error: - if (props != NULL) - pw_properties_free(props); + pw_properties_free(props); if (stream) stream_free(stream); return res; @@ -2500,8 +2495,7 @@ static int do_finish_upload_stream(struct client *client, uint32_t command, uint event = SUBSCRIPTION_EVENT_NEW; } else { - if (sample->props) - pw_properties_free(sample->props); + pw_properties_free(sample->props); free(sample->buffer); event = SUBSCRIPTION_EVENT_CHANGE; } @@ -2779,8 +2773,7 @@ error_noent: res = -ENOENT; goto error; error: - if (props != NULL) - pw_properties_free(props); + pw_properties_free(props); return res; } @@ -3447,8 +3440,7 @@ static int do_update_proplist(struct client *client, uint32_t command, uint32_t } res = reply_simple_ack(client, tag); exit: - if (props) - pw_properties_free(props); + pw_properties_free(props); return res; error_protocol: @@ -3515,8 +3507,7 @@ static int do_remove_proplist(struct client *client, uint32_t command, uint32_t } res = reply_simple_ack(client, tag); exit: - if (props) - pw_properties_free(props); + pw_properties_free(props); return res; error_protocol: @@ -6693,8 +6684,7 @@ error_free: free(impl); error_exit: - if (props != NULL) - pw_properties_free(props); + pw_properties_free(props); if (res < 0) errno = -res; diff --git a/src/modules/module-protocol-pulse/sample.c b/src/modules/module-protocol-pulse/sample.c index d463453df..15ac3a179 100644 --- a/src/modules/module-protocol-pulse/sample.c +++ b/src/modules/module-protocol-pulse/sample.c @@ -215,8 +215,7 @@ static struct sample_play *sample_play_new(struct pw_core *core, error_cleanup: pw_stream_destroy(p->stream); error_free: - if (props) - pw_properties_free(props); + pw_properties_free(props); free(p); errno = -res; return NULL; diff --git a/src/modules/module-protocol-simple.c b/src/modules/module-protocol-simple.c index d5bdb4ab4..9f1a528b4 100644 --- a/src/modules/module-protocol-simple.c +++ b/src/modules/module-protocol-simple.c @@ -525,8 +525,7 @@ on_connect(void *data, int fd, uint32_t mask) return; error: pw_log_error(NAME" %p: failed to create client: %m", impl); - if (props != NULL) - pw_properties_free(props); + pw_properties_free(props); if (client != NULL) client_free(client); return; @@ -653,8 +652,7 @@ static void impl_free(struct impl *impl) spa_hook_remove(&impl->module_listener); spa_list_consume(s, &impl->server_list, link) server_free(s); - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->props); free(impl); } diff --git a/src/modules/module-pulse-tunnel.c b/src/modules/module-pulse-tunnel.c index 9fe5b89f5..c81c9aded 100644 --- a/src/modules/module-pulse-tunnel.c +++ b/src/modules/module-pulse-tunnel.c @@ -646,10 +646,8 @@ static void impl_destroy(struct impl *impl) if (impl->core && impl->do_disconnect) pw_core_disconnect(impl->core); - if (impl->stream_props) - pw_properties_free(impl->stream_props); - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->stream_props); + pw_properties_free(impl->props); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); free(impl->buffer); diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index 87aaa3813..fa55cc262 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -613,8 +613,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) return 0; error: - if (impl->props) - pw_properties_free(impl->props); + pw_properties_free(impl->props); if (impl->system_bus) pw_rtkit_bus_free(impl->system_bus); free(impl); diff --git a/src/modules/module-session-manager/client-endpoint/client-endpoint.c b/src/modules/module-session-manager/client-endpoint/client-endpoint.c index c845cf05a..a0e442f4f 100644 --- a/src/modules/module-session-manager/client-endpoint/client-endpoint.c +++ b/src/modules/module-session-manager/client-endpoint/client-endpoint.c @@ -120,8 +120,7 @@ static int client_endpoint_stream_update(void *object, : 0; no_mem: - if (props) - pw_properties_free(props); + pw_properties_free(props); free(stream); pw_log_error(NAME" %p: cannot update stream: no memory", this); pw_resource_errorf(this->resource, -ENOMEM, @@ -204,8 +203,7 @@ static void *create_object(void *data, return this; no_mem: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); if (this && this->resource) pw_resource_destroy(this->resource); free(this); diff --git a/src/modules/module-session-manager/client-endpoint/endpoint-stream.c b/src/modules/module-session-manager/client-endpoint/endpoint-stream.c index 0370fb7bb..54a823e05 100644 --- a/src/modules/module-session-manager/client-endpoint/endpoint-stream.c +++ b/src/modules/module-session-manager/client-endpoint/endpoint-stream.c @@ -333,6 +333,5 @@ void endpoint_stream_clear(struct endpoint_stream *this) free(this->info.link_params); free(this->info.params); - if (this->props) - pw_properties_free(this->props); + pw_properties_free(this->props); } diff --git a/src/modules/module-session-manager/client-endpoint/endpoint.c b/src/modules/module-session-manager/client-endpoint/endpoint.c index fe22fbd30..94169ed28 100644 --- a/src/modules/module-session-manager/client-endpoint/endpoint.c +++ b/src/modules/module-session-manager/client-endpoint/endpoint.c @@ -365,6 +365,5 @@ void endpoint_clear(struct endpoint *this) free(this->info.media_class); free(this->info.params); - if (this->props) - pw_properties_free(this->props); + pw_properties_free(this->props); } diff --git a/src/modules/module-session-manager/client-session/client-session.c b/src/modules/module-session-manager/client-session/client-session.c index 6490d4cc8..37b4c890e 100644 --- a/src/modules/module-session-manager/client-session/client-session.c +++ b/src/modules/module-session-manager/client-session/client-session.c @@ -119,8 +119,7 @@ static int client_session_link_update(void *object, : 0; no_mem: - if (props) - pw_properties_free(props); + pw_properties_free(props); free(link); pw_log_error(NAME" %p: cannot update link: no memory", this); pw_resource_error(this->resource, -ENOMEM, @@ -203,8 +202,7 @@ static void *create_object(void *data, return this; no_mem: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); if (this && this->resource) pw_resource_destroy(this->resource); free(this); diff --git a/src/modules/module-session-manager/client-session/endpoint-link.c b/src/modules/module-session-manager/client-session/endpoint-link.c index b5b2dc39e..e5402b490 100644 --- a/src/modules/module-session-manager/client-session/endpoint-link.c +++ b/src/modules/module-session-manager/client-session/endpoint-link.c @@ -350,6 +350,5 @@ void endpoint_link_clear(struct endpoint_link *this) free(this->info.error); free(this->info.params); - if (this->props) - pw_properties_free(this->props); + pw_properties_free(this->props); } diff --git a/src/modules/module-session-manager/client-session/session.c b/src/modules/module-session-manager/client-session/session.c index 4792531ff..4359f08c4 100644 --- a/src/modules/module-session-manager/client-session/session.c +++ b/src/modules/module-session-manager/client-session/session.c @@ -325,6 +325,5 @@ void session_clear(struct session *this) free(this->info.params); - if (this->props) - pw_properties_free(this->props); + pw_properties_free(this->props); } diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index 8beb61e89..d4519f086 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -171,8 +171,7 @@ static void impl_free(struct impl *impl) avahi_client_free(impl->client); if (impl->avahi_poll) pw_avahi_poll_free(impl->avahi_poll); - if (impl->properties) - pw_properties_free(impl->properties); + pw_properties_free(impl->properties); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); free(impl); } diff --git a/src/modules/spa/module-device-factory.c b/src/modules/spa/module-device-factory.c index a2fd55714..b4192ec82 100644 --- a/src/modules/spa/module-device-factory.c +++ b/src/modules/spa/module-device-factory.c @@ -180,8 +180,7 @@ error_bind: goto error_exit; error_exit_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); error_exit: free(factory_name); errno = -res; diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index 6690824eb..b72ab9ab1 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -179,8 +179,7 @@ error_bind: goto error_exit; error_exit_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); error_exit: errno = -res; return NULL; diff --git a/src/modules/spa/spa-device.c b/src/modules/spa/spa-device.c index 25107c6c0..84f189b16 100644 --- a/src/modules/spa/spa-device.c +++ b/src/modules/spa/spa-device.c @@ -158,7 +158,6 @@ error_exit_unload: pw_unload_spa_handle(handle); error_exit: errno = -res; - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return NULL; } diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index d51c9348a..7f473e2ed 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -281,8 +281,7 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context, error_exit_unload: pw_unload_spa_handle(handle); error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/context.c b/src/pipewire/context.c index efb79f9c4..38601810c 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -386,10 +386,8 @@ error_free_loop: error_free: free(this); error_cleanup: - if (conf) - pw_properties_free(conf); - if (properties) - pw_properties_free(properties); + pw_properties_free(conf); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 53a17470e..ebab6caa1 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -391,8 +391,7 @@ error_proxy: exit_free: free(p); exit_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/filter.c b/src/pipewire/filter.c index 1b52253ed..369bf2597 100644 --- a/src/pipewire/filter.c +++ b/src/pipewire/filter.c @@ -1056,8 +1056,7 @@ filter_new(struct pw_context *context, const char *name, error_properties: free(impl); error_cleanup: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } @@ -1124,8 +1123,7 @@ pw_filter_new_simple(struct pw_loop *loop, error_cleanup: if (context) pw_context_destroy(context); - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } @@ -1509,8 +1507,7 @@ error_free: clear_params(impl, p, SPA_ID_INVALID); free(p); error_cleanup: - if (props) - pw_properties_free(props); + pw_properties_free(props); return NULL; } diff --git a/src/pipewire/global.c b/src/pipewire/global.c index 97483328d..cf5dcdd42 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -110,8 +110,7 @@ pw_global_new(struct pw_context *context, error_free: free(impl); error_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index b0e77dde5..20b9c2ba2 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -447,8 +447,7 @@ error_clear_array: error_free: free(impl); error_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } @@ -510,8 +509,7 @@ int pw_impl_client_register(struct pw_impl_client *client, return 0; error_existed: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return -EEXIST; } diff --git a/src/pipewire/impl-core.c b/src/pipewire/impl-core.c index fa6cf18fd..3611c85a6 100644 --- a/src/pipewire/impl-core.c +++ b/src/pipewire/impl-core.c @@ -463,8 +463,7 @@ struct pw_impl_core *pw_context_create_core(struct pw_context *context, return this; error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); free(this); errno = -res; return NULL; @@ -652,8 +651,7 @@ error_existed: res = -EEXIST; goto error_exit; error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return res; } diff --git a/src/pipewire/impl-device.c b/src/pipewire/impl-device.c index 3aec93255..ae507a36b 100644 --- a/src/pipewire/impl-device.c +++ b/src/pipewire/impl-device.c @@ -185,8 +185,7 @@ struct pw_impl_device *pw_context_create_device(struct pw_context *context, error_free: free(impl); error_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } @@ -602,8 +601,7 @@ int pw_impl_device_register(struct pw_impl_device *device, return 0; error_existed: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return -EEXIST; } diff --git a/src/pipewire/impl-factory.c b/src/pipewire/impl-factory.c index 76b5b39ab..27bc1acd9 100644 --- a/src/pipewire/impl-factory.c +++ b/src/pipewire/impl-factory.c @@ -73,8 +73,7 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context, return this; error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } @@ -218,8 +217,7 @@ int pw_impl_factory_register(struct pw_impl_factory *factory, return 0; error_existed: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return -EEXIST; } diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 7a19156d2..30d18407c 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -1200,8 +1200,7 @@ error_no_io: error_free: free(impl); error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } @@ -1278,8 +1277,7 @@ int pw_impl_link_register(struct pw_impl_link *link, return 0; error_existed: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return -EEXIST; } diff --git a/src/pipewire/impl-module.c b/src/pipewire/impl-module.c index ea5790a69..f7aad9cbd 100644 --- a/src/pipewire/impl-module.c +++ b/src/pipewire/impl-module.c @@ -291,8 +291,7 @@ error_free_filename: if (filename) free(filename); error_cleanup: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index ea0ffbc77..ead2778ac 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -718,8 +718,7 @@ int pw_impl_node_register(struct pw_impl_node *this, return 0; error_existed: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); return -EEXIST; } @@ -1235,8 +1234,7 @@ error_clean: spa_system_close(this->context->data_system, this->source.fd); free(impl); error_exit: - if (properties) - pw_properties_free(properties); + pw_properties_free(properties); errno = -res; return NULL; } diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index 06109349c..39bae4a14 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -186,8 +186,7 @@ void pw_mempool_destroy(struct pw_mempool *pool) spa_hook_list_clean(&impl->listener_list); pw_map_clear(&impl->map); - if (pool->props) - pw_properties_free(pool->props); + pw_properties_free(pool->props); free(impl); } diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index d0d5907f0..9f8908bd4 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -377,7 +377,12 @@ int pw_properties_add_keys(struct pw_properties *props, SPA_EXPORT void pw_properties_free(struct pw_properties *properties) { - struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this); + struct properties *impl; + + if (properties == NULL) + return; + + impl = SPA_CONTAINER_OF(properties, struct properties, this); pw_properties_clear(properties); pw_array_clear(&impl->items); free(impl); diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index c86aafe6e..3b9a304d7 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1304,12 +1304,10 @@ stream_new(struct pw_context *context, const char *name, return impl; error_properties: - if (impl->port_props) - pw_properties_free(impl->port_props); + pw_properties_free(impl->port_props); free(impl); error_cleanup: - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } @@ -1375,8 +1373,7 @@ pw_stream_new_simple(struct pw_loop *loop, error_cleanup: if (context) pw_context_destroy(context); - if (props) - pw_properties_free(props); + pw_properties_free(props); errno = -res; return NULL; } @@ -1794,8 +1791,7 @@ error_proxy: goto exit_cleanup; exit_cleanup: - if (props) - pw_properties_free(props); + pw_properties_free(props); return res; } diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index a3abcab05..7e1c0c1d4 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -1753,8 +1753,7 @@ error_no_context: error_no_props: error_no_main_loop: error_bad_file: - if (data.props) - pw_properties_free(data.props); + pw_properties_free(data.props); if (data.file) sf_close(data.file); if (data.midi.file) diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index 215fa5e57..4e1a62166 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -356,8 +356,7 @@ static int destroy_global(void *obj, void *data) return 0; pw_map_remove(&global->rd->globals, global->id); - if (global->properties) - pw_properties_free(global->properties); + pw_properties_free(global->properties); free(global->type); free(global); return 0; @@ -931,8 +930,7 @@ static const struct pw_device_events device_events = { static void session_info_free(struct pw_session_info *info) { free(info->params); - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); free(info); } @@ -955,8 +953,7 @@ static void session_event_info(void *object, info->n_params * sizeof(struct spa_param_info)); } if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); info->props = (struct spa_dict *) pw_properties_new_dict (update->props); } @@ -980,8 +977,7 @@ static void endpoint_info_free(struct pw_endpoint_info *info) free(info->name); free(info->media_class); free(info->params); - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); free(info); } @@ -1012,8 +1008,7 @@ static void endpoint_event_info(void *object, info->n_params * sizeof(struct spa_param_info)); } if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); info->props = (struct spa_dict *) pw_properties_new_dict (update->props); } @@ -1036,8 +1031,7 @@ static void endpoint_stream_info_free(struct pw_endpoint_stream_info *info) { free(info->name); free(info->params); - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); free(info); } @@ -1062,8 +1056,7 @@ static void endpoint_stream_event_info(void *object, info->n_params * sizeof(struct spa_param_info)); } if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS) { - if (info->props) - pw_properties_free ((struct pw_properties *)info->props); + pw_properties_free ((struct pw_properties *)info->props); info->props = (struct spa_dict *) pw_properties_new_dict (update->props); } @@ -1295,8 +1288,7 @@ static bool do_create_device(struct data *data, const char *cmd, char *args, cha props ? &props->dict : NULL, sizeof(struct proxy_data)); - if (props) - pw_properties_free(props); + pw_properties_free(props); pd = pw_proxy_get_user_data(proxy); pd->rd = rd; @@ -1335,8 +1327,7 @@ static bool do_create_node(struct data *data, const char *cmd, char *args, char props ? &props->dict : NULL, sizeof(struct proxy_data)); - if (props) - pw_properties_free(props); + pw_properties_free(props); pd = pw_proxy_get_user_data(proxy); pd->rd = rd; @@ -1407,8 +1398,7 @@ static bool do_create_link(struct data *data, const char *cmd, char *args, char props ? &props->dict : NULL, sizeof(struct proxy_data)); - if (props) - pw_properties_free(props); + pw_properties_free(props); pd = pw_proxy_get_user_data(proxy); pd->rd = rd; diff --git a/src/tools/pw-dot.c b/src/tools/pw-dot.c index 95d75e3cb..3b6e0d73b 100644 --- a/src/tools/pw-dot.c +++ b/src/tools/pw-dot.c @@ -609,8 +609,7 @@ static void removed_proxy(void *user_data) static void destroy_proxy(void *user_data) { struct global *g = user_data; - if (g->props) - pw_properties_free(g->props); + pw_properties_free(g->props); if (g->info) g->info_destroy(g->info); } diff --git a/src/tools/pw-dump.c b/src/tools/pw-dump.c index 8b047772e..ce7cf4405 100644 --- a/src/tools/pw-dump.c +++ b/src/tools/pw-dump.c @@ -198,8 +198,7 @@ static void object_destroy(struct object *o) spa_list_remove(&o->link); if (o->proxy) pw_proxy_destroy(o->proxy); - if (o->props) - pw_properties_free(o->props); + pw_properties_free(o->props); clear_params(&o->param_list, SPA_ID_INVALID); clear_params(&o->pending_list, SPA_ID_INVALID); free(o->type); @@ -1290,8 +1289,7 @@ static void registry_event_global(void *data, uint32_t id, bind_failed: pw_log_error("can't bind object for %u %s/%d: %m", id, type, version); - if (o->props) - pw_properties_free(o->props); + pw_properties_free(o->props); free(o); return; } diff --git a/src/tools/pw-loopback.c b/src/tools/pw-loopback.c index ff2bface1..00b26e3da 100644 --- a/src/tools/pw-loopback.c +++ b/src/tools/pw-loopback.c @@ -251,10 +251,8 @@ exit: pw_context_destroy(data.context); if (data.loop) pw_main_loop_destroy(data.loop); - if (data.capture_props) - pw_properties_free(data.capture_props); - if (data.playback_props) - pw_properties_free(data.playback_props); + pw_properties_free(data.capture_props); + pw_properties_free(data.playback_props); pw_deinit(); return res;