public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ensure a consistent return value in error case
@ 2012-07-14 16:43 Julia Lawall
  2012-07-14 16:43 ` [PATCH 1/6] drivers/pci/hotplug/cpci_hotplug_core.c: " Julia Lawall
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Julia Lawall @ 2012-07-14 16:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

Typically, the return value desired for the failure of a function with an
integer return value is a negative integer.  In these cases, the return
value is sometimes a negative integer and sometimes 0, due to a subsequent
initialization of the return variable within the loop.

The semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)

//<smpl>
@r exists@
identifier ret;
position p;
constant C;
expression e1,e2,e3,e4;
@@

ret = -C
... when != ret = e1
    when != ret += e1
    when any
if@p (...)
{
  ... when != ret = e2
      when != ret + e2
  return ret;
}
... when any
if (\(ret != 0\|ret < 0\|ret > 0\) || ...)
{
  ...
  return ...;
}
... when != ret = e3
    when != ret += e3
    when any
if@p (...)
{
  ... when != ret = e4
      when != ret += e4
  return ret;
}

@@
identifier r.ret;
position r.p;
statement S;
@@

(
if@p (<+...ret...+>) S
|
*if@p (...) S
)
//</smpl>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-26 15:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-14 16:43 [PATCH 0/6] ensure a consistent return value in error case Julia Lawall
2012-07-14 16:43 ` [PATCH 1/6] drivers/pci/hotplug/cpci_hotplug_core.c: " Julia Lawall
2012-07-14 16:43 ` [PATCH 2/6] drivers/net/can/softing/softing_main.c: " Julia Lawall
2012-07-15 20:21   ` Kurt Van Dijck
2012-07-16  7:34   ` Marc Kleine-Budde
2012-07-14 16:43 ` [PATCH 3/6] arch/arm/mach-netx/xc.c: " Julia Lawall
2012-07-14 16:43 ` [PATCH 4/6] drivers/cpuidle/sysfs.c: " Julia Lawall
2012-07-14 16:43 ` [PATCH 5/6] drivers/pci/hotplug: " Julia Lawall
2012-07-16 15:54   ` Bjorn Helgaas
2012-07-14 16:43 ` [PATCH 6/6] arch/x86/kernel/kdebugfs.c: " Julia Lawall
2012-07-26 15:19   ` [tip:x86/urgent] arch/x86/kernel/kdebugfs.c: Ensure " tip-bot for Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox