Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1408495 > unrolled thread
| Started by | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| First post | 2016-05-28 18:50 +0200 |
| Last post | 2016-05-31 07:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] mtd: Replace if and BUG with BUG_ON Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-05-28 18:50 +0200
Re: [PATCH] mtd: Replace if and BUG with BUG_ON Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> - 2016-05-31 00:20 +0200
Re: [PATCH] mtd: Replace if and BUG with BUG_ON Julia Lawall <julia.lawall@lip6.fr> - 2016-05-31 07:50 +0200
| From | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| Date | 2016-05-28 18:50 +0200 |
| Subject | [PATCH] mtd: Replace if and BUG with BUG_ON |
| Message-ID | <rDPAZ-2Qo-1@gated-at.bofh.it> |
Replace if condition and BUG() with a BUG_ON having the conditional
expression of the if statement as argument.
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 <amitoj1606@gmail.com>
---
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);
block_address = ssfdc->logic_block_map[block_address];
--
1.9.1
[toc] | [next] | [standalone]
| From | Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> |
|---|---|
| Date | 2016-05-31 00:20 +0200 |
| Message-ID | <rEDHr-1Vq-9@gated-at.bofh.it> |
| In reply to | #1408495 |
Hi Amitoj,
Thanks for your patch.
On 28 May 2016 at 13:41, Amitoj Kaur Chawla <amitoj1606@gmail.com> 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 <amitoj1606@gmail.com>
> ---
> 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).
I'm not complaining about *this* particular patch, but rather about
these kind of supposedly clean-up patches.
--
Ezequiel GarcĂa, VanguardiaSur
www.vanguardiasur.com.ar
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2016-05-31 07:50 +0200 |
| Message-ID | <rEKIV-6JU-5@gated-at.bofh.it> |
| In reply to | #1409681 |
On Mon, 30 May 2016, Ezequiel Garcia wrote:
> Hi Amitoj,
>
> Thanks for your patch.
>
> On 28 May 2016 at 13:41, Amitoj Kaur Chawla <amitoj1606@gmail.com> 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 <amitoj1606@gmail.com>
> > ---
> > 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web