public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Tim Hansen <devtimhansen@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"willemb@google.com" <willemb@google.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"soheil@google.com" <soheil@google.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"elena.reshetova@intel.com" <elena.reshetova@intel.com>,
	"tom@quantonium.net" <tom@quantonium.net>,
	"Jason@zx2c4.com" <Jason@zx2c4.com>,
	"fw@strlen.de" <fw@strlen.de>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] net/core: Fix BUG to BUG_ON conditionals.
Date: Mon, 9 Oct 2017 20:26:34 +0000	[thread overview]
Message-ID: <20171009202633.ep5pbi2tlg7dqidz@sasha-lappy> (raw)
In-Reply-To: <20171009171540.lgmk2slq3bdrptxk@ast-mbp.dhcp.thefacebook.com>

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@gmail.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

  reply	other threads:[~2017-10-09 20:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09 15:37 [PATCH v2] net/core: Fix BUG to BUG_ON conditionals Tim Hansen
2017-10-09 17:15 ` Alexei Starovoitov
2017-10-09 20:26   ` Levin, Alexander (Sasha Levin) [this message]
2017-10-09 23:06     ` Alexei Starovoitov
2017-10-09 23:15       ` Levin, Alexander (Sasha Levin)
2017-10-09 23:23         ` Alexei Starovoitov
2017-10-10  1:14           ` Levin, Alexander (Sasha Levin)
2017-10-09 23:17       ` David Miller
2017-10-10 19:32 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2017-10-08 19:17 [PATCH] " Tim Hansen
2017-10-08 20:03 ` [PATCH v2] " Tim Hansen
2017-10-09  4:20   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171009202633.ep5pbi2tlg7dqidz@sasha-lappy \
    --to=alexander.levin@verizon.com \
    --cc=Jason@zx2c4.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devtimhansen@gmail.com \
    --cc=edumazet@google.com \
    --cc=elena.reshetova@intel.com \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=soheil@google.com \
    --cc=tom@quantonium.net \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox