mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
FD_SET: dump NULL-check that hides usage error, dump non-standard FD_SET_VAL
This commit is contained in:
parent
b0917d987a
commit
5ad743e182
@ -1337,19 +1337,19 @@ lwip_selscan(int maxfdp1, fd_set *readset_in, fd_set *writeset_in, fd_set *excep
|
|||||||
/* ... then examine it: */
|
/* ... then examine it: */
|
||||||
/* See if netconn of this socket is ready for read */
|
/* See if netconn of this socket is ready for read */
|
||||||
if (readset_in && FD_ISSET(i, readset_in) && ((lastdata != NULL) || (rcvevent > 0))) {
|
if (readset_in && FD_ISSET(i, readset_in) && ((lastdata != NULL) || (rcvevent > 0))) {
|
||||||
FD_SET_VAL(i, lreadset);
|
FD_SET(i, &lreadset);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
|
||||||
nready++;
|
nready++;
|
||||||
}
|
}
|
||||||
/* See if netconn of this socket is ready for write */
|
/* See if netconn of this socket is ready for write */
|
||||||
if (writeset_in && FD_ISSET(i, writeset_in) && (sendevent != 0)) {
|
if (writeset_in && FD_ISSET(i, writeset_in) && (sendevent != 0)) {
|
||||||
FD_SET_VAL(i, lwriteset);
|
FD_SET(i, &lwriteset);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
|
||||||
nready++;
|
nready++;
|
||||||
}
|
}
|
||||||
/* See if netconn of this socket had an error */
|
/* See if netconn of this socket had an error */
|
||||||
if (exceptset_in && FD_ISSET(i, exceptset_in) && (errevent != 0)) {
|
if (exceptset_in && FD_ISSET(i, exceptset_in) && (errevent != 0)) {
|
||||||
FD_SET_VAL(i, lexceptset);
|
FD_SET(i, &lexceptset);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for exception\n", i));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for exception\n", i));
|
||||||
nready++;
|
nready++;
|
||||||
}
|
}
|
||||||
|
@ -405,15 +405,12 @@ typedef struct ip_mreq {
|
|||||||
#undef FD_SETSIZE
|
#undef FD_SETSIZE
|
||||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||||
#define FDSETSAFESET_VAL(n, p, code) do { \
|
#define FDSETSAFESET(n, p, code) do { \
|
||||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||||
code; }} while(0)
|
code; }} while(0)
|
||||||
#define FDSETSAFESET(n, p, code) do { \
|
#define FDSETSAFEGET(n, p, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||||
if ((p) != NULL) { FDSETSAFESET_VAL(n, p, code); }} while(0)
|
|
||||||
#define FDSETSAFEGET(n, p, code) (((p) != NULL) && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
|
||||||
(code) : 0)
|
(code) : 0)
|
||||||
#define FD_SET(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
#define FD_SET(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||||
#define FD_SET_VAL(n, p) FDSETSAFESET_VAL(n, &(p), (p).fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
|
||||||
#define FD_CLR(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
#define FD_CLR(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||||
#define FD_ISSET(n,p) FDSETSAFEGET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
#define FD_ISSET(n,p) FDSETSAFEGET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||||
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
||||||
@ -425,8 +422,6 @@ typedef struct fd_set
|
|||||||
|
|
||||||
#elif LWIP_SOCKET_OFFSET
|
#elif LWIP_SOCKET_OFFSET
|
||||||
#error LWIP_SOCKET_OFFSET does not work with external FD_SET!
|
#error LWIP_SOCKET_OFFSET does not work with external FD_SET!
|
||||||
#elif !defined(FD_SET_VAL)
|
|
||||||
#define FD_SET_VAL(n, p) FD_SET(n, &(p))
|
|
||||||
#endif /* FD_SET */
|
#endif /* FD_SET */
|
||||||
|
|
||||||
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
||||||
|
Loading…
Reference in New Issue
Block a user