From 3708254f3666744b095b17f8ee98ab651b12b4f3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Dec 2017 12:11:13 +0100 Subject: [PATCH 1/2] coccinelle: improve run-coccinelle.sh to take list of scripts to run Let's tweak run-coccinelle.sh to optionally take a list of scripts to run. If not specified, run all scripts, as before. --- coccinelle/run-coccinelle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index fe3aeb68ce..1373b53c5f 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -for SCRIPT in *.cocci ; do +for SCRIPT in ${@-*.cocci} ; do [ "$SCRIPT" = "empty-if.cocci" ] && continue echo "--x-- Processing $SCRIPT --x--" TMPFILE=`mktemp` From a8ea93a5e2a5d6cc2d448a42c265bac2408e0b21 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Dec 2017 12:13:00 +0100 Subject: [PATCH 2/2] core: use empty_to_null() where we can --- coccinelle/empty-to-null.cocci | 5 +++++ src/core/unit.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 coccinelle/empty-to-null.cocci diff --git a/coccinelle/empty-to-null.cocci b/coccinelle/empty-to-null.cocci new file mode 100644 index 0000000000..fbc75b9c34 --- /dev/null +++ b/coccinelle/empty-to-null.cocci @@ -0,0 +1,5 @@ +@@ +expression s; +@@ +- isempty(s) ? NULL : s ++ empty_to_null(s) diff --git a/src/core/unit.c b/src/core/unit.c index ed0cf02678..7af8425707 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3015,8 +3015,8 @@ static int signal_name_owner_changed(sd_bus_message *message, void *userdata, sd return 0; } - old_owner = isempty(old_owner) ? NULL : old_owner; - new_owner = isempty(new_owner) ? NULL : new_owner; + old_owner = empty_to_null(old_owner); + new_owner = empty_to_null(new_owner); if (UNIT_VTABLE(u)->bus_name_owner_change) UNIT_VTABLE(u)->bus_name_owner_change(u, name, old_owner, new_owner);