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.
This commit is contained in:
Peter Hutterer 2021-06-01 11:21:17 +10:00 committed by Wim Taymans
parent a1e821c259
commit e0471c6757
68 changed files with 142 additions and 273 deletions

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}