summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-12-16 11:12:03 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-12-18 09:52:42 +0800
commit072847109936bc0e822f8cf67c31eb62183f0db8 (patch)
tree168ebf7666c721c912d2b3a5c004d27480d47fc6 /ui
parentb955fa07fc256b39caedb311f97fed404a63c8d5 (diff)
downloadtalos-petitboot-072847109936bc0e822f8cf67c31eb62183f0db8.tar.gz
talos-petitboot-072847109936bc0e822f8cf67c31eb62183f0db8.zip
lib/util: Move mac_buf from nc code to util library
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/ncurses/nc-sysinfo.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c
index 1d7bd1e..142c705 100644
--- a/ui/ncurses/nc-sysinfo.c
+++ b/ui/ncurses/nc-sysinfo.c
@@ -127,28 +127,10 @@ static __attribute__((format(printf, 2, 3))) void sysinfo_screen_append_line(
screen->n_lines++;
}
-static void mac_str(struct interface_info *info, char *buf, unsigned int buflen)
+static void if_info_mac_str(struct interface_info *info,
+ char *buf, unsigned int buflen)
{
- unsigned int i;
- char *pos;
-
- assert(buflen > sizeof("unknown"));
-
- if (!info->hwaddr_size || info->hwaddr_size * 3 + 1 > buflen) {
- strcpy(buf, "unknown");
- return;
- }
-
- pos = buf;
-
- for (i = 0; i < info->hwaddr_size; i++) {
- snprintf(pos, 4, "%02x:", info->hwaddr[i]);
- pos += 3;
- }
-
- *(pos - 1) = '\0';
-
- return;
+ return mac_str(info->hwaddr, info->hwaddr_size, buf, buflen);
}
static void sysinfo_screen_populate(struct sysinfo_screen *screen,
@@ -190,7 +172,7 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
struct interface_info *info = sysinfo->interfaces[i];
char macbuf[32];
- mac_str(info, macbuf, sizeof(macbuf));
+ if_info_mac_str(info, macbuf, sizeof(macbuf));
line("%s:", info->name);
line(" MAC: %s", macbuf);
OpenPOWER on IntegriCloud