Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753877AbdLMUos (ORCPT ); Wed, 13 Dec 2017 15:44:48 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46855 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753503AbdLMUor (ORCPT ); Wed, 13 Dec 2017 15:44:47 -0500 Subject: Re: [PATCH][mtd-next] mtd: nand: remove redundant check of len To: Boris Brezillon Cc: Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20171213201743.27324-1-colin.king@canonical.com> <20171213212425.6fe999cb@bbrezillon> <20171213213844.78efe253@bbrezillon> From: Colin Ian King Message-ID: Date: Wed, 13 Dec 2017 20:44:45 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171213213844.78efe253@bbrezillon> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2187 Lines: 71 On 13/12/17 20:38, Boris Brezillon wrote: > On Wed, 13 Dec 2017 20:30:04 +0000 > Colin Ian King wrote: > >> On 13/12/17 20:24, Boris Brezillon wrote: >>> On Wed, 13 Dec 2017 20:17:43 +0000 >>> Colin King wrote: >>> >>>> From: Colin Ian King >>>> >>>> The check of len being zero is redundant as it has already been >>>> sanity checked for this value at the start of the function. Hence >>>> it is impossible for this test to be true and so the redundant >>>> code can be removed. >>> >>> Nope, it's not the same test, the initial test is >>> >>> if (len && !buf) >> >> Ah, the current tip from linux-next has: >> >> 1912 if (!len || !buf) >> 1913 return -EINVAL; >> >> ..so I guess that's why it got picked up by static analysis. > > Hm, that's weird, that's not what I see [1] in linux-next. I see my mistake, I fixed the *wrong* function, I'll send a v2. Doh. > > [1]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/mtd/nand/nand_base.c#n1488 > >> >>> >>> not >>> >>> if (len) >>> >>> So this test is not redundant. >>> >>>> >>>> Detected by CoverityScan, CID#1462748 ("Logically dead code") >>>> >>>> Signed-off-by: Colin Ian King >>>> --- >>>> drivers/mtd/nand/nand_base.c | 4 ---- >>>> 1 file changed, 4 deletions(-) >>>> >>>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c >>>> index afd5e18db81c..9daaa23db943 100644 >>>> --- a/drivers/mtd/nand/nand_base.c >>>> +++ b/drivers/mtd/nand/nand_base.c >>>> @@ -1507,10 +1507,6 @@ static int nand_read_param_page_op(struct nand_chip *chip, u8 page, void *buf, >>>> }; >>>> struct nand_operation op = NAND_OPERATION(instrs); >>>> >>>> - /* Drop the DATA_IN instruction if len is set to 0. */ >>>> - if (!len) >>>> - op.ninstrs--; >>>> - >>>> return nand_exec_op(chip, &op); >>>> } >>>> >>> >> > > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >