mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 03:00:29 +01:00
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:
parent
35f36ba4c3
commit
0dcba8a9a0
1 changed files with 6 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue