Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3254034ybi; Fri, 5 Jul 2019 04:28:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5yftPTCyoOhzaUIFi+tZ6QfDK9xpvfQfoo2kIgd6WL78wDlU3wRwHPKSp1vSgykfEORnn X-Received: by 2002:a17:902:296a:: with SMTP id g97mr4934989plb.115.1562326123278; Fri, 05 Jul 2019 04:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562326123; cv=none; d=google.com; s=arc-20160816; b=cG6RFnpp2ATI9e1TxGzrB8uZuKnojo1w5mv8ZPc5QoBactFz50AUaDulx2uJRC9ouI yDnOqfOhz4hJw4qLHmy2HklPK2NGNl2n1Jm7OhR+m43eJ6NBvDhGwxI04BH0f4C+THCU 1IwW0mJ7hqKU+spAnohdP7vipMmz9H3NW2Y2/sBghBmGBNZ2L4bVdLKDTEgdBwD26CDi 2TTPOCJwiJAx59lo5w8OX4NzJBZ1Soy58EfRaaJt3uEykE+9oTmoV3UD32Ihi0Gdux1/ GXs6J+uusaEsuUwlNZYPgE36xL1Py0IO7QQx3OKZ0GQw6txSyNtsZOn0RqpqQZj4qDMc Lq+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=6apruxXla4hHs/SL2ad/D8gMhBMeUckYciJuDeTjqx8=; b=u0j2F+3b9wtvSS2iDjHETm1nHPC1F2zbIg1VMkP0ImRMF82Iv7heWutKTTOoq9YbYg YAxnvnClOtNkZx1dJUOQjrshHbVnQfMsSoVDY2VXwHYt1P7rYseV2UaMYef0hmBSK7mw s2UtO9C90iMTZxNAS+zOpo/XYJYN7yMXMUTJjl0c7LZosDDtGEEf+UBoEu+ngFQ3r6gN RmoBhhpxjmXc7BakSTk4tzn4KPuRchBSfZ9nPVii0nNg64vwK2GxUUD0nmyrglWDn99A 0CMk4BdQPAh/fVVv0rBFPnXXSzFmEoRfqmN7Tx4Jn+gtsfOhSk3/3B1pf7JSAVa6WjZ7 6hRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u190si9275772pgd.547.2019.07.05.04.28.28; Fri, 05 Jul 2019 04:28:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728516AbfGEKgd (ORCPT + 99 others); Fri, 5 Jul 2019 06:36:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:45080 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728132AbfGEKgd (ORCPT ); Fri, 5 Jul 2019 06:36:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 373DCAC4E; Fri, 5 Jul 2019 10:36:32 +0000 (UTC) Date: Fri, 05 Jul 2019 12:36:31 +0200 Message-ID: From: Takashi Iwai To: wharms@bfs.de Cc: "Colin King" , , "Jaroslav Kysela" , , Subject: Re: [PATCH] ALSA: cs4281: remove redundant assignment to variable val and remove a goto In-Reply-To: <5D1F245A.7030203@bfs.de> References: <20190705095704.26050-1-colin.king@canonical.com> <5D1F245A.7030203@bfs.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > 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 > > --- > > 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