Let the compiler choose the best way to clear the sockaddr_in structure instead of using memset.
Frederico Lamberti Pissarra committed
May 12, 2016 at 20:45 UTC
bf581ab169aba9f6c517b7f07d8da7406d7cd60e
1 file changed
+1
-4
src/web_server.c
+1
-4
@@ -67,7 +67,6 @@ int create_listen_socket4(const char *ip, int port, int listen_backlog)
67
{
68
int sock;
69
int sockopt = 1;
70
- struct sockaddr_in name;
70
71
debug(D_LISTENER, "IPv4 creating new listening socket on port %d", port);
72
@@ -80,9 +79,7 @@ int create_listen_socket4(const char *ip, int port, int listen_backlog)
79
/* avoid "address already in use" */
80
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&sockopt, sizeof(sockopt));
81
83
- memset(&name, 0, sizeof(struct sockaddr_in));
84
- name.sin_family = AF_INET;
85
- name.sin_port = htons (port);
82
+ struct sockaddr_in name = { .sin_family = AF_INET, .sin_port = htons(port) };
83
84
if(is_ip_anything(ip)) {
85
name.sin_addr.s_addr = htonl(INADDR_ANY);