From 6af868a229169e8735115457132da84c1e54bae6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 26 Jun 2024 13:07:03 +0200 Subject: [PATCH] sd-bus: simplify handling of 'types' in convenience methods The arg types==NULL has different meanings for different functions. Some functions like sd_bus_message_appendv() require a non-null param and treat "" as "no data". Other functions like sd_bus_skip() treat null as "process one item", while the convenience functions treat NULL the same as "". So I think it's reasonable to make the convenience functions handle NULL explicitly, separately from "". That way the logical separation of concerns is clearer, and e.g. sd_bus_message_appendv() handles all non-null strings, while e.g. sd_bus_call_methodv() doesn't look into the string at all. Behaviour is unchanged. --- src/libsystemd/sd-bus/bus-convenience.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c index 14d8073bc90..e9a350bad6e 100644 --- a/src/libsystemd/sd-bus/bus-convenience.c +++ b/src/libsystemd/sd-bus/bus-convenience.c @@ -39,7 +39,7 @@ _public_ int sd_bus_emit_signal_tov( if (r < 0) return r; - if (!isempty(types)) { + if (types) { r = sd_bus_message_appendv(m, types, ap); if (r < 0) return r; @@ -118,7 +118,7 @@ _public_ int sd_bus_call_method_asyncv( if (r < 0) return r; - if (!isempty(types)) { + if (types) { r = sd_bus_message_appendv(m, types, ap); if (r < 0) return r; @@ -174,7 +174,7 @@ _public_ int sd_bus_call_methodv( if (r < 0) goto fail; - if (!isempty(types)) { + if (types) { r = sd_bus_message_appendv(m, types, ap); if (r < 0) goto fail; @@ -229,7 +229,7 @@ _public_ int sd_bus_reply_method_returnv( if (r < 0) return r; - if (!isempty(types)) { + if (types) { r = sd_bus_message_appendv(m, types, ap); if (r < 0) return r; -- 2.47.3