七星输出

fed*_*di 5 c coccinelle

我是 coccinelle 的初学者,并尝试运行我的第一个示例。

目前我正在按照本文的步骤进行操作

  1. 我创建了c文件
  2. 我创建了 coccinelle 脚本
  3. 我运行它使用

    $ spatch -sp_file test.cocci test.c
    
    Run Code Online (Sandbox Code Playgroud)

在终端中,我得到了文章中提到的预期结果

--- 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;
 }
Run Code Online (Sandbox Code Playgroud)

但是,c 文件没有按预期更改。

任何机构都可以告诉我在哪里可以获得脚本所做的更改?

fed*_*di 2

使用

spatch --help
Run Code Online (Sandbox Code Playgroud)

我获得了命令 spatch 的所有选项。所以我应该使用

$ spatch -sp_file test.cocci test.c -o /tmp/newtest.c
Run Code Online (Sandbox Code Playgroud)

运行补丁的结果在/tmp/newtest.c中