mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-14 11:38:05 +02: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;
|
gchar *addr = NULL;
|
||||||
|
|
||||||
if (start[length - 1] != ']')
|
if (start[length - 1] != ']')
|
||||||
{
|
goto bad_ipv6_literal;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = g_strndup (start + 1, length - 2);
|
addr = g_strndup (start + 1, length - 2);
|
||||||
|
|
||||||
@ -499,9 +492,18 @@ parse_ip_literal (const gchar *start,
|
|||||||
/* Success */
|
/* Success */
|
||||||
if (out != NULL)
|
if (out != NULL)
|
||||||
*out = g_steal_pointer (&addr);
|
*out = g_steal_pointer (&addr);
|
||||||
|
|
||||||
g_free (addr);
|
g_free (addr);
|
||||||
|
|
||||||
return TRUE;
|
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
|
static gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user