summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2026-05-21 08:35:50 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2026-05-23 19:18:53 -0700
commit52ccc1b8d38906d9a30ce091a153915bbd85c945 (patch)
treeee08176114b1b61e3e05e6c5016cf0ae2bd4584a
parent17215532dc72cc2de1a1c235a0eba9cbfb05ab8c (diff)
Avoid memsets in pop.c
* lib-src/pop.c (socket_connection): Rewrite memset+assignments to designated initializers.
-rw-r--r--lib-src/pop.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 6fe487e1e21..2a4e9b4dd75 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -975,10 +975,8 @@ static int
socket_connection (char *host, int flags)
{
struct addrinfo *res, *it;
- struct addrinfo hints;
int ret;
struct servent *servent;
- struct sockaddr_in addr;
char found_port = 0;
const char *service;
int sock;
@@ -1012,9 +1010,6 @@ socket_connection (char *host, int flags)
}
#endif
- memset (&addr, 0, sizeof (addr));
- addr.sin_family = AF_INET;
-
/** "kpop" service is never used: look for 20060515 to see why **/
#ifdef KERBEROS
service = (flags & POP_NO_KERBEROS) ? POP_SERVICE : KPOP_SERVICE;
@@ -1022,6 +1017,8 @@ socket_connection (char *host, int flags)
service = POP_SERVICE;
#endif
+ struct sockaddr_in addr = {.sin_family = AF_INET};
+
#ifdef HESIOD
if (! (flags & POP_NO_HESIOD))
{
@@ -1063,10 +1060,12 @@ socket_connection (char *host, int flags)
}
- memset (&hints, 0, sizeof (hints));
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = AF_INET;
+ struct addrinfo hints =
+ {
+ .ai_socktype = SOCK_STREAM,
+ .ai_flags = AI_CANONNAME,
+ .ai_family = AF_INET,
+ };
do
{
ret = getaddrinfo (host, service, &hints, &res);