mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-28 02:20:04 +01:00
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:
parent
17a53f2fc7
commit
7e400a886e
18
glib/guri.c
18
glib/guri.c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user