]> git.ipfire.org Git - thirdparty/systemd.git/commit
coccinelle: add explicit statement isomorphisms
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 26 Apr 2019 19:42:16 +0000 (21:42 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 27 Apr 2019 13:26:11 +0000 (15:26 +0200)
commitb3fd7b53ffcdb3d4ed4adaa42c73762a26cc6df8
tree784e9604fec2904f8eba380dc32d1c5246307572
parentaeafd03a2b3d8cd1e5f91d218196578911330f8e
coccinelle: add explicit statement isomorphisms

Coccinelle needs a custom isomorphism file with rules (isomorphisms) how
to correctly rewrite conditions with explicit NULL checks (i.e.
if (ptr == NULL)) to their shorter form (i.e. if (!ptr)). Coccinelle
already contains such isomorphisms in its default .iso file, however,
they're in the opposite direction, which results in useless output from
coccinelle/equals-null.cocci.

With this fix, `spatch` should no longer report patches like:

@@ -628,8 +628,9 @@ static int path_deserialize_item(Unit *u
                 f = path_result_from_string(value);
                 if (f < 0)
                         log_unit_debug(u, "Failed to parse result value: %s", value);
-                else if (f != PATH_SUCCESS)
-                        p->result = f;
+                else {if (f != PATH_SUCCESS)
+                                p->result = f;
+                }

         } else
                 log_unit_debug(u, "Unknown serialization key: %s", key);
coccinelle/run-coccinelle.sh
coccinelle/systemd-definitions.iso [new file with mode: 0644]