mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
gsocket: Clear address before filling it
This will probably make no functional difference, but will squash two warnings from scan-build: ``` ../../../../source/glib/gio/gsocket.c:503:14: warning: Assigned value is garbage or undefined [core.uninitialized.Assign] family = address.storage.ss_family; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../source/glib/gio/gsocket.c:527:29: warning: Assigned value is garbage or undefined [core.uninitialized.Assign] socket->priv->family = address.storage.ss_family; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ ``` It seems like a reasonable thing to warn about. Initialising the full union to zero should avoid any possibility of undefined behaviour like that. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1767
This commit is contained in:
@@ -463,6 +463,8 @@ g_socket_details_from_fd (GSocket *socket)
|
|||||||
int value, family;
|
int value, family;
|
||||||
int errsv;
|
int errsv;
|
||||||
|
|
||||||
|
memset (&address, 0, sizeof (address));
|
||||||
|
|
||||||
fd = socket->priv->fd;
|
fd = socket->priv->fd;
|
||||||
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
|
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user