From 0dcba8a9a0b9d1dcfff90348bb433d2625489017 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 6 Aug 2014 13:39:53 -0400 Subject: [PATCH] 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. --- libnm-core/nm-utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 649942ade7..3dea14f648 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -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