UDP Networking: Fix unitialized variable problem found by Coverity

This commit is contained in:
Gregory Nutt 2017-09-13 12:12:57 -06:00
parent 15784ca46f
commit 80412df0b1
1 changed files with 6 additions and 2 deletions

View File

@ -231,7 +231,7 @@ static uint16_t udp_select_port(uint8_t domain, FAR union ip_binding_u *u)
g_last_udp_port = 4096; g_last_udp_port = 4096;
} }
} }
while (udp_find_conn(domain, u, htons(g_last_udp_port))); while (udp_find_conn(domain, u, htons(g_last_udp_port)) != NULL);
/* Initialize and return the connection structure, bind it to the /* Initialize and return the connection structure, bind it to the
* port number * port number
@ -661,13 +661,17 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
/* Is any other UDP connection already bound to this address and port? */ /* Is any other UDP connection already bound to this address and port? */
if (!udp_find_conn(conn->domain, &conn->u, portno)) if (udp_find_conn(conn->domain, &conn->u, portno) == NULL)
{ {
/* No.. then bind the socket to the port */ /* No.. then bind the socket to the port */
conn->lport = portno; conn->lport = portno;
ret = OK; ret = OK;
} }
else
{
ret = -EADDRINUSE;
}
net_unlock(); net_unlock();
} }