diff options
Diffstat (limited to 'dev.c')
-rw-r--r-- | dev.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -416,17 +416,9 @@ const char *device_addr2str(const unsigned char *addr, int alen, int type, if (alen == 16 && type == ARPHRD_TUNNEL6) return inet_ntop(AF_INET6, addr, buf, blen); - for (l = 0, i = 0; i < alen; i++) { - if (i == 0) { - snprintf(buf + l, blen, "%02x", addr[i]); - blen -= 2; - l += 2; - } else { - snprintf(buf + l, blen, ":%02x", addr[i]); - blen -= 3; - l += 3; - } - } + snprintf(buf, blen, "%02x", addr[0]); + for (i = 1, l = 2; i < alen && l < blen; i++, l += 3) + snprintf(buf + l, blen - l, ":%02x", addr[i]); return buf; } |