mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
Remove the unnecessary cast for main_t, NULL and argv
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
d6f787afca
commit
b659f0fbdf
100 changed files with 559 additions and 449 deletions
|
|
@ -110,7 +110,7 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd)
|
|||
/* Read data from the socket */
|
||||
|
||||
#ifdef FIONBIO
|
||||
for (;;)
|
||||
for (; ; )
|
||||
#endif
|
||||
{
|
||||
printf("lo_listener: Read data from sd=%d\n", sd);
|
||||
|
|
@ -135,7 +135,7 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd)
|
|||
}
|
||||
else
|
||||
{
|
||||
nls->buffer[ret]='\0';
|
||||
nls->buffer[ret] = '\0';
|
||||
printf("lo_listener: Read '%s' (%d bytes)\n", nls->buffer, ret);
|
||||
|
||||
/* Echo the data back to the client */
|
||||
|
|
@ -147,9 +147,10 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd)
|
|||
{
|
||||
if (errno != EINTR)
|
||||
{
|
||||
printf("lo_listener: Send failed sd=%d: %d\n", sd, errno);
|
||||
net_closeclient(nls, sd);
|
||||
return false;
|
||||
printf("lo_listener: Send failed sd=%d: %d\n",
|
||||
sd, errno);
|
||||
net_closeclient(nls, sd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -175,10 +176,11 @@ static inline bool net_connection(struct net_listener_s *nls)
|
|||
/* Loop until all connections have been processed */
|
||||
|
||||
#ifdef FIONBIO
|
||||
for (;;)
|
||||
for (; ; )
|
||||
#endif
|
||||
{
|
||||
printf("lo_listener: Accepting new connection on sd=%d\n", nls->listensd);
|
||||
printf("lo_listener: Accepting new connection on sd=%d\n",
|
||||
nls->listensd);
|
||||
|
||||
sd = accept(nls->listensd, NULL, NULL);
|
||||
if (sd < 0)
|
||||
|
|
@ -231,7 +233,8 @@ static inline bool net_mksocket(struct net_listener_s *nls)
|
|||
/* Configure the socket */
|
||||
|
||||
value = 1;
|
||||
ret = setsockopt(nls->listensd, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int));
|
||||
ret = setsockopt(nls->listensd, SOL_SOCKET,
|
||||
SO_REUSEADDR, &value, sizeof(int));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("lo_listener: setsockopt failed: %d\n", errno);
|
||||
|
|
@ -257,7 +260,8 @@ static inline bool net_mksocket(struct net_listener_s *nls)
|
|||
nls->addr.sin_family = AF_INET;
|
||||
nls->addr.sin_port = htons(LISTENER_PORT);
|
||||
nls->addr.sin_addr.s_addr = htonl(LO_ADDRESS);
|
||||
ret = bind(nls->listensd, (struct sockaddr *)&nls->addr, sizeof(struct sockaddr_in));
|
||||
ret = bind(nls->listensd, (struct sockaddr *)&nls->addr,
|
||||
sizeof(struct sockaddr_in));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("lo_listener: bind failed: %d\n", errno);
|
||||
|
|
@ -299,7 +303,7 @@ void *lo_listener(pthread_addr_t pvarg)
|
|||
memset(&nls, 0, sizeof(struct net_listener_s));
|
||||
if (!net_mksocket(&nls))
|
||||
{
|
||||
return (void *)(uintptr_t)1;
|
||||
return (void *)(uintptr_t)1;
|
||||
}
|
||||
|
||||
/* Initialize the 'master' file descriptor set */
|
||||
|
|
@ -317,13 +321,14 @@ void *lo_listener(pthread_addr_t pvarg)
|
|||
* on any of the connect sockets.
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
/* Wait on select */
|
||||
|
||||
printf("lo_listener: Calling select(), listener sd=%d\n", nls.listensd);
|
||||
printf("lo_listener: Calling select(), listener sd=%d\n",
|
||||
nls.listensd);
|
||||
memcpy(&nls.working, &nls.master, sizeof(fd_set));
|
||||
ret = select(nls.mxsd + 1, (FAR fd_set*)&nls.working, (FAR fd_set*)NULL, (FAR fd_set*)NULL, &timeout);
|
||||
ret = select(nls.mxsd + 1, &nls.working, NULL, NULL, &timeout);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("lo_listener: select failed: %d\n", errno);
|
||||
|
|
@ -367,7 +372,7 @@ void *lo_listener(pthread_addr_t pvarg)
|
|||
/* Cleanup */
|
||||
|
||||
#if 0 /* Don't get here */
|
||||
for (i = 0; i <= nls.mxsd; +i++)
|
||||
for (i = 0; i <= nls.mxsd; +i++)
|
||||
{
|
||||
if (FD_ISSET(i, &nls.master))
|
||||
{
|
||||
|
|
@ -375,5 +380,6 @@ void *lo_listener(pthread_addr_t pvarg)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL; /* Keeps some compilers from complaining */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue