mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-09-25 18:23:50 +08:00
minor: coding style
This commit is contained in:
@@ -883,7 +883,8 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
|
||||
#endif /* LWIP_DNS*/
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
void netconn_thread_init(void)
|
||||
void
|
||||
netconn_thread_init(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem == NULL) || !sys_sem_valid(sem)) {
|
||||
@@ -893,7 +894,8 @@ void netconn_thread_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
void netconn_thread_cleanup(void)
|
||||
void
|
||||
netconn_thread_cleanup(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem != NULL) && sys_sem_valid(sem)) {
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
/* netconns are polled once per second (e.g. continue write on memory error) */
|
||||
#define NETCONN_TCP_POLL_INTERVAL 2
|
||||
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) do { if(val) { \
|
||||
#define SET_NONBLOCKING_CONNECT(conn, val) do { if (val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \
|
||||
} else { \
|
||||
(conn)->flags &= ~ NETCONN_FLAG_IN_NONBLOCKING_CONNECT; }} while(0)
|
||||
@@ -106,7 +106,7 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
/* copy the whole packet into new pbufs */
|
||||
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
|
||||
if(q != NULL) {
|
||||
if (q != NULL) {
|
||||
if (pbuf_copy(q, p) != ERR_OK) {
|
||||
pbuf_free(q);
|
||||
q = NULL;
|
||||
@@ -519,7 +519,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_RAW
|
||||
case NETCONN_RAW:
|
||||
msg->conn->pcb.raw = raw_new(msg->msg.n.proto);
|
||||
if(msg->conn->pcb.raw != NULL) {
|
||||
if (msg->conn->pcb.raw != NULL) {
|
||||
raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
|
||||
}
|
||||
break;
|
||||
@@ -527,7 +527,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDP:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
if(msg->conn->pcb.udp != NULL) {
|
||||
if (msg->conn->pcb.udp != NULL) {
|
||||
#if LWIP_UDPLITE
|
||||
if (NETCONNTYPE_ISUDPLITE(msg->conn->type)) {
|
||||
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
|
||||
@@ -543,7 +543,7 @@ pcb_new(struct api_msg_msg *msg)
|
||||
#if LWIP_TCP
|
||||
case NETCONN_TCP:
|
||||
msg->conn->pcb.tcp = tcp_new();
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
setup_tcp(msg->conn);
|
||||
}
|
||||
break;
|
||||
@@ -723,7 +723,7 @@ netconn_drain(struct netconn *conn)
|
||||
while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) {
|
||||
#if LWIP_TCP
|
||||
if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) {
|
||||
if(mem != NULL) {
|
||||
if (mem != NULL) {
|
||||
p = (struct pbuf*)mem;
|
||||
/* pcb might be set to NULL already by err_tcp() */
|
||||
if (conn->pcb.tcp != NULL) {
|
||||
@@ -876,7 +876,7 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
}
|
||||
#endif /* LWIP_SO_LINGER */
|
||||
} else {
|
||||
if(err == ERR_MEM) {
|
||||
if (err == ERR_MEM) {
|
||||
/* Closing failed because of memory shortage */
|
||||
if (netconn_is_nonblocking(conn)) {
|
||||
/* Nonblocking close failed */
|
||||
|
||||
@@ -313,7 +313,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* service location specified, try to resolve */
|
||||
if ((hints != NULL) && (hints->ai_flags & AI_NUMERICHOST)) {
|
||||
/* no DNS lookup, just parse for an address string */
|
||||
if(!ipaddr_aton(nodename, &addr)) {
|
||||
if (!ipaddr_aton(nodename, &addr)) {
|
||||
return EAI_NONAME;
|
||||
}
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
@@ -328,7 +328,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
u8_t type = NETCONN_DNS_IPV4_IPV6;
|
||||
if (ai_family == AF_INET) {
|
||||
type = NETCONN_DNS_IPV4;
|
||||
} else if(ai_family == AF_INET6) {
|
||||
} else if (ai_family == AF_INET6) {
|
||||
type = NETCONN_DNS_IPV6;
|
||||
}
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
@@ -142,7 +142,7 @@ static void sockaddr_to_ipaddr_port(const struct sockaddr* sockaddr, ip_addr_t*
|
||||
#define IS_SOCK_ADDR_ALIGNED(name) ((((mem_ptr_t)(name)) % 4) == 0)
|
||||
|
||||
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype) do { if((optlen) < sizeof(opttype)) { return EINVAL; }}while(0)
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype) do { if ((optlen) < sizeof(opttype)) { return EINVAL; }}while(0)
|
||||
#define LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock, optlen, opttype) do { \
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN(optlen, opttype); \
|
||||
if ((sock)->conn == NULL) { return EINVAL; } }while(0)
|
||||
@@ -635,7 +635,7 @@ lwip_close(int s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sock->conn != NULL) {
|
||||
if (sock->conn != NULL) {
|
||||
is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
|
||||
} else {
|
||||
LWIP_ASSERT("sock->lastdata == NULL", sock->lastdata == NULL);
|
||||
@@ -1702,7 +1702,7 @@ lwip_shutdown(int s, int how)
|
||||
shut_rx = 1;
|
||||
} else if (how == SHUT_WR) {
|
||||
shut_tx = 1;
|
||||
} else if(how == SHUT_RDWR) {
|
||||
} else if (how == SHUT_RDWR) {
|
||||
shut_rx = 1;
|
||||
shut_tx = 1;
|
||||
} else {
|
||||
@@ -2391,7 +2391,7 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct ip_mreq, NETCONN_UDP);
|
||||
inet_addr_to_ipaddr(&if_addr, &imr->imr_interface);
|
||||
inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr);
|
||||
if(optname == IP_ADD_MEMBERSHIP) {
|
||||
if (optname == IP_ADD_MEMBERSHIP) {
|
||||
if (!lwip_socket_register_membership(s, &if_addr, &multi_addr)) {
|
||||
/* cannot track membership (out of memory) */
|
||||
err = ENOMEM;
|
||||
|
||||
@@ -559,11 +559,11 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
|
||||
|
||||
tcpip_init_done = initfunc;
|
||||
tcpip_init_done_arg = arg;
|
||||
if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {
|
||||
if (sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {
|
||||
LWIP_ASSERT("failed to create tcpip_thread mbox", 0);
|
||||
}
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
if(sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
|
||||
if (sys_mutex_new(&lock_tcpip_core) != ERR_OK) {
|
||||
LWIP_ASSERT("failed to create lock_tcpip_core", 0);
|
||||
}
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
Reference in New Issue
Block a user