From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
To: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.de>, alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/3] ucm: add a FIXME comment
Date: Wed, 11 Feb 2015 16:16:11 +0000 [thread overview]
Message-ID: <1423671371.7654.27.camel@loki> (raw)
In-Reply-To: <1423661646.2747.5.camel@tkkaskin-mobl3.ger.corp.intel.com>
On Wed, 2015-02-11 at 15:34 +0200, Tanu Kaskinen wrote:
> On Wed, 2015-02-11 at 14:01 +0100, Takashi Iwai wrote:
> > At Wed, 11 Feb 2015 13:44:40 +0200,
> > Tanu Kaskinen wrote:
> > >
> > > On Wed, 2015-02-11 at 12:38 +0100, Takashi Iwai wrote:
> > > > At Tue, 10 Feb 2015 22:42:33 +0200,
> > > > Tanu Kaskinen wrote:
> > > > >
> > > > > I'm pretty sure the current code will crash with some inputs, but I
> > > > > don't know what the original author intended this code to do, so I
> > > > > don't know how to fix it.
> > > > > ---
> > > > > src/ucm/main.c | 8 ++++++++
> > > > > 1 file changed, 8 insertions(+)
> > > > >
> > > > > diff --git a/src/ucm/main.c b/src/ucm/main.c
> > > > > index 3924aee..62bc374 100644
> > > > > --- a/src/ucm/main.c
> > > > > +++ b/src/ucm/main.c
> > > > > @@ -317,6 +317,14 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
> > > > > uc_error("cdev is not defined!");
> > > > > return err;
> > > > > }
> > > > > + /* FIXME: If cdev1 is NULL and cdev2 is not,
> > > > > + * then set cdev to cdev1... makes no sense!
> > > > > + * Also, what if both cdev1 and cdev2 are NULL?
> > > > > + * What should happen? Later in this function we
> > > > > + * call open_ctl(), which assumes non-NULL cdev,
> > > > > + * so leaving cdev to NULL here is not an
> > > > > + * option (or at least cdev has to be checked
> > > > > + * before calling open_ctl()). */
> > > > > if (cdev1 == NULL || cdev2 == NULL ||
> > > > > strcmp(cdev1, cdev2) == 0) {
> > > > > cdev = (char *)cdev1;
> > > >
> > > > Ouch, the code is really buggy there. We must fix it instead of
> > > > leaving FIXME.
> > > >
> > > > I see there are multiple bugs (in addition to your patch#1):
> > > >
> > > > - the error check is wrong, it should be compared with -ENOENT
> > > > if (err < 0 && err != ENOENT)
> > > >
> > > > This leaves cdev1 or cdev2 NULL as non-error.
> > > >
> > > > - The intention of the code should be (as far as I understand):
> > > > - if only one of cdev1 and cdev2 is defined, take it as cdev
> > > > - if cdev1 and cdev2 are defined and have the same string, keep
> > > > cdev1 and free cdev2
> > > > - in the rest cases, free both cdev1 and cdev2 without changing cdev
> > >
> > > Regarding that last case, just leaving cdev unchanged is not a good
> > > idea. cdev will always be NULL if we don't set it here, and when we call
> > > open_ctl(), it must be non-NULL.
> >
> > Right. I *guess* if cdev1 != cdev2, it should bail out as an error.
>
> Ok, I'll make a patch that will implement the described behaviour.
>
It may also be worth adding a comment describing the cdev1/2 usage or
maybe even rename them to make it obvious ?
Thanks
Liam
next prev parent reply other threads:[~2015-02-11 16:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 20:42 [PATCH 0/3] ucm: miscellaneous fixes Tanu Kaskinen
2015-02-10 20:42 ` [PATCH 1/3] ucm: fix variable mixup Tanu Kaskinen
2015-02-11 11:43 ` Takashi Iwai
2015-02-10 20:42 ` [PATCH 2/3] ucm: add a FIXME comment Tanu Kaskinen
2015-02-11 11:38 ` Takashi Iwai
2015-02-11 11:44 ` Tanu Kaskinen
2015-02-11 13:01 ` Takashi Iwai
2015-02-11 13:34 ` Tanu Kaskinen
2015-02-11 13:35 ` Takashi Iwai
2015-02-11 16:16 ` Liam Girdwood [this message]
2015-02-10 20:42 ` [PATCH 3/3] ucm: fix inappropriate use of const Tanu Kaskinen
2015-02-11 11:42 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423671371.7654.27.camel@loki \
--to=liam.r.girdwood@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=tanu.kaskinen@linux.intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox