summaryrefslogtreecommitdiff
path: root/dispatcher
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-04-24 11:20:03 +0200
committerLubomir Rintel <lkundrak@v3.sk>2018-05-10 14:36:58 +0200
commite69d386975be997d3d840de9045e51521ac4474c (patch)
treec240198404e8bdc5396c3e9608d0cc387337abfc /dispatcher
parentf0c1efbf426260c6ed45f3ae83b9a4e2b5a347c4 (diff)
all: use the elvis operator wherever possible
Coccinelle: @@ expression a, b; @@ -a ? a : b +a ?: b Applied with: spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir . With some manual adjustments on spots that Cocci didn't catch for reasons unknown. Thanks to the marvelous effort of the GNU compiler developer we can now spare a couple of bits that could be used for more important things, like this commit message. Standards commitees yet have to catch up.
Diffstat (limited to 'dispatcher')
-rw-r--r--dispatcher/nm-dispatcher.c8
-rw-r--r--dispatcher/tests/test-dispatcher-envp.c2
2 files changed, 4 insertions, 6 deletions
diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c
index ca11523ab..899669530 100644
--- a/dispatcher/nm-dispatcher.c
+++ b/dispatcher/nm-dispatcher.c
@@ -144,7 +144,7 @@ struct Request {
(_request)->request_id, \
(_request)->action, \
(_request)->iface ? " [" : "", \
- (_request)->iface ? (_request)->iface : "", \
+ (_request)->iface ?: "", \
(_request)->iface ? "]" : "", \
(_script) ? ", \"" : "", \
(_script) ? (_script)->script : "", \
@@ -297,7 +297,7 @@ complete_request (Request *request)
g_variant_builder_add (&results, "(sus)",
script->script,
script->result,
- script->error ? script->error : "");
+ script->error ?: "");
}
ret = g_variant_new ("(a(sus))", &results);
@@ -537,9 +537,7 @@ script_dispatch (ScriptInfo *script)
script->dispatched = TRUE;
argv[0] = script->script;
- argv[1] = request->iface
- ? request->iface
- : (!strcmp (request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
+ argv[1] = request->iface ?: (!strcmp(request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
argv[2] = request->action;
argv[3] = NULL;
diff --git a/dispatcher/tests/test-dispatcher-envp.c b/dispatcher/tests/test-dispatcher-envp.c
index 25cd5e60c..936b6e93f 100644
--- a/dispatcher/tests/test-dispatcher-envp.c
+++ b/dispatcher/tests/test-dispatcher-envp.c
@@ -543,7 +543,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
device_dhcp4_props,
device_dhcp6_props,
connectivity_change,
- override_vpn_ip_iface ? override_vpn_ip_iface : vpn_ip_iface,
+ override_vpn_ip_iface ?: vpn_ip_iface,
vpn_proxy_props,
vpn_ip4_props,
vpn_ip6_props,