mirror of
https://github.com/systemd/systemd.git
synced 2024-11-24 02:33:36 +08:00
b3fd7b53ff
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);
21 lines
466 B
Plaintext
21 lines
466 B
Plaintext
/* Statement isomorphisms - replace explicit checks against NULL with a
|
|
* shorter variant, which relies on C's downgrade-to-bool feature.
|
|
* The expression metavariables should be declared as pointers, however,
|
|
* that doesn't work well with complex expressions like:
|
|
* if (UNIT(p)->default_dependencies != NULL)
|
|
*/
|
|
|
|
Statement
|
|
@@
|
|
expression X;
|
|
statement S;
|
|
@@
|
|
if (X == NULL) S => if (!X) S
|
|
|
|
Statement
|
|
@@
|
|
expression X;
|
|
statement S;
|
|
@@
|
|
if (X != NULL) S => if (X) S
|