[pulseaudio-discuss] [PATCH v2 5/6] card: simplify setting pa_card.name

Tanu Kaskinen tanuk at iki.fi
Sun Jun 12 20:41:11 UTC 2016


On Sun, 2016-06-12 at 18:58 +0500, Alexander E. Patrakov wrote:
> 10.06.2016 22:55, Tanu Kaskinen пишет:
> > ---
> >  src/pulsecore/card.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
> > index bc5b75b..896e959 100644
> > --- a/src/pulsecore/card.c
> > +++ b/src/pulsecore/card.c
> > @@ -122,7 +122,6 @@ void pa_card_new_data_done(pa_card_new_data *data) {
> > 
> >  pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
> >      pa_card *c;
> > -    const char *name;
> >      void *state;
> >      pa_card_profile *profile;
> >      pa_device_port *port;
> > @@ -135,16 +134,15 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
> > 
> >      c = pa_xnew0(pa_card, 1);
> > 
> > -    if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail))) {
> > +    if (!(c->name = pa_xstrdup(pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail)))) {
> 
> I think that the old code was more obvious.
> 
> pa_namereg_register() could return NULL, you checked for that 
> immediately, and acted upon the error. Now you pass this NULL through 
> pa_xstrdup(). This causes the reader to think what pa_xstrdup does with 
> a NULL. Yes, it returns a NULL, but I had to look at the source.

Ok, I'll drop this patch.

-- 
Tanu


More information about the pulseaudio-discuss mailing list