Joe Perches | 9 May 03:17

incomplete spatch transforms?

Hi Julia.

I have a cocci file I'm playing with to do
a conversion of a linux kernel function
compare_ether_addr to ether_addr_equal.

It doesn't transform all the cases and
I can't figure out why.

$ spatch -version
spatch version 1.0.0-rc12 with Python support and with PCRE support

$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
-	!compare_ether_addr(a, b)
+	ether_addr_equal(a, b)

@@
expression a,b;
@@
-	compare_ether_addr(a, b)
+	!ether_addr_equal(a, b)

@@
expression a,b;
@@
-	!ether_addr_equal(a, b) == 0
+	ether_addr_equal(a, b)
(Continue reading)

ron minnich | 6 May 07:46
Picon

replace all use of type with another

I have some code that (wrongly) assuming unsigned long is always 32
bits. Thanks to OSX, not true.

I'd like to replace all cases and declarations with
unsigned long
to
u32int

but I'm not getting it, hints?

ron
Michael Stefaniuc | 26 Apr 13:43
Picon
Favicon

Failure("only handling multi and no when code in a nest expr")

Hello,

I'm stuck with a SmPL problem:
@@
idexpression ret;
@@
 ok(<... ret ...>, ...);
 ... when != ret
*ok
   (<... ret ...>, ...);

spatch --parse-cocci accepts it but when running it I get:
Fatal error: exception Failure("only handling multi and no when code in
a nest expr")
<... ret ...> inside ok() is the culprit.

I'm trying for days to think of a workaround for this (e.g. splitting it
into different rules) but I'm drawing a blank on it.

ok() is the test function/macro in the Wine tests which evaluates its
first arg to see if the test succeeded. The rest of the varargs are the
printf style message in case the test fails. I'm trying to check that a
variable isn't tested in two ok() calls without being modified in
between. The expression in the first arg passed to ok() can be fairly
complex with "ret" showing up multiple times. I've attached some sample
code.

Any ideas?
thanks
bye
(Continue reading)

Julia Lawall | 21 Apr 20:23
Picon
Favicon

[PATCH v2] scripts/coccinelle: sizeof of pointer

From: Julia Lawall <Julia.Lawall <at> lip6.fr>

Signed-off-by: Julia Lawall <Julia.Lawall <at> lip6.fr>

---
v2, with a better subject

 scripts/coccinelle/misc/noderef.cocci |   65 ++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci
new file mode 100644
index 0000000..c170721
--- /dev/null
+++ b/scripts/coccinelle/misc/noderef.cocci
@@ -0,0 +1,65 @@
+/// sizeof when applied to a pointer typed expression gives the size of
+/// the pointer
+///
+// Confidence: High
+// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
+// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: -no_includes -include_headers
+
+virtual org
+virtual report
+virtual context
+virtual patch
(Continue reading)

Julia Lawall | 21 Apr 20:14
Picon
Favicon

[PATCH] scripts/coccinelle: address test is always true

From: Julia Lawall <Julia.Lawall <at> lip6.fr>

Signed-off-by: Julia Lawall <Julia.Lawall <at> lip6.fr>

---
 scripts/coccinelle/misc/ifaddr.cocci |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci
new file mode 100644
index 0000000..3e4089a
--- /dev/null
+++ b/scripts/coccinelle/misc/ifaddr.cocci
@@ -0,0 +1,35 @@
+/// the address of a variable or field is non-zero is likely always to bo
+/// non-zero
+///
+// Confidence: High
+// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
+// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: -no_includes -include_headers
+
+virtual org
+virtual report
+virtual context
+
+@r@
+expression x;
(Continue reading)

Julia Lawall | 21 Apr 20:14
Picon
Favicon

[PATCH] scripts/coccinelle: address test is always true

From: Julia Lawall <Julia.Lawall <at> lip6.fr>

Signed-off-by: Julia Lawall <Julia.Lawall <at> lip6.fr>

---
 scripts/coccinelle/misc/noderef.cocci |   65 ++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci
new file mode 100644
index 0000000..c170721
--- /dev/null
+++ b/scripts/coccinelle/misc/noderef.cocci
@@ -0,0 +1,65 @@
+/// sizeof when applied to a pointer typed expression gives the size of
+/// the pointer
+///
+// Confidence: High
+// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
+// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: -no_includes -include_headers
+
+virtual org
+virtual report
+virtual context
+virtual patch
+
+@depends on patch@
(Continue reading)

SF Markus Elfring | 20 Apr 15:22
Picon

Re: 1.0.0-rc12: Improvements for commit messages?

> If you need differnt information than what is provided, then you can do the diff.
> The main differences of general are given in the mailing list on eachrelease.

I would appreciate if similar and eventually shorter or more appropriate 
information will appear in corresponding commit messages.
https://github.com/coccinelle/coccinelle/commits/

Regards,
Markus
ron minnich | 17 Apr 22:54
Picon

deleting a switch

I'm missing something ...

@@
type T;
statement S;
@@
T intel_crtc_dpms(...){
...
-switch(...)S
...
}

thanks

ron
Michael Stefaniuc | 16 Apr 23:47
Picon
Favicon

#if 0 code removed (regression in rc12)

Hello,

rc12 introduced an interesting regression: when modifying a function all
#if 0 code is removed.

float f;
#if 0
char c;
#endif

int foo(void)
{
    int i = 1;

#if 0
    TRACE("\n");
#endif
    return i;
}

This SmPL code modifies the function foo:
@@ @@
-int
+size_t

and the diff contains
-#if 0
-char c;
-#endif
...
(Continue reading)

Mansour Moufid | 15 Apr 12:11
Picon

size_t array indices

Hello,

If I try to use the size_t type for array indices in a cocci script, I get an error. For example:

foo.cocci:
@@
type T;
identifier x, y;
@@
- T y;
+ size_t y;
  ...
  x[y]

foo.c:
int main(void) {
    int i = 2;
    int x[] = {1,2,3};
    x[i] = 4;
    return 0;
}

$ spatch --sp-file foo.cocci foo.c
size_t 
Fatal error: exception Failure("line 8: bad type for an array index")

But size_t is perfectly valid, and even recommended.[1] I'm not familiar with the Coccinelle code but may I
suggest the attached patch?

Thanks for your time.
(Continue reading)

Jim Cromie | 10 Apr 21:33
Picon

-in_place appears to be broken in -rc12 vanilla config

hi all,

Ive built and installed -rc12 on  fedora & ubuntu boxes, -in_place is
not working.
All uses also had -dir, maybe the combo is problematic.

the distro version on fedora is working, as is Nicolas Palix's package
for ubuntu.
The "apparent" difference is PCRE support, though that doesnt seem
very pertinent.

Also, the /usr/local installation seems to be confused - its reporting -rc7,
which I had installed previously on the fedora box.
IIRC, I saw the same confusion on ubuntu, and deleted
/usr/local/share/coccinelle
to solve that problem.

[jimc <at> groucho linux-2.6]$ uname -a
Linux groucho.jimc.earth 3.3.0-4.fc16.x86_64 #1 SMP Tue Mar 20
18:05:40 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[jimc <at> groucho linux-2.6]$

[jimc <at> groucho linux-2.6]$ which -a spatch
/usr/local/bin/spatch
/usr/bin/spatch

[jimc <at> groucho linux-2.6]$ /usr/bin/spatch -version
spatch version 1.0.0-rc9 with Python support and with PCRE support

[jimc <at> groucho linux-2.6]$ /usr/local/bin/spatch -version
(Continue reading)


Gmane