
{"id":7634,"date":"2012-09-12T17:08:41","date_gmt":"2012-09-12T17:08:41","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=7634"},"modified":"2012-09-12T17:08:41","modified_gmt":"2012-09-12T17:08:41","slug":"sematic-patch-using-coccinelle","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2012\/09\/12\/sematic-patch-using-coccinelle\/","title":{"rendered":"semantic patch using coccinelle"},"content":{"rendered":"<h4><u>commandline session<\/u><\/h4>\n<pre>\n$ 4.2.36 26 525---&gt; cat source.c\n #include \n\nint\nmain(int argc, char *argv[])\n    {\n            unsigned int bytes = 1024 * 1024;\n            char *buf;\n\n            \/* allocate memory *\/\n            buf = alloca(bytes);\n\n            return 0;\n    }\n$ 4.2.36 27 526---&gt; cat source.cocci\n@@ expression E; @@\n\n-alloca(E)\n+malloc(E)\n$ 4.2.36 28 527---&gt; spatch --sp-file source.cocci source.c\ninit_defs_builtins: \/usr\/share\/coccinelle\/standard.h\nHANDLING: source.c\ndiff =\n--- source.c\n+++ \/tmp\/cocci-output-9888-dc7b02-source.c\n@@ -7,7 +7,7 @@ main(int argc, char *argv[])\n             char *buf;\n\n             \/* allocate memory *\/\n-            buf = alloca(bytes);\n+            buf = malloc(bytes);\n\n             return 0;\n     }\n$ 4.2.36 29 528---&gt; spatch --sp-file source.cocci source.c -o newsource.c\ninit_defs_builtins: \/usr\/share\/coccinelle\/standard.h\nHANDLING: source.c\ndiff =\n--- source.c\n+++ \/tmp\/cocci-output-9896-231c5d-source.c\n@@ -7,7 +7,7 @@ main(int argc, char *argv[])\n             char *buf;\n\n             \/* allocate memory *\/\n-            buf = alloca(bytes);\n+            buf = malloc(bytes);\n\n             return 0;\n     }\n$ 4.2.36 30 529---&gt;\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>commandline session $ 4.2.36 26 525&#8212;&gt; cat source.c #include int main(int argc, char *argv[]) { unsigned int bytes = 1024 * 1024; char *buf; \/* allocate memory *\/ buf = alloca(bytes); return 0; } $ 4.2.36 27 526&#8212;&gt; cat source.cocci @@ expression E; @@ -alloca(E) +malloc(E) $ 4.2.36 28 527&#8212;&gt; spatch &#8211;sp-file source.cocci source.c init_defs_builtins: &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2012\/09\/12\/sematic-patch-using-coccinelle\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;semantic patch using coccinelle&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7634"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=7634"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/7634\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=7634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=7634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=7634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}