Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coccinelle output

Tags:

c

coccinelle

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?

like image 993
fedi Avatar asked Sep 27 '22 09:09

fedi


1 Answers

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

like image 52
fedi Avatar answered Oct 11 '22 15:10

fedi