diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-29 07:18:41 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-29 07:21:19 +0200 |
commit | 518a66ec082d977b753acaca289e1a2bd9278f6b (patch) | |
tree | 8d16e76b3c2967cfd42446185f6c5e236a0f7c46 /src/network/networkctl.c | |
parent | util: introduce format_ifname() (diff) | |
download | systemd-518a66ec082d977b753acaca289e1a2bd9278f6b.tar.xz systemd-518a66ec082d977b753acaca289e1a2bd9278f6b.zip |
tree-wide: replace if_indextoname() with format_ifname()
Diffstat (limited to 'src/network/networkctl.c')
-rw-r--r-- | src/network/networkctl.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 6eb1b64a98..a7a1a1c62f 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -20,6 +20,7 @@ #include "ether-addr-util.h" #include "fd-util.h" #include "format-table.h" +#include "format-util.h" #include "hwdb-util.h" #include "local-addresses.h" #include "locale-util.h" @@ -499,9 +500,9 @@ static int dump_gateways( /* Show interface name for the entry if we show * entries for all interfaces */ if (ifindex <= 0) { - char name[IF_NAMESIZE+1] = {}; + char name[IF_NAMESIZE+1]; - if (if_indextoname(local[i].ifindex, name)) + if (format_ifname(local[i].ifindex, name)) r = table_add_cell_stringf(table, NULL, "%s on %s", with_description ?: gateway, name); else r = table_add_cell_stringf(table, NULL, "%s on %%%i", with_description ?: gateway, local[i].ifindex); @@ -545,9 +546,9 @@ static int dump_addresses( return r; if (ifindex <= 0) { - char name[IF_NAMESIZE+1] = {}; + char name[IF_NAMESIZE+1]; - if (if_indextoname(local[i].ifindex, name)) + if (format_ifname(local[i].ifindex, name)) r = table_add_cell_stringf(table, NULL, "%s on %s", pretty, name); else r = table_add_cell_stringf(table, NULL, "%s on %%%i", pretty, local[i].ifindex); @@ -1358,7 +1359,6 @@ static int link_delete_send_message(sd_netlink *rtnl, int index) { static int link_delete(int argc, char *argv[], void *userdata) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; _cleanup_set_free_ Set *indexes = NULL; - char ifname[IFNAMSIZ] = ""; int index, r, i; Iterator j; @@ -1383,7 +1383,9 @@ static int link_delete(int argc, char *argv[], void *userdata) { SET_FOREACH(index, indexes, j) { r = link_delete_send_message(rtnl, index); if (r < 0) { - if (if_indextoname(index, ifname)) + char ifname[IF_NAMESIZE + 1]; + + if (format_ifname(index, ifname)) return log_error_errno(r, "Failed to delete interface %s: %m", ifname); else return log_error_errno(r, "Failed to delete interface %d: %m", index); |