diff options
author | Colin Walters <walters@verbum.org> | 2017-03-23 13:06:07 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-03-30 19:19:54 +0000 |
commit | 305db981d47e4aa417dd90164b1995e008d25757 (patch) | |
tree | 6a391e2627f8969ced1ecc5ff2b2d60c36c03b5a /coccinelle | |
parent | ee626c2654b877f5ae6771933330c381efa7e802 (diff) | |
download | ostree-305db981d47e4aa417dd90164b1995e008d25757.tar.gz |
Add Coccinelle usage: one for blacklisting, one for patch collection
This is inspired by the [Coccinelle](http://coccinelle.lip6.fr/) usage
in systemd. I also took it a bit further and added infrastructure
to have spatches which should never apply. This acts as a blacklist.
The reason to do the latter is that coccinelle is *way* more powerful than the
regular expresssions we have in `make syntax-check`.
I started with blacklisting `g_error_free()` directly. The reason that's bad is
it leaves a dangling pointer.
Closes: #754
Approved by: jlebon
Diffstat (limited to 'coccinelle')
-rw-r--r-- | coccinelle/README.md | 6 | ||||
-rw-r--r-- | coccinelle/newstyle.cocci | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/coccinelle/README.md b/coccinelle/README.md new file mode 100644 index 00000000..60909b1f --- /dev/null +++ b/coccinelle/README.md @@ -0,0 +1,6 @@ +This is a directory of semantic patches +to apply with coccinelle, like the collection in systemd: +https://github.com/systemd/systemd/tree/29f32655842a0712e8db482bcefc4da8908460c8/coccinelle + +See also the tests/coccinelle directory which +has spatches which detect errors. diff --git a/coccinelle/newstyle.cocci b/coccinelle/newstyle.cocci new file mode 100644 index 00000000..7df248c3 --- /dev/null +++ b/coccinelle/newstyle.cocci @@ -0,0 +1,22 @@ +@@ +expression p; +@@ +- glnx_set_error_from_errno (p); +- goto out; ++ return glnx_throw_errno (p); +@@ +expression p; +@@ +- if (!p) +- goto out; ++ if (!p) ++ return FALSE; +@@ +expression p; +@@ +- gboolean ret = FALSE; +... +- ret = TRUE; +- out: +- return ret; ++ return TRUE; |