From: Zbigniew Jędrzejewski-Szmek Date: Wed, 26 Jun 2024 11:07:03 +0000 (+0200) Subject: sd-bus: simplify handling of 'types' in convenience methods X-Git-Tag: v257-rc1~1021^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6af868a229169e8735115457132da84c1e54bae6;p=thirdparty%2Fsystemd.git 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. --- 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;