summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2018-12-19 17:47:25 +0100
committerWim Taymans <wtaymans@redhat.com>2018-12-20 09:32:28 +0100
commit5c6bd8e5c7ebe39e6068456465877753f532cc38 (patch)
treec8a9e5df6ea41f0b772c75c588804d5f31824502
parent5390079b4a2bfb5cbf565e654424ee372ad630fd (diff)
free() can handle NULL just fine so skip the check
Fixes #117
-rw-r--r--src/daemon/daemon-config.c2
-rw-r--r--src/modules/module-protocol-dbus.c1
-rw-r--r--src/pipewire/factory.c3
-rw-r--r--src/pipewire/introspect.c72
-rw-r--r--src/pipewire/link.c11
-rw-r--r--src/pipewire/module.c9
-rw-r--r--src/pipewire/node.c6
-rw-r--r--src/pipewire/port.c3
-rw-r--r--src/pipewire/remote.c10
-rw-r--r--src/pipewire/stream.c16
10 files changed, 46 insertions, 87 deletions
diff --git a/src/daemon/daemon-config.c b/src/daemon/daemon-config.c
index a2bccf98..bcc09ac3 100644
--- a/src/daemon/daemon-config.c
+++ b/src/daemon/daemon-config.c
@@ -90,7 +90,7 @@ void pw_daemon_config_free(struct pw_daemon_config *config)
struct pw_command *cmd, *tmp;
spa_list_for_each_safe(cmd, tmp, &config->commands, link)
- pw_command_free(cmd);
+ pw_command_free(cmd);
free(config);
}
diff --git a/src/modules/module-protocol-dbus.c b/src/modules/module-protocol-dbus.c
index 4e0e64d9..3e030c00 100644
--- a/src/modules/module-protocol-dbus.c
+++ b/src/modules/module-protocol-dbus.c
@@ -211,6 +211,7 @@ static void client_destroy(struct client *this)
if (this->sender) {
spa_list_remove(&this->link);
free(this->sender);
+ this->sender = NULL;
}
}
diff --git a/src/pipewire/factory.c b/src/pipewire/factory.c
index cda3267e..35b4cdcb 100644
--- a/src/pipewire/factory.c
+++ b/src/pipewire/factory.c
@@ -67,8 +67,7 @@ void pw_factory_destroy(struct pw_factory *factory)
spa_hook_remove(&factory->global_listener);
pw_global_destroy(factory->global);
}
- if (factory->info.name)
- free((char *)factory->info.name);
+ free((char *)factory->info.name);
if (factory->properties)
pw_properties_free(factory->properties);
diff --git a/src/pipewire/introspect.c b/src/pipewire/introspect.c
index d9aed7fa..bf75f98b 100644
--- a/src/pipewire/introspect.c
+++ b/src/pipewire/introspect.c
@@ -130,23 +130,19 @@ struct pw_core_info *pw_core_info_update(struct pw_core_info *info,
info->change_mask = update->change_mask;
if (update->change_mask & PW_CORE_CHANGE_MASK_USER_NAME) {
- if (info->user_name)
- free((void *) info->user_name);
+ free((void *) info->user_name);
info->user_name = update->user_name ? strdup(update->user_name) : NULL;
}
if (update->change_mask & PW_CORE_CHANGE_MASK_HOST_NAME) {
- if (info->host_name)
- free((void *) info->host_name);
+ free((void *) info->host_name);
info->host_name = update->host_name ? strdup(update->host_name) : NULL;
}
if (update->change_mask & PW_CORE_CHANGE_MASK_VERSION) {
- if (info->version)
- free((void *) info->version);
+ free((void *) info->version);
info->version = update->version ? strdup(update->version) : NULL;
}
if (update->change_mask & PW_CORE_CHANGE_MASK_NAME) {
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL;
}
if (update->change_mask & PW_CORE_CHANGE_MASK_COOKIE)
@@ -161,14 +157,10 @@ struct pw_core_info *pw_core_info_update(struct pw_core_info *info,
void pw_core_info_free(struct pw_core_info *info)
{
- if (info->user_name)
- free((void *) info->user_name);
- if (info->host_name)
- free((void *) info->host_name);
- if (info->version)
- free((void *) info->version);
- if (info->name)
- free((void *) info->name);
+ free((void *) info->user_name);
+ free((void *) info->host_name);
+ free((void *) info->version);
+ free((void *) info->name);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);
@@ -190,8 +182,7 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
info->change_mask = update->change_mask;
if (update->change_mask & PW_NODE_CHANGE_MASK_NAME) {
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL;
}
if (update->change_mask & PW_NODE_CHANGE_MASK_INPUT_PORTS) {
@@ -205,8 +196,7 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
if (update->change_mask & PW_NODE_CHANGE_MASK_STATE) {
info->state = update->state;
- if (info->error)
- free((void *) info->error);
+ free((void *) info->error);
info->error = update->error ? strdup(update->error) : NULL;
}
if (update->change_mask & PW_NODE_CHANGE_MASK_PROPS) {
@@ -220,10 +210,8 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
void pw_node_info_free(struct pw_node_info *info)
{
- if (info->name)
- free((void *) info->name);
- if (info->error)
- free((void *) info->error);
+ free((void *) info->name);
+ free((void *) info->error);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);
@@ -245,8 +233,7 @@ struct pw_port_info *pw_port_info_update(struct pw_port_info *info,
info->change_mask = update->change_mask;
if (update->change_mask & PW_PORT_CHANGE_MASK_NAME) {
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL;
}
if (update->change_mask & PW_PORT_CHANGE_MASK_PROPS) {
@@ -260,8 +247,7 @@ struct pw_port_info *pw_port_info_update(struct pw_port_info *info,
void pw_port_info_free(struct pw_port_info *info)
{
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);
@@ -279,8 +265,7 @@ struct pw_factory_info *pw_factory_info_update(struct pw_factory_info *info,
return NULL;
}
info->id = update->id;
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL;
info->type = update->type;
info->version = update->version;
@@ -296,8 +281,7 @@ struct pw_factory_info *pw_factory_info_update(struct pw_factory_info *info,
void pw_factory_info_free(struct pw_factory_info *info)
{
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);
@@ -318,18 +302,15 @@ struct pw_module_info *pw_module_info_update(struct pw_module_info *info,
info->change_mask = update->change_mask;
if (update->change_mask & PW_MODULE_CHANGE_MASK_NAME) {
- if (info->name)
- free((void *) info->name);
+ free((void *) info->name);
info->name = update->name ? strdup(update->name) : NULL;
}
if (update->change_mask & PW_MODULE_CHANGE_MASK_FILENAME) {
- if (info->filename)
- free((void *) info->filename);
+ free((void *) info->filename);
info->filename = update->filename ? strdup(update->filename) : NULL;
}
if (update->change_mask & PW_MODULE_CHANGE_MASK_ARGS) {
- if (info->args)
- free((void *) info->args);
+ free((void *) info->args);
info->args = update->args ? strdup(update->args) : NULL;
}
if (update->change_mask & PW_MODULE_CHANGE_MASK_PROPS) {
@@ -342,12 +323,9 @@ struct pw_module_info *pw_module_info_update(struct pw_module_info *info,
void pw_module_info_free(struct pw_module_info *info)
{
- if (info->name)
- free((void *) info->name);
- if (info->filename)
- free((void *) info->filename);
- if (info->args)
- free((void *) info->args);
+ free((void *) info->name);
+ free((void *) info->filename);
+ free((void *) info->args);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);
@@ -406,8 +384,7 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info,
info->input_port_id = update->input_port_id;
}
if (update->change_mask & PW_LINK_CHANGE_MASK_FORMAT) {
- if (info->format)
- free(info->format);
+ free(info->format);
info->format = pw_spa_pod_copy(update->format);
}
return info;
@@ -415,7 +392,6 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info,
void pw_link_info_free(struct pw_link_info *info)
{
- if (info->format)
- free(info->format);
+ free(info->format);
free(info);
}
diff --git a/src/pipewire/link.c b/src/pipewire/link.c
index 8a4dbeaf..ab35f05b 100644
--- a/src/pipewire/link.c
+++ b/src/pipewire/link.c
@@ -215,9 +215,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st
pw_work_queue_add(impl->work, input->node, res2, complete_ready, input);
}
-
- if (this->info.format)
- free(this->info.format);
+ free(this->info.format);
this->info.format = format;
if (changed) {
@@ -235,8 +233,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st
error:
pw_link_update_state(this, PW_LINK_STATE_ERROR, error);
- if (format)
- free(format);
+ free(format);
return res;
}
@@ -1311,9 +1308,7 @@ void pw_link_destroy(struct pw_link *link)
if (link->properties)
pw_properties_free(link->properties);
- if (link->info.format)
- free(link->info.format);
-
+ free(link->info.format);
free(impl);
}
diff --git a/src/pipewire/module.c b/src/pipewire/module.c
index 07282f95..d8923524 100644
--- a/src/pipewire/module.c
+++ b/src/pipewire/module.c
@@ -299,12 +299,9 @@ void pw_module_destroy(struct pw_module *module)
spa_list_for_each_safe(resource, tmp, &module->resource_list, link)
pw_resource_destroy(resource);
- if (module->info.name)
- free((char *) module->info.name);
- if (module->info.filename)
- free((char *) module->info.filename);
- if (module->info.args)
- free((char *) module->info.args);
+ free((char *) module->info.name);
+ free((char *) module->info.filename);
+ free((char *) module->info.args);
dlclose(impl->hnd);
free(impl);
diff --git a/src/pipewire/node.c b/src/pipewire/node.c
index 726e30cc..38f4c8a9 100644
--- a/src/pipewire/node.c
+++ b/src/pipewire/node.c
@@ -654,8 +654,7 @@ void pw_node_destroy(struct pw_node *node)
pw_map_clear(&node->input_port_map);
pw_map_clear(&node->output_port_map);
- if (node->properties)
- pw_properties_free(node->properties);
+ pw_properties_free(node->properties);
clear_info(node);
@@ -922,8 +921,7 @@ void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *
pw_log_debug("node %p: update state from %s -> %s", node,
pw_node_state_as_string(old), pw_node_state_as_string(state));
- if (node->info.error)
- free((char*)node->info.error);
+ free((char*)node->info.error);
node->info.error = error;
node->info.state = state;
diff --git a/src/pipewire/port.c b/src/pipewire/port.c
index c1702660..e3db4e0e 100644
--- a/src/pipewire/port.c
+++ b/src/pipewire/port.c
@@ -564,8 +564,7 @@ void pw_port_destroy(struct pw_port *port)
pw_map_clear(&port->mix_port_map);
- if (port->properties)
- pw_properties_free(port->properties);
+ pw_properties_free(port->properties);
free(port);
}
diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c
index 26e65680..c19f3512 100644
--- a/src/pipewire/remote.c
+++ b/src/pipewire/remote.c
@@ -124,8 +124,7 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con
enum pw_remote_state old = remote->state;
if (old != state) {
- if (remote->error)
- free(remote->error);
+ free(remote->error);
if (fmt) {
va_list varargs;
@@ -305,8 +304,9 @@ void pw_remote_destroy(struct pw_remote *remote)
spa_list_remove(&remote->link);
- if (remote->properties)
- pw_properties_free(remote->properties);
+ pw_log_debug("remote %p: free", remote);
+ pw_properties_free(remote->properties);
+
free(remote->error);
free(impl);
}
@@ -452,7 +452,7 @@ int pw_remote_disconnect(struct pw_remote *remote)
remote->n_types = 0;
if (remote->info) {
- pw_core_info_free (remote->info);
+ pw_core_info_free(remote->info);
remote->info = NULL;
}
pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL);
diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c
index fa8922c1..0f3a5bde 100644
--- a/src/pipewire/stream.c
+++ b/src/pipewire/stream.c
@@ -304,8 +304,7 @@ static bool stream_set_state(struct pw_stream *stream, enum pw_stream_state stat
enum pw_stream_state old = stream->state;
bool res = old != state;
if (res) {
- if (stream->error)
- free(stream->error);
+ free(stream->error);
stream->error = error;
pw_log_debug("stream %p: update state from %s -> %s (%s)", stream,
@@ -540,14 +539,10 @@ void pw_stream_destroy(struct pw_stream *stream)
pw_array_clear(&impl->mem_ids);
- if (stream->error)
- free(stream->error);
-
- if (stream->name)
- free(stream->name);
+ free(stream->error);
+ free(stream->name);
- if (stream->properties)
- pw_properties_free(stream->properties);
+ pw_properties_free(stream->properties);
free(impl);
}
@@ -948,8 +943,7 @@ client_node_port_set_param(void *data,
pw_log_debug("stream %p: format changed %d", stream, seq);
- if (impl->format)
- free(impl->format);
+ free(impl->format);
if (spa_pod_is_object_type(param, t->spa_format)) {
impl->format = pw_spa_pod_copy(param);