All of lore.kernel.org
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov)
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq
Date: Sun, 27 Dec 2015 01:36:27 +0300	[thread overview]
Message-ID: <567F166B.7030208@cogentembedded.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1512262330430.2070@localhost6.localdomain6>

On 12/27/2015 01:32 AM, Julia Lawall wrote:

>>> The error return value of platform_get_irq seems to often get dropped.
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> ---
>>>
>>> v2: Check for the direct return case also.  Added some mailing lists of
>>> common offenders.
>>>
>>> diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> new file mode 100644
>>> index 0000000..44680d0
>>> --- /dev/null
>>> +++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> @@ -0,0 +1,58 @@
>>> +/// Propagate the return value of platform_get_irq.
>>> +//# Sometimes the return value of platform_get_irq is tested using <= 0,
>>> but 0
>>> +//# might not be an appropriate return value in an error case.
>>> +///
>>> +// Confidence: Moderate
>>> +// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
>>> +// URL: http://coccinelle.lip6.fr/
>>> +// Options: --no-includes --include-headers
>>> +
>>> +virtual context
>>> +virtual org
>>> +virtual report
>>> +
>>> +//
>>> ----------------------------------------------------------------------------
>>> +
>>> + at r depends on context || org || report@
>>> +constant C;
>>> +statement S;
>>> +expression e, ret;
>>> +position j0, j1;
>>> +@@
>>> +
>>> +* e at j0 = platform_get_irq(...);
>>> +(
>>> +if at j1 (...) {
>>> +  ...
>>> +  return -C;
>>> +} else S
>>> +|
>>> +if at j1 (...) {
>>> +  ...
>>> +  ret = -C;
>>> +  ...
>>> +  return ret;
>>> +} else S
>>
>>     Well, this seems to also cover the (e <= 0) checks which do make same sense
>> in the light of Linus considering IRQ0 invalid. So I'd be more specific about
>> the checks here -- 0 should indeed be overridden with something if it's
>> considered invalid.
>
> That's what the limitations section says (lines with #).  This doesn't

    Ah, failed to notice those, only saw after replying.

> make any changes, it only makes warnings, which should include the
> limitations information, so perhaps people can consider what it is that
> they really intend to do.
 >
> If you think this is not a good idea, then I can make the test more
> specific.

    Well, looking again, the patch should be good. I just thought its goal was 
to fix the code as well...

> julia

MBR, Sergei

WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: cocci@systeme.lip6.fr
Subject: Re: [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq
Date: Sat, 26 Dec 2015 22:36:27 +0000	[thread overview]
Message-ID: <567F166B.7030208@cogentembedded.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1512262330430.2070@localhost6.localdomain6>

On 12/27/2015 01:32 AM, Julia Lawall wrote:

>>> The error return value of platform_get_irq seems to often get dropped.
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> ---
>>>
>>> v2: Check for the direct return case also.  Added some mailing lists of
>>> common offenders.
>>>
>>> diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> new file mode 100644
>>> index 0000000..44680d0
>>> --- /dev/null
>>> +++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> @@ -0,0 +1,58 @@
>>> +/// Propagate the return value of platform_get_irq.
>>> +//# Sometimes the return value of platform_get_irq is tested using <= 0,
>>> but 0
>>> +//# might not be an appropriate return value in an error case.
>>> +///
>>> +// Confidence: Moderate
>>> +// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
>>> +// URL: http://coccinelle.lip6.fr/
>>> +// Options: --no-includes --include-headers
>>> +
>>> +virtual context
>>> +virtual org
>>> +virtual report
>>> +
>>> +//
>>> ----------------------------------------------------------------------------
>>> +
>>> +@r depends on context || org || report@
>>> +constant C;
>>> +statement S;
>>> +expression e, ret;
>>> +position j0, j1;
>>> +@@
>>> +
>>> +* e@j0 = platform_get_irq(...);
>>> +(
>>> +if@j1 (...) {
>>> +  ...
>>> +  return -C;
>>> +} else S
>>> +|
>>> +if@j1 (...) {
>>> +  ...
>>> +  ret = -C;
>>> +  ...
>>> +  return ret;
>>> +} else S
>>
>>     Well, this seems to also cover the (e <= 0) checks which do make same sense
>> in the light of Linus considering IRQ0 invalid. So I'd be more specific about
>> the checks here -- 0 should indeed be overridden with something if it's
>> considered invalid.
>
> That's what the limitations section says (lines with #).  This doesn't

    Ah, failed to notice those, only saw after replying.

> make any changes, it only makes warnings, which should include the
> limitations information, so perhaps people can consider what it is that
> they really intend to do.
 >
> If you think this is not a good idea, then I can make the test more
> specific.

    Well, looking again, the patch should be good. I just thought its goal was 
to fix the code as well...

> julia

MBR, Sergei


WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <mmarek@suse.com>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, netdev@vger.kernel.org,
	linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org,
	dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq
Date: Sun, 27 Dec 2015 01:36:27 +0300	[thread overview]
Message-ID: <567F166B.7030208@cogentembedded.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1512262330430.2070@localhost6.localdomain6>

On 12/27/2015 01:32 AM, Julia Lawall wrote:

>>> The error return value of platform_get_irq seems to often get dropped.
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> ---
>>>
>>> v2: Check for the direct return case also.  Added some mailing lists of
>>> common offenders.
>>>
>>> diff --git a/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> new file mode 100644
>>> index 0000000..44680d0
>>> --- /dev/null
>>> +++ b/scripts/coccinelle/api/platform_get_irq_return.cocci
>>> @@ -0,0 +1,58 @@
>>> +/// Propagate the return value of platform_get_irq.
>>> +//# Sometimes the return value of platform_get_irq is tested using <= 0,
>>> but 0
>>> +//# might not be an appropriate return value in an error case.
>>> +///
>>> +// Confidence: Moderate
>>> +// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
>>> +// URL: http://coccinelle.lip6.fr/
>>> +// Options: --no-includes --include-headers
>>> +
>>> +virtual context
>>> +virtual org
>>> +virtual report
>>> +
>>> +//
>>> ----------------------------------------------------------------------------
>>> +
>>> +@r depends on context || org || report@
>>> +constant C;
>>> +statement S;
>>> +expression e, ret;
>>> +position j0, j1;
>>> +@@
>>> +
>>> +* e@j0 = platform_get_irq(...);
>>> +(
>>> +if@j1 (...) {
>>> +  ...
>>> +  return -C;
>>> +} else S
>>> +|
>>> +if@j1 (...) {
>>> +  ...
>>> +  ret = -C;
>>> +  ...
>>> +  return ret;
>>> +} else S
>>
>>     Well, this seems to also cover the (e <= 0) checks which do make same sense
>> in the light of Linus considering IRQ0 invalid. So I'd be more specific about
>> the checks here -- 0 should indeed be overridden with something if it's
>> considered invalid.
>
> That's what the limitations section says (lines with #).  This doesn't

    Ah, failed to notice those, only saw after replying.

> make any changes, it only makes warnings, which should include the
> limitations information, so perhaps people can consider what it is that
> they really intend to do.
 >
> If you think this is not a good idea, then I can make the test more
> specific.

    Well, looking again, the patch should be good. I just thought its goal was 
to fix the code as well...

> julia

MBR, Sergei

  reply	other threads:[~2015-12-26 22:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-26 19:24 [Cocci] [PATCH] coccinelle: api: check for propagation of error from platform_get_irq Julia Lawall
2015-12-26 19:24 ` Julia Lawall
2015-12-26 19:24 ` Julia Lawall
2015-12-26 19:59 ` [Cocci] " Sergei Shtylyov
2015-12-26 19:59   ` Sergei Shtylyov
2015-12-26 19:59   ` Sergei Shtylyov
2015-12-26 20:08   ` [Cocci] " Julia Lawall
2015-12-26 20:08     ` Julia Lawall
2015-12-26 20:08     ` Julia Lawall
2015-12-26 20:24     ` [Cocci] " Julia Lawall
2015-12-26 20:24       ` Julia Lawall
2015-12-26 20:24       ` Julia Lawall
2015-12-26 20:29       ` [Cocci] " Sergei Shtylyov
2015-12-26 20:29         ` Sergei Shtylyov
2015-12-26 20:29         ` Sergei Shtylyov
2015-12-26 20:38         ` [Cocci] " Julia Lawall
2015-12-26 20:38           ` Julia Lawall
2015-12-26 20:38           ` Julia Lawall
2015-12-26 20:58         ` [Cocci] [PATCH v2] " Julia Lawall
2015-12-26 20:58           ` Julia Lawall
2015-12-26 20:58           ` Julia Lawall
2015-12-26 22:26           ` [Cocci] " Sergei Shtylyov
2015-12-26 22:26             ` Sergei Shtylyov
2015-12-26 22:26             ` Sergei Shtylyov
2015-12-26 22:26             ` Sergei Shtylyov
2015-12-26 22:32             ` [Cocci] " Julia Lawall
2015-12-26 22:32               ` Julia Lawall
2015-12-26 22:32               ` Julia Lawall
2015-12-26 22:32               ` Julia Lawall
2015-12-26 22:36               ` Sergei Shtylyov [this message]
2015-12-26 22:36                 ` Sergei Shtylyov
2015-12-26 22:36                 ` Sergei Shtylyov
2015-12-27  6:13                 ` [Cocci] " Julia Lawall
2015-12-27  6:13                   ` Julia Lawall
2015-12-27  6:13                   ` Julia Lawall
2015-12-27  6:13                   ` Julia Lawall
2015-12-27 11:18                   ` [Cocci] " Sergei Shtylyov
2015-12-27 11:18                     ` Sergei Shtylyov
2015-12-27 11:18                     ` Sergei Shtylyov
2015-12-27  7:58           ` [Cocci] " SF Markus Elfring
2015-12-27  7:58             ` SF Markus Elfring
2015-12-27  7:58             ` SF Markus Elfring
2015-12-27  7:58             ` SF Markus Elfring
2015-12-27 11:41             ` Julia Lawall
2015-12-27 11:41               ` Julia Lawall
2015-12-27 11:41               ` Julia Lawall
2015-12-27 11:41               ` Julia Lawall
2015-12-27 16:24               ` SF Markus Elfring
2015-12-27 16:24                 ` SF Markus Elfring
2015-12-27 16:24                 ` SF Markus Elfring
2015-12-27 16:24                 ` SF Markus Elfring

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=567F166B.7030208@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=cocci@systeme.lip6.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.