[PATCH v2 02/18] sink, source: Disallow setting NULL description

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/28/2013 09:47 AM, Tanu Kaskinen wrote:
> ---
>   src/pulsecore/sink.c   | 15 +++++----------
>   src/pulsecore/source.c | 13 ++++---------
>   2 files changed, 9 insertions(+), 19 deletions(-)
>
> diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
> index cf3a90e..3d039b4 100644
> --- a/src/pulsecore/sink.c
> +++ b/src/pulsecore/sink.c
> @@ -2295,29 +2295,24 @@ pa_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist
>   }
>
>   /* Called from main thread */
> -/* FIXME -- this should be dropped and be merged into pa_sink_update_proplist() */
>   void pa_sink_set_description(pa_sink *s, const char *description) {
>       const char *old;
> +
>       pa_sink_assert_ref(s);
> +    pa_assert(description);

Are empty names okay ( description[0] == '\0') ? Otherwise you might 
want to add that too to your list of assertions.

>       pa_assert_ctl_context();
>
> -    if (!description && !pa_proplist_contains(s->proplist, PA_PROP_DEVICE_DESCRIPTION))
> -        return;
> -
>       old = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
>
> -    if (old && description && pa_streq(old, description))
> +    if (old && pa_streq(old, description))
>           return;
>
> -    if (description)
> -        pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
> -    else
> -        pa_proplist_unset(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
> +    pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
>
>       if (s->monitor_source) {
>           char *n;
>
> -        n = pa_sprintf_malloc("Monitor Source of %s", description ? description : s->name);
> +        n = pa_sprintf_malloc("Monitor Source of %s", description);
>           pa_source_set_description(s->monitor_source, n);
>           pa_xfree(n);
>       }
> diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
> index 98a8bcc..aaa0542 100644
> --- a/src/pulsecore/source.c
> +++ b/src/pulsecore/source.c
> @@ -1852,24 +1852,19 @@ pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_prop
>   }
>
>   /* Called from main thread */
> -/* FIXME -- this should be dropped and be merged into pa_source_update_proplist() */
>   void pa_source_set_description(pa_source *s, const char *description) {
>       const char *old;
> +
>       pa_source_assert_ref(s);
> +    pa_assert(description);
>       pa_assert_ctl_context();
>
> -    if (!description && !pa_proplist_contains(s->proplist, PA_PROP_DEVICE_DESCRIPTION))
> -        return;
> -
>       old = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
>
> -    if (old && description && pa_streq(old, description))
> +    if (old && pa_streq(old, description))
>           return;
>
> -    if (description)
> -        pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
> -    else
> -        pa_proplist_unset(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
> +    pa_proplist_sets(s->proplist, PA_PROP_DEVICE_DESCRIPTION, description);
>
>       if (PA_SOURCE_IS_LINKED(s->state)) {
>           pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
>



-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux