mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
gtlsbackend: Add missing preconditions for DTLS virtual methods
Make it a bit more obvious when the DTLS methods aren’t implemented by a particular TLS backend; return an invalid type rather than crashing. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=752240
This commit is contained in:
parent
51e852e5d0
commit
52dd98475c
@ -230,14 +230,22 @@ g_tls_backend_get_server_connection_type (GTlsBackend *backend)
|
||||
* Gets the #GType of @backend’s #GDtlsClientConnection implementation.
|
||||
*
|
||||
* Returns: the #GType of @backend’s #GDtlsClientConnection
|
||||
* implementation.
|
||||
* implementation, or %G_TYPE_INVALID if this backend doesn’t support DTLS.
|
||||
*
|
||||
* Since: 2.48
|
||||
*/
|
||||
GType
|
||||
g_tls_backend_get_dtls_client_connection_type (GTlsBackend *backend)
|
||||
{
|
||||
return G_TLS_BACKEND_GET_INTERFACE (backend)->get_dtls_client_connection_type ();
|
||||
GTlsBackendInterface *iface;
|
||||
|
||||
g_return_val_if_fail (G_IS_TLS_BACKEND (backend), G_TYPE_INVALID);
|
||||
|
||||
iface = G_TLS_BACKEND_GET_INTERFACE (backend);
|
||||
if (iface->get_dtls_client_connection_type == NULL)
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return iface->get_dtls_client_connection_type ();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,14 +255,22 @@ g_tls_backend_get_dtls_client_connection_type (GTlsBackend *backend)
|
||||
* Gets the #GType of @backend’s #GDtlsServerConnection implementation.
|
||||
*
|
||||
* Returns: the #GType of @backend’s #GDtlsServerConnection
|
||||
* implementation.
|
||||
* implementation, or %G_TYPE_INVALID if this backend doesn’t support DTLS.
|
||||
*
|
||||
* Since: 2.48
|
||||
*/
|
||||
GType
|
||||
g_tls_backend_get_dtls_server_connection_type (GTlsBackend *backend)
|
||||
{
|
||||
return G_TLS_BACKEND_GET_INTERFACE (backend)->get_dtls_server_connection_type ();
|
||||
GTlsBackendInterface *iface;
|
||||
|
||||
g_return_val_if_fail (G_IS_TLS_BACKEND (backend), G_TYPE_INVALID);
|
||||
|
||||
iface = G_TLS_BACKEND_GET_INTERFACE (backend);
|
||||
if (iface->get_dtls_server_connection_type == NULL)
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return iface->get_dtls_server_connection_type ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user