From 7f83151ac0f72bc0244acd27cbb658edf5ab049b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 28 Apr 2022 10:50:08 +0100 Subject: [PATCH] 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 Helps: #1767 --- gio/gsocket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gio/gsocket.c b/gio/gsocket.c index b19a9a373..f22f6b703 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -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)) {