lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 20 Dec 2011 23:24:13 +0100 (CET)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Lars-Peter Clausen <lars@...afoo.de>
cc:	Julia Lawall <julia@...u.dk>,
	Gilles Muller <Gilles.Muller@...6.fr>,
	Nicolas Palix <npalix.work@...il.com>,
	linux-kernel@...r.kernel.org, cocci@...u.dk, mmarek@...e.cz
Subject: Re: [Cocci] [PATCH 2/2] coccinelle: Add patch for replacing open-coded
 IS_ERR_OR_NULL

For this one, I made quite a number of changes, some of which required 
fixing a bug in Coccinelle...  I will try to release the bug fix shortly. 
In general, though, I have added ... between the two tests.  I also got 
rid of the focus on ifs in the org and report rules.

julia

virtual context
virtual patch
virtual org
virtual report

// Since the logical or operator by itself is not commutative we need rules for
// both cases as well as for their De Morgan equivalents.

@depends on context@
expression x;
@@
* IS_ERR(x)
   || ... ||
* x == NULL

@depends on context@
expression x;
@@
* x == NULL
   || ... ||
* IS_ERR(x)

@depends on context@
expression x;
@@
* !IS_ERR(x)
   && ... &&
* x != NULL

@depends on context@
expression x;
@@
* x != NULL
   && ... &&
* !IS_ERR(x)

@depends on patch@
expression x;
@@
- IS_ERR(x)
+ IS_ERR_OR_NULL(x)
   || ...
- || x == NULL

@depends on patch@
expression x;
@@
- x == NULL
+ IS_ERR_OR_NULL(x)
   || ...
- || IS_ERR(x)

@depends on patch@
expression x;
@@
- !IS_ERR(x)
+ !IS_ERR_OR_NULL(x)
   && ...
- && x != NULL

@depends on patch@
expression x;
@@
- x != NULL
+ !IS_ERR_OR_NULL(x)
   && ...
- && !IS_ERR(x)

@r depends on org || report@
expression x;
position p;
@@
(
  IS_ERR@p(x) || ... || x == NULL
|
  x == NULL || ... || IS_ERR@p(x)
|
  !IS_ERR@p(x) && ... && x != NULL
|
  x != NULL && ... && !IS_ERR@p(x)
)

@script:python depends on org@
p << r.p;
x << r.x;
@@

msg="IS_ERR_OR_NULL can be used with %s" % (x)
msg_safe=msg.replace("[","@(").replace("]",")")
coccilib.org.print_todo(p[0], msg_safe)

@script:python depends on report@
p << r.p;
x << r.x;
@@

msg="IS_ERR_OR_NULL can be used with %s" % (x)
coccilib.report.print_report(p[0], msg)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ