#include "resolved-def.h"
#include "resolved-dns-packet.h"
#include "socket-netlink.h"
+#include "stdio-util.h"
#include "string-table.h"
#include "strv.h"
#include "terminal-util.h"
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(link_info_clear) struct link_info link_info = {};
- _cleanup_free_ char *ifi = NULL, *p = NULL;
- char ifname[IF_NAMESIZE + 1] = "";
+ _cleanup_free_ char *p = NULL;
+ char ifi[DECIMAL_STR_MAX(int)], ifname[IF_NAMESIZE + 1] = "";
char **i;
int r;
name = ifname;
}
- if (asprintf(&ifi, "%i", ifindex) < 0)
- return log_oom();
-
+ xsprintf(ifi, "%i", ifindex);
r = sd_bus_path_encode("/org/freedesktop/resolve1/link", ifi, &p);
if (r < 0)
return log_oom();
static int verb_status(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata;
+ _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
int r = 0;
if (argc > 1) {
STRV_FOREACH(ifname, argv + 1) {
int ifindex, q;
- ifindex = resolve_interface(NULL, *ifname);
+ ifindex = resolve_interface(&rtnl, *ifname);
if (ifindex < 0) {
log_warning_errno(ifindex, "Failed to resolve interface \"%s\", ignoring: %m", *ifname);
continue;