diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-05 15:33:10 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-12 11:36:24 +0100 |
commit | 41b88bb8ad9474b1a215bbc1c730e6ae7e8d4fa9 (patch) | |
tree | 3e2b98b3af558fed2844b7ab48e79f6f2fa80054 | |
parent | sd-bus: extend sd_bus_message_read_strv() to paths and signatures (diff) | |
download | systemd-41b88bb8ad9474b1a215bbc1c730e6ae7e8d4fa9.tar.xz systemd-41b88bb8ad9474b1a215bbc1c730e6ae7e8d4fa9.zip |
sd-bus: standarize on NULL for empty signature in method calls
We would use sometimes "" and sometimes NULL. They are equivalent, so let's use
NULL everywhere, except for a two places in tests.
-rw-r--r-- | src/analyze/analyze.c | 2 | ||||
-rw-r--r-- | src/busctl/busctl.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-objects.c | 89 |
3 files changed, 47 insertions, 48 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index c25d11e0de..72ebd25525 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1277,7 +1277,7 @@ static int dot(int argc, char *argv[], void *userdata) { if (r < 0) return r; - r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, ""); + r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL); if (r < 0) log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r)); diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 7774aeac7c..c577ac2bab 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -442,7 +442,7 @@ static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *p r = sd_bus_call_method(bus, service, path, "org.freedesktop.DBus.Introspectable", "Introspect", - &error, &reply, ""); + &error, &reply, NULL); if (r < 0) { printf("%sFailed to introspect object %s of service %s: %s%s\n", ansi_highlight_red(), @@ -981,7 +981,7 @@ static int introspect(int argc, char **argv, void *userdata) { r = sd_bus_call_method(bus, argv[1], argv[2], "org.freedesktop.DBus.Introspectable", "Introspect", - &error, &reply_xml, ""); + &error, &reply_xml, NULL); if (r < 0) return log_error_errno(r, "Failed to introspect object %s of service %s: %s", argv[2], argv[1], bus_error_message(&error, r)); diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 80d2a5d98b..5ef3f30c70 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -297,8 +297,7 @@ static int client(struct context *c) { assert_se(r >= 0); assert_se(streq(s, "<<<hallo>>>")); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Doesntexist", &error, &reply, ""); assert_se(r < 0); @@ -306,6 +305,12 @@ static int client(struct context *c) { sd_bus_error_free(&error); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Doesntexist", &error, &reply, NULL); /* NULL and "" are equivalent */ + assert_se(r < 0); + assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_METHOD)); + + sd_bus_error_free(&error); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "AlterSomething", &error, &reply, "as", 1, "hallo"); assert_se(r < 0); assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_INVALID_ARGS)); @@ -319,8 +324,7 @@ static int client(struct context *c) { assert_se(r >= 0); assert_se(streq(s, "<<<hallo>>>")); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); r = sd_bus_set_property(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Something", &error, "s", "test"); assert_se(r >= 0); @@ -332,8 +336,7 @@ static int client(struct context *c) { assert_se(r >= 0); assert_se(streq(s, "test")); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); r = sd_bus_set_property(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "AutomaticIntegerProperty", &error, "u", 815); assert_se(r >= 0); @@ -352,8 +355,16 @@ static int client(struct context *c) { assert_se(r >= 0); fputs(s, stdout); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); + + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, NULL); /* NULL and "" are equivalent */ + assert_se(r >= 0); + + r = sd_bus_message_read(reply, "s", &s); + assert_se(r >= 0); + fputs(s, stdout); + + reply = sd_bus_message_unref(reply); r = sd_bus_get_property(bus, "org.freedesktop.systemd.test", "/value/xuzz", "org.freedesktop.systemd.ValueTest", "Value", &error, &reply, "s"); assert_se(r >= 0); @@ -362,66 +373,60 @@ static int client(struct context *c) { assert_se(r >= 0); log_info("read %s", s); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, NULL); assert_se(r >= 0); r = sd_bus_message_read(reply, "s", &s); assert_se(r >= 0); fputs(s, stdout); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, NULL); assert_se(r >= 0); r = sd_bus_message_read(reply, "s", &s); assert_se(r >= 0); fputs(s, stdout); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, NULL); assert_se(r >= 0); r = sd_bus_message_read(reply, "s", &s); assert_se(r >= 0); fputs(s, stdout); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", NULL); assert_se(r >= 0); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", "org.freedesktop.systemd.ValueTest2"); assert_se(r < 0); assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_INTERFACE)); sd_bus_error_free(&error); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, NULL); assert_se(r < 0); assert_se(sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_METHOD)); sd_bus_error_free(&error); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, NULL); assert_se(r >= 0); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.systemd.ValueTest", "NotifyTest", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.systemd.ValueTest", "NotifyTest", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -430,10 +435,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.systemd.ValueTest", "NotifyTest2", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.systemd.ValueTest", "NotifyTest2", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -442,10 +446,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitInterfacesAdded", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitInterfacesAdded", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -454,10 +457,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitInterfacesRemoved", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitInterfacesRemoved", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -466,10 +468,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitObjectAdded", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitObjectAdded", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -478,10 +479,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitObjectRemoved", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "EmitObjectRemoved", &error, NULL, NULL); assert_se(r >= 0); r = sd_bus_process(bus, &reply); @@ -490,10 +490,9 @@ static int client(struct context *c) { assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved")); sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); - sd_bus_message_unref(reply); - reply = NULL; + reply = sd_bus_message_unref(reply); - r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Exit", &error, NULL, ""); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Exit", &error, NULL, NULL); assert_se(r >= 0); sd_bus_flush(bus); |