summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/af_link.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ifconfig/af_link.c')
-rw-r--r--sbin/ifconfig/af_link.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c
index e89be23..c96cbd2 100644
--- a/sbin/ifconfig/af_link.c
+++ b/sbin/ifconfig/af_link.c
@@ -58,25 +58,22 @@ link_status(int s __unused, const struct ifaddrs *ifa)
{
/* XXX no const 'cuz LLADDR is defined wrong */
struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr;
- char *ether_format;
- int i;
+ char *ether_format, *format_char;
if (sdl != NULL && sdl->sdl_alen > 0) {
if ((sdl->sdl_type == IFT_ETHER ||
sdl->sdl_type == IFT_L2VLAN ||
sdl->sdl_type == IFT_BRIDGE) &&
- sdl->sdl_alen == ETHER_ADDR_LEN)
+ sdl->sdl_alen == ETHER_ADDR_LEN) {
+ ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
- ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
- for (i = 0; i < strlen(ether_format); i++) {
- if (ether_format[i] == ':')
- ether_format[i] = '-';
- }
- printf("\tether %s\n", ether_format);
- } else
- printf("\tether %s\n",
- ether_ntoa((struct ether_addr *)LLADDR(sdl)));
- else {
+ for (format_char = strchr(ether_format, ':');
+ format_char != NULL;
+ format_char = strchr(ether_format, ':'))
+ *format_char = '-';
+ }
+ printf("\tether %s\n", ether_format);
+ } else {
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
printf("\tlladdr %s\n", link_ntoa(sdl) + n);
OpenPOWER on IntegriCloud