]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: simplify handling of 'types' in convenience methods
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 26 Jun 2024 11:07:03 +0000 (13:07 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 28 Jun 2024 10:08:19 +0000 (12:08 +0200)
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

index 14d8073bc9026a643b1c9a4e5ec7d9b402dd4ed4..e9a350bad6e547419ccea2b8a845f308aa87bc19 100644 (file)
@@ -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;