From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbcEaFl2 (ORCPT ); Tue, 31 May 2016 01:41:28 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:13091 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907AbcEaFl0 (ORCPT ); Tue, 31 May 2016 01:41:26 -0400 X-IronPort-AV: E=Sophos;i="5.26,394,1459807200"; d="scan'208";a="220382425" Date: Tue, 31 May 2016 07:41:23 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: Ezequiel Garcia cc: Amitoj Kaur Chawla , David Woodhouse , Brian Norris , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mtd: Replace if and BUG with BUG_ON In-Reply-To: Message-ID: References: <20160528164117.GA31101@amitoj-Inspiron-3542> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 May 2016, Ezequiel Garcia wrote: > Hi Amitoj, > > Thanks for your patch. > > On 28 May 2016 at 13:41, Amitoj Kaur Chawla wrote: > > Replace if condition and BUG() with a BUG_ON having the conditional > > expression of the if statement as argument. > > > > We usually want commit messages that tell us *why* you are doing the > change: what are you fixing, or what are you improving, and what > possible side-effects it may have. > > This commit log explains what the code does, but we can clearly see > that, so it's not useful. > > > The Coccinelle semantic patch used to make this change is as follows: > > @@ expression E,f; @@ > > > > ( > > if (<+... f(...) ...+>) { BUG(); } > > | > > - if (E) { BUG(); } > > + BUG_ON(E); > > ) > > > > Signed-off-by: Amitoj Kaur Chawla > > --- > > drivers/mtd/ssfdc.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c > > index daf82ba..41b13d1 100644 > > --- a/drivers/mtd/ssfdc.c > > +++ b/drivers/mtd/ssfdc.c > > @@ -380,8 +380,7 @@ static int ssfdcr_readsect(struct mtd_blktrans_dev *dev, > > " block_addr=%d\n", logic_sect_no, sectors_per_block, offset, > > block_address); > > > > - if (block_address >= ssfdc->map_len) > > - BUG(); > > + BUG_ON(block_address >= ssfdc->map_len); > > > > I don't want to be rude, but I wonder if there's any value at all in > such a patch. It barely improves readability, it barely reduces the > LoC, yet it consumes developer time, maintainer time, and changes git > per-line authorship (used in git blame). Actually, I think that this particular patch does improve readability a bit. Scanning straight down the code is easier than looking under an if. Also, git blame now has a way to go back in history (although I don't remember what it is), so the argument that cleaning up the code makes it very difficult to find why the nontrivial part of the code is as it is doesn't completely hold any more. julia