Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-26 Thread Gustavo A. R. Silva
Hi Herbert, Quoting Herbert Xu : On Wed, Oct 25, 2017 at 07:38:35PM -0500, Gustavo A. R. Silva wrote: I don't think we want something like: bool err; err = build_spdinfo(r_skb, net, sportid, seq, *flags) < 0 ? true : false; BUG_ON(err); How about int err; err = build_spd

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-25 Thread Herbert Xu
On Wed, Oct 25, 2017 at 07:38:35PM -0500, Gustavo A. R. Silva wrote: > > I don't think we want something like: > > bool err; > > err = build_spdinfo(r_skb, net, sportid, seq, *flags) < 0 ? true : false; > BUG_ON(err); How about int err; err = build_spdinfo(r_skb, net, sportid,

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-25 Thread Gustavo A. R. Silva
Quoting "Gustavo A. R. Silva" : Hi all, Quoting Steffen Klassert : On Wed, Oct 25, 2017 at 01:22:22PM +0900, David Miller wrote: From: Herbert Xu Date: Wed, 25 Oct 2017 12:05:41 +0800 On Tue, Oct 24, 2017 at 05:48:42PM +0900, David Miller wrote: This discussion has happened before. Bu

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-25 Thread Gustavo A. R. Silva
Hi all, Quoting Steffen Klassert : On Wed, Oct 25, 2017 at 01:22:22PM +0900, David Miller wrote: From: Herbert Xu Date: Wed, 25 Oct 2017 12:05:41 +0800 > On Tue, Oct 24, 2017 at 05:48:42PM +0900, David Miller wrote: >> >> This discussion has happened before. >> >> But I'll explain the conclu

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-25 Thread Steffen Klassert
On Wed, Oct 25, 2017 at 01:22:22PM +0900, David Miller wrote: > From: Herbert Xu > Date: Wed, 25 Oct 2017 12:05:41 +0800 > > > On Tue, Oct 24, 2017 at 05:48:42PM +0900, David Miller wrote: > >> > >> This discussion has happened before. > >> > >> But I'll explain the conclusion here for your ben

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-24 Thread David Miller
From: Herbert Xu Date: Wed, 25 Oct 2017 12:05:41 +0800 > On Tue, Oct 24, 2017 at 05:48:42PM +0900, David Miller wrote: >> >> This discussion has happened before. >> >> But I'll explain the conclusion here for your benefit. >> >> BUG_ON() is a statement and everything inside of it will >> alway

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-24 Thread Herbert Xu
On Tue, Oct 24, 2017 at 05:48:42PM +0900, David Miller wrote: > > This discussion has happened before. > > But I'll explain the conclusion here for your benefit. > > BUG_ON() is a statement and everything inside of it will > always execute. > > BUG_ON() is always preferred because it allows arc

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-24 Thread David Miller
From: Herbert Xu Date: Tue, 24 Oct 2017 11:25:08 +0800 > On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: >> Use BUG_ON instead of if condition followed by BUG. >> >> This issue was detected with the help of Coccinelle. >> >> Signed-off-by: Gustavo A. R. Silva > > I think

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-24 Thread David Miller
From: Herbert Xu Date: Tue, 24 Oct 2017 11:53:20 +0800 > No your patch makes it worse. The original construct makes it > clear that the conditional is real code and not just some debugging > aid. > > With your patch, real code is now inside BUG_ON. This discussion has happened before. But I'l

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Herbert Xu
On Mon, Oct 23, 2017 at 09:01:46PM -0700, Alexei Starovoitov wrote: > > fwiw I had the same argument earlier: > https://lkml.org/lkml/2017/10/9/1139 Fair point on eliminating a branch. But I'd prefer something like bool cond; cond = code_that_does_something(); BUG_ON(con

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Gustavo A. R. Silva
Quoting Herbert Xu : On Mon, Oct 23, 2017 at 10:50:43PM -0500, Gustavo A. R. Silva wrote: Quoting Herbert Xu : >On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: >>Use BUG_ON instead of if condition followed by BUG. >> >>This issue was detected with the help of Coccinelle.

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Alexei Starovoitov
On Tue, Oct 24, 2017 at 11:53:20AM +0800, Herbert Xu wrote: > On Mon, Oct 23, 2017 at 10:50:43PM -0500, Gustavo A. R. Silva wrote: > > > > Quoting Herbert Xu : > > > > >On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: > > >>Use BUG_ON instead of if condition followed by BUG. >

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Herbert Xu
On Mon, Oct 23, 2017 at 10:50:43PM -0500, Gustavo A. R. Silva wrote: > > Quoting Herbert Xu : > > >On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: > >>Use BUG_ON instead of if condition followed by BUG. > >> > >>This issue was detected with the help of Coccinelle. > >> > >>Si

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Gustavo A. R. Silva
Quoting Herbert Xu : On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: Use BUG_ON instead of if condition followed by BUG. This issue was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva I think this patch is terrible. Why on earth is Coccinelle

Re: [PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Herbert Xu
On Mon, Oct 23, 2017 at 01:18:57PM -0500, Gustavo A. R. Silva wrote: > Use BUG_ON instead of if condition followed by BUG. > > This issue was detected with the help of Coccinelle. > > Signed-off-by: Gustavo A. R. Silva I think this patch is terrible. Why on earth is Coccinelle even warning abo

[PATCH] net: xfrm_user: use BUG_ON instead of if condition followed by BUG

2017-10-23 Thread Gustavo A. R. Silva
Use BUG_ON instead of if condition followed by BUG. This issue was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva --- net/xfrm/xfrm_user.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm