[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171009202633.ep5pbi2tlg7dqidz@sasha-lappy>
Date: Mon, 9 Oct 2017 20:26:34 +0000
From: "Levin, Alexander (Sasha Levin)" <alexander.levin@...izon.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
CC: Tim Hansen <devtimhansen@...il.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"willemb@...gle.com" <willemb@...gle.com>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"soheil@...gle.com" <soheil@...gle.com>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"elena.reshetova@...el.com" <elena.reshetova@...el.com>,
"tom@...ntonium.net" <tom@...ntonium.net>,
"Jason@...c4.com" <Jason@...c4.com>, "fw@...len.de" <fw@...len.de>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] net/core: Fix BUG to BUG_ON conditionals.
On Mon, Oct 09, 2017 at 10:15:42AM -0700, Alexei Starovoitov wrote:
>On Mon, Oct 09, 2017 at 11:37:59AM -0400, Tim Hansen wrote:
>> Fix BUG() calls to use BUG_ON(conditional) macros.
>>
>> This was found using make coccicheck M=net/core on linux next
>> tag next-2017092
>>
>> Signed-off-by: Tim Hansen <devtimhansen@...il.com>
>> ---
>> net/core/skbuff.c | 15 ++++++---------
>> 1 file changed, 6 insertions(+), 9 deletions(-)
>>
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index d98c2e3ce2bf..34ce4c1a0f3c 100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>> @@ -1350,8 +1350,7 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
>> /* Set the tail pointer and length */
>> skb_put(n, skb->len);
>>
>> - if (skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len))
>> - BUG();
>> + BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len));
>
>I'm concerned with this change.
>1. Calling non-trivial bit of code inside the macro is a poor coding style (imo)
>2. BUG_ON != BUG. Some archs like mips and ppc have HAVE_ARCH_BUG_ON and implementation
>of BUG and BUG_ON look quite different.
For these archs, wouldn't it then be more efficient to use BUG_ON rather than BUG()?
--
Thanks,
Sasha
Powered by blists - more mailing lists