public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 0/8] drop if around WARN_ON
Date: Sun, 04 Nov 2012 16:16:58 +0000	[thread overview]
Message-ID: <alpine.DEB.2.02.1211041708190.1960@localhost6.localdomain6> (raw)
In-Reply-To: <CA+1xoqfa6CMcsjuOQ_QRRK7kGwkFPCVvrS44rk3Xf1S2HFPTow@mail.gmail.com>

On Sun, 4 Nov 2012, Sasha Levin wrote:

> On Sun, Nov 4, 2012 at 10:57 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> On Sun, 4 Nov 2012, Sasha Levin wrote:
>>
>>> Hi Julia,
>>>
>>> On Sat, Nov 3, 2012 at 4:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>>>>
>>>> These patches convert a conditional with a simple test expression and a
>>>> then branch that only calls WARN_ON(1) to just a call to WARN_ON, which
>>>> will test the condition.
>>>>
>>>> // <smpl>
>>>> @@
>>>> expression e;
>>>> @@
>>>>
>>>> (
>>>> if(<+...e(...)...+>) WARN_ON(1);
>>>> |
>>>> - if (e) WARN_ON(1);
>>>> + WARN_ON(e);
>>>> )// </smpl>
>>>
>>>
>>> So this deals with WARN_ON(), are you considering doing the same for
>>> the rest of it's friends?
>>
>>
>> I tried WARN_ON_ONCE, but the pattern never occurred.  Are there others that
>> are worth trying?
>
> Definitely!
>
> Here's the semantic patch I've got:
>
> @@
> expression e;
> @@
>
> (
> - if (e) WARN_ON(1);
> + WARN_ON(e);
> |
> - if (e) WARN_ON_ONCE(1);
> + WARN_ON_ONCE(e);
> |
> - if (e) WARN_ON_SMP(1);
> + WARN_ON_SMP(e);
> |
> - if (e) BUG();
> + BUG_ON(e);
> )
>
> This gave me a really huge patch output.
>
> I can send it out if you think the patch above looks good.

I didn't change any cases where the if test contains a function call.  The 
current definitions of WARN_ON seem to always evaluate the condition 
expression, but I was worried that that might not always be the case.  And 
calling a function (the ones I remember were some kinds of print 
functions) seems like something one might not want buried in the argument 
of a debugging macro.

WARN_ON_SMP is just WARN_ON if CONFIG_SMP is true, but it is just 0 
otherwise.  So in that case it seems important to check that one is not 
throwing away something important.

I remember working on the BUG_ON case several years ago, and other people 
worked on it too, but I guess some are still there...  The current 
definitions of BUG_ON seem to keep the condition, but there are quite a 
few specialized definitions, so someone at some point might make a version 
that does not have that property.

julia


  reply	other threads:[~2012-11-04 16:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03 20:30 [PATCH 0/8] drop if around WARN_ON Julia Lawall
2012-11-03 20:30 ` [PATCH 1/8] fs/btrfs: " Julia Lawall
2012-11-05 15:39   ` David Sterba
2012-11-03 20:30 ` [PATCH 2/8] drivers/scsi/bfa/bfa_svc.c: " Julia Lawall
2012-11-03 20:30 ` [PATCH 3/8] arch/x86/kernel/cpu/mtrr/cleanup.c: " Julia Lawall
2012-11-03 20:30 ` [PATCH 4/8] fs/ext3/inode.c: " Julia Lawall
2012-11-06 23:04   ` Jan Kara
2012-11-03 20:30 ` [PATCH 5/8] drivers/scsi/qla2xxx/qla_nx.c: " Julia Lawall
2012-11-03 20:30 ` [PATCH 6/8] arch/arm/mach-omap2/dpll3xxx.c: " Julia Lawall
2012-12-14 18:53   ` Tony Lindgren
2012-11-03 20:30 ` [PATCH 7/8] drivers/scsi/scsi_transport_fc.c: " Julia Lawall
2012-11-03 20:30 ` [PATCH 8/8] drivers/net/wireless/ath/ath6kl/hif.c: " Julia Lawall
2012-11-16 11:39   ` Kalle Valo
2012-11-04 14:59 ` [PATCH 0/8] " Sasha Levin
2012-11-04 15:57   ` Julia Lawall
2012-11-04 16:00     ` Sasha Levin
2012-11-04 16:16       ` Julia Lawall [this message]
2012-11-05  2:47         ` Sasha Levin

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=alpine.DEB.2.02.1211041708190.1960@localhost6.localdomain6 \
    --to=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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