diff options
Diffstat (limited to '')
-rw-r--r-- | src/journal/journalctl.c | 2 | ||||
-rw-r--r-- | src/network/networkctl.c | 2 | ||||
-rw-r--r-- | src/nss-resolve/nss-resolve.c | 6 | ||||
-rw-r--r-- | src/resolve/resolvectl.c | 8 | ||||
-rw-r--r-- | src/shared/varlink.c | 13 | ||||
-rw-r--r-- | src/shared/varlink.h | 25 | ||||
-rw-r--r-- | src/test/test-varlink-idl.c | 8 | ||||
-rw-r--r-- | src/test/test-varlink.c | 6 | ||||
-rw-r--r-- | src/varlinkctl/varlinkctl.c | 6 |
9 files changed, 47 insertions, 29 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index cc476c30db..817b563bbd 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1934,7 +1934,7 @@ static int simple_varlink_call(const char *option, const char *method) { (void) varlink_set_description(link, "journal"); (void) varlink_set_relative_timeout(link, USEC_INFINITY); - r = varlink_call(link, method, NULL, NULL, &error, NULL); + r = varlink_call(link, method, /* parameters= */ NULL, /* ret_parameters= */ NULL, &error); if (r < 0) return log_error_errno(r, "Failed to execute varlink call: %m"); if (error) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 95e22cd9e3..41b35accf8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -104,7 +104,7 @@ static int check_netns_match(void) { if (r < 0) return log_error_errno(r, "Failed to connect to network service /run/systemd/netif/io.systemd.Network: %m"); - r = varlink_call(vl, "io.systemd.Network.GetNamespaceId", NULL, &reply, NULL, 0); + r = varlink_call(vl, "io.systemd.Network.GetNamespaceId", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL); if (r < 0) return log_error_errno(r, "Failed to issue GetNamespaceId() varlink call: %m"); diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index 822ad4f622..ce8c064004 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -261,7 +261,7 @@ enum nss_status _nss_resolve_gethostbyname4_r( * configuration can distinguish such executed but negative replies from complete failure to * talk to resolved). */ const char *error_id; - r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id, NULL); + r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id); if (r < 0) goto fail; if (!isempty(error_id)) { @@ -423,7 +423,7 @@ enum nss_status _nss_resolve_gethostbyname3_r( goto fail; const char *error_id; - r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id, NULL); + r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id); if (r < 0) goto fail; if (!isempty(error_id)) { @@ -641,7 +641,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r( goto fail; const char* error_id; - r = varlink_call(link, "io.systemd.Resolve.ResolveAddress", cparams, &rparams, &error_id, NULL); + r = varlink_call(link, "io.systemd.Resolve.ResolveAddress", cparams, &rparams, &error_id); if (r < 0) goto fail; if (!isempty(error_id)) { diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index b086a67010..811e0118e9 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -1080,7 +1080,7 @@ static int show_statistics(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m"); - r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpStatistics", NULL, &reply, NULL, 0); + r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpStatistics", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL); if (r < 0) return log_error_errno(r, "Failed to issue DumpStatistics() varlink call: %m"); @@ -1238,7 +1238,7 @@ static int reset_statistics(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m"); - r = varlink_call(vl, "io.systemd.Resolve.Monitor.ResetStatistics", NULL, &reply, NULL, 0); + r = varlink_call(vl, "io.systemd.Resolve.Monitor.ResetStatistics", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL); if (r < 0) return log_error_errno(r, "Failed to issue ResetStatistics() varlink call: %m"); @@ -2972,7 +2972,7 @@ static int verb_show_cache(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m"); - r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpCache", NULL, &reply, NULL, 0); + r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpCache", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL); if (r < 0) return log_error_errno(r, "Failed to issue DumpCache() varlink call: %m"); @@ -3146,7 +3146,7 @@ static int verb_show_server_state(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m"); - r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpServerState", NULL, &reply, NULL, 0); + r = varlink_call(vl, "io.systemd.Resolve.Monitor.DumpServerState", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL); if (r < 0) return log_error_errno(r, "Failed to issue DumpServerState() varlink call: %m"); diff --git a/src/shared/varlink.c b/src/shared/varlink.c index d39db5382d..55e3560aea 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -2153,7 +2153,7 @@ int varlink_observeb(Varlink *v, const char *method, ...) { return varlink_observe(v, method, parameters); } -int varlink_call( +int varlink_call_full( Varlink *v, const char *method, JsonVariant *parameters, @@ -2247,27 +2247,24 @@ int varlink_call( } } -int varlink_callb( +int varlink_callb_ap( Varlink *v, const char *method, JsonVariant **ret_parameters, const char **ret_error_id, - VarlinkReplyFlags *ret_flags, ...) { + VarlinkReplyFlags *ret_flags, + va_list ap) { _cleanup_(json_variant_unrefp) JsonVariant *parameters = NULL; - va_list ap; int r; assert_return(v, -EINVAL); - va_start(ap, ret_flags); r = json_buildv(¶meters, ap); - va_end(ap); - if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); - return varlink_call(v, method, parameters, ret_parameters, ret_error_id, ret_flags); + return varlink_call_full(v, method, parameters, ret_parameters, ret_error_id, ret_flags); } static void varlink_collect_context_free(VarlinkCollectContext *cc) { diff --git a/src/shared/varlink.h b/src/shared/varlink.h index f703391279..a54b1f0381 100644 --- a/src/shared/varlink.h +++ b/src/shared/varlink.h @@ -88,8 +88,29 @@ int varlink_send(Varlink *v, const char *method, JsonVariant *parameters); int varlink_sendb(Varlink *v, const char *method, ...); /* Send method call and wait for reply */ -int varlink_call(Varlink *v, const char *method, JsonVariant *parameters, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags); -int varlink_callb(Varlink *v, const char *method, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags, ...); +int varlink_call_full(Varlink *v, const char *method, JsonVariant *parameters, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags); +static inline int varlink_call(Varlink *v, const char *method, JsonVariant *parameters, JsonVariant **ret_parameters, const char **ret_error_id) { + return varlink_call_full(v, method, parameters, ret_parameters, ret_error_id, NULL); +} +int varlink_callb_ap(Varlink *v, const char *method, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags, va_list ap); +static inline int varlink_callb_full(Varlink *v, const char *method, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags, ...) { + va_list ap; + int r; + + va_start(ap, ret_flags); + r = varlink_callb_ap(v, method, ret_parameters, ret_error_id, ret_flags, ap); + va_end(ap); + return r; +} +static inline int varlink_callb(Varlink *v, const char *method, JsonVariant **ret_parameters, const char **ret_error_id, ...) { + va_list ap; + int r; + + va_start(ap, ret_error_id); + r = varlink_callb_ap(v, method, ret_parameters, ret_error_id, NULL, ap); + va_end(ap); + return r; +} /* Send method call and begin collecting all 'more' replies into an array, finishing when a final reply is sent */ int varlink_collect(Varlink *v, const char *method, JsonVariant *parameters, JsonVariant **ret_parameters, const char **ret_error_id, VarlinkReplyFlags *ret_flags); diff --git a/src/test/test-varlink-idl.c b/src/test/test-varlink-idl.c index 1770cb3c03..d322c02c55 100644 --- a/src/test/test-varlink-idl.c +++ b/src/test/test-varlink-idl.c @@ -344,7 +344,7 @@ TEST(validate_method_call) { JsonVariant *reply = NULL; const char *error_id = NULL; - assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, NULL, + assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, JSON_BUILD_OBJECT( JSON_BUILD_PAIR_UNSIGNED("foo", 8), JSON_BUILD_PAIR_UNSIGNED("bar", 9))) >= 0); @@ -361,7 +361,7 @@ TEST(validate_method_call) { json_variant_dump(expected_reply, JSON_FORMAT_PRETTY_AUTO|JSON_FORMAT_COLOR_AUTO, NULL, NULL); assert_se(json_variant_equal(reply, expected_reply)); - assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, NULL, + assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, JSON_BUILD_OBJECT( JSON_BUILD_PAIR_UNSIGNED("foo", 9), JSON_BUILD_PAIR_UNSIGNED("bar", 8), @@ -370,14 +370,14 @@ TEST(validate_method_call) { assert_se(!error_id); assert_se(json_variant_equal(reply, expected_reply)); - assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, NULL, + assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, JSON_BUILD_OBJECT( JSON_BUILD_PAIR_UNSIGNED("foo", 8), JSON_BUILD_PAIR_UNSIGNED("bar", 9), JSON_BUILD_PAIR_STRING("zzz", "pfft"))) >= 0); assert_se(streq_ptr(error_id, VARLINK_ERROR_INVALID_PARAMETER)); - assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, NULL, + assert_se(varlink_callb(v, "xyz.TestMethod", &reply, &error_id, JSON_BUILD_OBJECT( JSON_BUILD_PAIR_STRING("foo", "wuff"), JSON_BUILD_PAIR_UNSIGNED("bar", 9))) >= 0); diff --git a/src/test/test-varlink.c b/src/test/test-varlink.c index 2617ed0e1a..b0b244e917 100644 --- a/src/test/test-varlink.c +++ b/src/test/test-varlink.c @@ -265,7 +265,7 @@ static void *thread(void *arg) { } assert_se(x == 6); - assert_se(varlink_call(c, "io.test.DoSomething", i, &o, &e, NULL) >= 0); + assert_se(varlink_call(c, "io.test.DoSomething", i, &o, &e) >= 0); assert_se(json_variant_integer(json_variant_by_key(o, "sum")) == 88 + 99); assert_se(!e); @@ -281,7 +281,7 @@ static void *thread(void *arg) { assert_se(varlink_push_fd(c, fd2) == 1); assert_se(varlink_push_fd(c, fd3) == 2); - assert_se(varlink_callb(c, "io.test.PassFD", &o, &e, NULL, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("fd", JSON_BUILD_STRING("whoop")))) >= 0); + assert_se(varlink_callb(c, "io.test.PassFD", &o, &e, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("fd", JSON_BUILD_STRING("whoop")))) >= 0); int fd4 = varlink_peek_fd(c, 0); int fd5 = varlink_peek_fd(c, 1); @@ -292,7 +292,7 @@ static void *thread(void *arg) { test_fd(fd4, "miau", 4); test_fd(fd5, "wuff", 4); - assert_se(varlink_callb(c, "io.test.IDontExist", &o, &e, NULL, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("x", JSON_BUILD_REAL(5.5)))) >= 0); + assert_se(varlink_callb(c, "io.test.IDontExist", &o, &e, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("x", JSON_BUILD_REAL(5.5)))) >= 0); assert_se(streq_ptr(json_variant_string(json_variant_by_key(o, "method")), "io.test.IDontExist")); assert_se(streq(e, VARLINK_ERROR_METHOD_NOT_FOUND)); diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 64105c7ab2..9c8a8d9710 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -211,7 +211,7 @@ static int verb_info(int argc, char *argv[], void *userdata) { JsonVariant *reply = NULL; const char *error = NULL; - r = varlink_call(vl, "org.varlink.service.GetInfo", NULL, &reply, &error, NULL); + r = varlink_call(vl, "org.varlink.service.GetInfo", /* parameters= */ NULL, &reply, &error); if (r < 0) return log_error_errno(r, "Failed to issue GetInfo() call: %m"); if (error) @@ -297,7 +297,7 @@ static int verb_introspect(int argc, char *argv[], void *userdata) { JsonVariant *reply = NULL; const char *error = NULL; - r = varlink_callb(vl, "org.varlink.service.GetInterfaceDescription", &reply, &error, NULL, JSON_BUILD_OBJECT(JSON_BUILD_PAIR_STRING("interface", interface))); + r = varlink_callb(vl, "org.varlink.service.GetInterfaceDescription", &reply, &error, JSON_BUILD_OBJECT(JSON_BUILD_PAIR_STRING("interface", interface))); if (r < 0) return log_error_errno(r, "Failed to issue GetInterfaceDescription() call: %m"); if (error) @@ -432,7 +432,7 @@ static int verb_call(int argc, char *argv[], void *userdata) { JsonVariant *reply = NULL; const char *error = NULL; - r = varlink_call(vl, method, jp, &reply, &error, NULL); + r = varlink_call(vl, method, jp, &reply, &error); if (r < 0) return log_error_errno(r, "Failed to issue %s() call: %m", method); |