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:
Philip Withnall 2022-04-28 10:50:08 +01:00
parent c02890645b
commit 7f83151ac0

View File

@ -463,6 +463,8 @@ g_socket_details_from_fd (GSocket *socket)
int value, family;
int errsv;
memset (&address, 0, sizeof (address));
fd = socket->priv->fd;
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
{