tree-wide: make format_ifname() or friends return negative errno on failure

Also,
- drop unnecessary +1 from buffer size, as IF_NAMESIZE or IFNAMSIZ
  includes the nul at the end.
- format_ifname() does not update buffer on failure,
- introduces format_ifname_alloc(), FORMAT_IFNAME(), and their friends.
This commit is contained in:
Yu Watanabe
2021-09-29 03:37:06 +09:00
parent 1641c2b112
commit 01afd0f7f5
13 changed files with 99 additions and 94 deletions
+2 -2
View File
@@ -557,9 +557,9 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
fputs("\t Iface:", stdout);
for (size_t c = 0; c < i->n_netif; c++) {
char name[IF_NAMESIZE+1];
char name[IF_NAMESIZE];
if (format_ifname(i->netif[c], name)) {
if (format_ifname(i->netif[c], name) >= 0) {
fputc(' ', stdout);
fputs(name, stdout);