summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-24 15:14:09 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-25 16:37:22 +0200
commit0a6c0745681f544508177f9abb93f9d637b2d002 (patch)
treea1f02f1ffb506fa8e14532fc199666104418f756
parent1bcefad91907e134a853430f18689b50e39ac5f7 (diff)
downloadsystemd-0a6c0745681f544508177f9abb93f9d637b2d002.tar.gz
resolved: avoid allocation
While at it, constify the argument.
-rw-r--r--src/resolve/resolved-bus.c3
-rw-r--r--src/resolve/resolved-link-bus.c9
-rw-r--r--src/resolve/resolved-link-bus.h2
-rw-r--r--src/resolve/resolved-resolv-conf.c1
4 files changed, 7 insertions, 8 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index db0f8381ef..920cb92a58 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -12,6 +12,7 @@
#include "resolved-dnssd-bus.h"
#include "resolved-dnssd.h"
#include "resolved-link-bus.h"
+#include "stdio-util.h"
#include "user-util.h"
#include "utf8.h"
@@ -68,7 +69,7 @@ static int reply_query_state(DnsQuery *q) {
rc = dns_rcode_to_string(q->answer_rcode);
if (!rc) {
- sprintf(p, "%i", q->answer_rcode);
+ xsprintf(p, "%i", q->answer_rcode);
rc = p;
}
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c
index b6c1476f5c..fe997cd1e1 100644
--- a/src/resolve/resolved-link-bus.c
+++ b/src/resolve/resolved-link-bus.c
@@ -12,6 +12,7 @@
#include "resolved-bus.h"
#include "resolved-link-bus.h"
#include "resolved-resolv-conf.h"
+#include "stdio-util.h"
#include "strv.h"
#include "user-util.h"
@@ -735,15 +736,13 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void
return 1;
}
-char *link_bus_path(Link *link) {
- _cleanup_free_ char *ifindex = NULL;
- char *p;
+char *link_bus_path(const Link *link) {
+ char *p, ifindex[DECIMAL_STR_MAX(link->ifindex)];
int r;
assert(link);
- if (asprintf(&ifindex, "%i", link->ifindex) < 0)
- return NULL;
+ xsprintf(ifindex, "%i", link->ifindex);
r = sd_bus_path_encode("/org/freedesktop/resolve1/link", ifindex, &p);
if (r < 0)
diff --git a/src/resolve/resolved-link-bus.h b/src/resolve/resolved-link-bus.h
index 671725101e..74068a4777 100644
--- a/src/resolve/resolved-link-bus.h
+++ b/src/resolve/resolved-link-bus.h
@@ -8,7 +8,7 @@
extern const sd_bus_vtable link_vtable[];
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
-char *link_bus_path(Link *link);
+char *link_bus_path(const Link *link);
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error);
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c
index dfc9a948e3..7b487d50c6 100644
--- a/src/resolve/resolved-resolv-conf.c
+++ b/src/resolve/resolved-resolv-conf.c
@@ -334,7 +334,6 @@ static int write_stub_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSet
}
int manager_write_resolv_conf(Manager *m) {
-
_cleanup_ordered_set_free_ OrderedSet *dns = NULL, *domains = NULL;
_cleanup_free_ char *temp_path_uplink = NULL, *temp_path_stub = NULL;
_cleanup_fclose_ FILE *f_uplink = NULL, *f_stub = NULL;