libnm-core: rewrite nm_utils_hwaddr_ntoa()

Rather than returning from the middle of the loop, just rearrange
things so we can exit the loop like normal people.
This commit is contained in:
Dan Winship 2014-08-06 13:39:53 -04:00
parent 35f36ba4c3
commit 0dcba8a9a0

View file

@ -2060,17 +2060,17 @@ nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length)
g_return_val_if_fail (length > 0 && length <= NM_UTILS_HWADDR_LEN_MAX, g_strdup (""));
result = out = g_malloc (length * 3);
for (;;) {
while (length--) {
guint8 v = *in++;
*out++ = LOOKUP[v >> 4];
*out++ = LOOKUP[v & 0x0F];
if (--length == 0) {
*out = 0;
return result;
}
*out++ = ':';
if (length)
*out++ = ':';
}
*out = 0;
return result;
}
static int