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

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

View file

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

View file

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

View file

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

View file

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