guri: Refactor error handling in parse_ip_literal()

Having the goto labels at the bottom of a function makes things a little
more readable. This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2020-09-30 17:50:38 +01:00
parent 17a53f2fc7
commit 7e400a886e

View File

@ -466,14 +466,7 @@ parse_ip_literal (const gchar *start,
gchar *addr = NULL;
if (start[length - 1] != ']')
{
bad_ipv6_literal:
g_free (addr);
g_set_error (error, G_URI_ERROR, G_URI_ERROR_BAD_HOST,
_("Invalid IPv6 address %.*s in URI"),
(gint)length, start);
return FALSE;
}
goto bad_ipv6_literal;
addr = g_strndup (start + 1, length - 2);
@ -499,9 +492,18 @@ parse_ip_literal (const gchar *start,
/* Success */
if (out != NULL)
*out = g_steal_pointer (&addr);
g_free (addr);
return TRUE;
bad_ipv6_literal:
g_free (addr);
g_set_error (error, G_URI_ERROR, G_URI_ERROR_BAD_HOST,
_("Invalid IPv6 address %.*s in URI"),
(gint)length, start);
return FALSE;
}
static gboolean