5

I am a beginner in coccinelle and try to run my first example.

Currently I'am following the steps of this article

  1. I created the c file
  2. I created the coccinelle script
  3. I run it using

    $ spatch -sp_file test.cocci test.c
    

In the terminal I got the expected result as mentioned in the article

--- test.c
+++ /tmp/cocci-output-17416-b5450d-test.c
@@ -7,7 +7,7 @@ main(int argc, char *argv[])
         char *buf;

         /* allocate memory */
-        buf = alloca(bytes);
+        buf = malloc(bytes);

         return 0;
 }

However the c file didn't change as expected.

Can any body tell me where can I get the changes made by the script?

alk
  • 69,737
  • 10
  • 105
  • 255
fedi
  • 368
  • 3
  • 7
  • 18

2 Answers2

2

using

spatch --help

I got all the option for the command spatch . So i should use

$ spatch -sp_file test.cocci test.c -o /tmp/newtest.c

the result of runing the patch is in /tmp/newtest.c

fedi
  • 368
  • 3
  • 7
  • 18
2

You can use --in-place option.

So the following should do what you want.

$ spatch -sp_file test.cocci test.c --in-place

Yasushi Shoji
  • 4,028
  • 1
  • 26
  • 47