public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: wharms@bfs.de
Cc: "Colin King" <colin.king@canonical.com>,
	<alsa-devel@alsa-project.org>, "Jaroslav Kysela" <perex@perex.cz>,
	<kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: cs4281: remove redundant assignment to variable val and remove a goto
Date: Fri, 05 Jul 2019 12:36:31 +0200	[thread overview]
Message-ID: <s5hbly8zs28.wl-tiwai@suse.de> (raw)
In-Reply-To: <5D1F245A.7030203@bfs.de>

On Fri, 05 Jul 2019 12:20:10 +0200,
walter harms wrote:
> 
> 
> 
> Am 05.07.2019 11:57, schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > The variable val is being assigned with a value that is never
> > read and it is being updated later with a new value. The
> > assignment is redundant and can be removed.  Also remove a
> > goto statement and a label and replace with a break statement.
> > 
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  sound/pci/cs4281.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
> > index a2cce3ecda6f..04c712647853 100644
> > --- a/sound/pci/cs4281.c
> > +++ b/sound/pci/cs4281.c
> > @@ -694,7 +694,7 @@ static int snd_cs4281_trigger(struct snd_pcm_substream *substream, int cmd)
> >  
> >  static unsigned int snd_cs4281_rate(unsigned int rate, unsigned int *real_rate)
> >  {
> > -	unsigned int val = ~0;
> > +	unsigned int val;
> >  	
> >  	if (real_rate)
> >  		*real_rate = rate;
> > @@ -707,9 +707,8 @@ static unsigned int snd_cs4281_rate(unsigned int rate, unsigned int *real_rate)
> >  	case 44100:	return 1;
> >  	case 48000:	return 0;
> >  	default:
> > -		goto __variable;
> > +		break;
> >  	}
> > -      __variable:
> >  	val = 1536000 / rate;
> >  	if (real_rate)
> >  		*real_rate = 1536000 / val;
> 		^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> this is confusing. is
> *real_rate = rate
> intended here ? (like above)
> 
> val could be eliminated by using
> 
> return  1536000 / rate ;

No, the current code is correct.
The purpose of this calculation is to consider the truncation by
division.


Takashi

      reply	other threads:[~2019-07-05 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  9:57 [PATCH] ALSA: cs4281: remove redundant assignment to variable val and remove a goto Colin King
2019-07-05 10:12 ` Takashi Iwai
2019-07-05 10:20 ` walter harms
2019-07-05 10:36   ` Takashi Iwai [this message]

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=s5hbly8zs28.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=wharms@bfs.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