Major stylo search/replace for "One space between keyword and opening bracket."
This commit is contained in:
@@ -45,7 +45,7 @@ netbuf *netbuf_new(void)
|
||||
struct netbuf *buf;
|
||||
|
||||
buf = memp_mallocp(MEMP_NETBUF);
|
||||
if(buf != NULL) {
|
||||
if (buf != NULL) {
|
||||
buf->p = NULL;
|
||||
buf->ptr = NULL;
|
||||
return buf;
|
||||
@@ -57,8 +57,8 @@ netbuf *netbuf_new(void)
|
||||
void
|
||||
netbuf_delete(struct netbuf *buf)
|
||||
{
|
||||
if(buf != NULL) {
|
||||
if(buf->p != NULL) {
|
||||
if (buf != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
buf->p = buf->ptr = NULL;
|
||||
}
|
||||
@@ -70,11 +70,11 @@ void *
|
||||
netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
{
|
||||
/* Deallocate any previously allocated memory. */
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
|
||||
if(buf->p == NULL) {
|
||||
if (buf->p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
buf->ptr = buf->p;
|
||||
@@ -84,7 +84,7 @@ netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
void
|
||||
netbuf_free(struct netbuf *buf)
|
||||
{
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = buf->ptr = NULL;
|
||||
@@ -93,7 +93,7 @@ netbuf_free(struct netbuf *buf)
|
||||
void
|
||||
netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)
|
||||
{
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
|
||||
@@ -119,7 +119,7 @@ netbuf_len(struct netbuf *buf)
|
||||
err_t
|
||||
netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
{
|
||||
if(buf->ptr == NULL) {
|
||||
if (buf->ptr == NULL) {
|
||||
return ERR_BUF;
|
||||
}
|
||||
*dataptr = buf->ptr->payload;
|
||||
@@ -130,11 +130,11 @@ netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
s8_t
|
||||
netbuf_next(struct netbuf *buf)
|
||||
{
|
||||
if(buf->ptr->next == NULL) {
|
||||
if (buf->ptr->next == NULL) {
|
||||
return -1;
|
||||
}
|
||||
buf->ptr = buf->ptr->next;
|
||||
if(buf->ptr->next == NULL) {
|
||||
if (buf->ptr->next == NULL) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -154,19 +154,19 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
|
||||
left = 0;
|
||||
|
||||
if(buf == NULL) {
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This implementation is bad. It should use bcopy
|
||||
instead. */
|
||||
for(p = buf->p; left < len && p != NULL; p = p->next) {
|
||||
if(offset != 0 && offset >= p->len) {
|
||||
if (offset != 0 && offset >= p->len) {
|
||||
offset -= p->len;
|
||||
} else {
|
||||
for(i = offset; i < p->len; ++i) {
|
||||
((char *)dataptr)[left] = ((char *)p->payload)[i];
|
||||
if(++left >= len) {
|
||||
if (++left >= len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -199,13 +199,13 @@ netconn *netconn_new(enum netconn_type t)
|
||||
struct netconn *conn;
|
||||
|
||||
conn = memp_mallocp(MEMP_NETCONN);
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
conn->type = t;
|
||||
conn->pcb.tcp = NULL;
|
||||
|
||||
if((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
memp_freep(MEMP_NETCONN, conn);
|
||||
return NULL;
|
||||
}
|
||||
@@ -239,11 +239,11 @@ netconn_delete(struct netconn *conn)
|
||||
struct api_msg *msg;
|
||||
void *mem;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
@@ -254,9 +254,9 @@ netconn_delete(struct netconn *conn)
|
||||
memp_freep(MEMP_API_MSG, msg);
|
||||
|
||||
/* Drain the recvmbox. */
|
||||
if(conn->recvmbox != SYS_MBOX_NULL) {
|
||||
while(sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||
while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
pbuf_free((struct pbuf *)mem);
|
||||
} else {
|
||||
netbuf_delete((struct netbuf *)mem);
|
||||
@@ -268,8 +268,8 @@ netconn_delete(struct netconn *conn)
|
||||
|
||||
|
||||
/* Drain the acceptmbox. */
|
||||
if(conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
while(sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if (conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
while (sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
netconn_delete((struct netconn *)mem);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ netconn_delete(struct netconn *conn)
|
||||
|
||||
sys_mbox_free(conn->mbox);
|
||||
conn->mbox = SYS_MBOX_NULL;
|
||||
if(conn->sem != SYS_SEM_NULL) {
|
||||
if (conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_free(conn->sem);
|
||||
}
|
||||
/* conn->sem = SYS_SEM_NULL;*/
|
||||
@@ -297,7 +297,7 @@ err_t
|
||||
netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
u16_t *port)
|
||||
{
|
||||
switch(conn->type) {
|
||||
switch (conn->type) {
|
||||
case NETCONN_UDPLITE:
|
||||
case NETCONN_UDPNOCHKSUM:
|
||||
case NETCONN_UDP:
|
||||
@@ -308,7 +308,7 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
*port = conn->pcb.udp->remote_port;
|
||||
break;
|
||||
case NETCONN_TCP:
|
||||
if(conn->pcb.tcp == NULL)
|
||||
if (conn->pcb.tcp == NULL)
|
||||
return ERR_CONN;
|
||||
*addr = (conn->pcb.tcp->remote_ip);
|
||||
*port = conn->pcb.tcp->remote_port;
|
||||
@@ -321,7 +321,7 @@ err_t
|
||||
netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
||||
u16_t *port)
|
||||
{
|
||||
switch(conn->type) {
|
||||
switch (conn->type) {
|
||||
case NETCONN_UDPLITE:
|
||||
case NETCONN_UDPNOCHKSUM:
|
||||
case NETCONN_UDP:
|
||||
@@ -342,18 +342,18 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->type != NETCONN_TCP &&
|
||||
if (conn->type != NETCONN_TCP &&
|
||||
conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_BIND;
|
||||
@@ -373,18 +373,18 @@ netconn_connect(struct netconn *conn, struct ip_addr *addr,
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
|
||||
if(conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
msg->type = API_MSG_CONNECT;
|
||||
@@ -402,11 +402,11 @@ netconn_disconnect(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
msg->type = API_MSG_DISCONNECT;
|
||||
@@ -423,18 +423,18 @@ netconn_listen(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
if (conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
conn->acceptmbox = sys_mbox_new();
|
||||
if(conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
if (conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_LISTEN;
|
||||
@@ -450,7 +450,7 @@ netconn_accept(struct netconn *conn)
|
||||
{
|
||||
struct netconn *newconn;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -470,21 +470,21 @@ netconn_recv(struct netconn *conn)
|
||||
struct pbuf *p;
|
||||
u16_t len;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox == SYS_MBOX_NULL) {
|
||||
conn->err = ERR_CONN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if(conn->pcb.tcp->state == LISTEN) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if (conn->pcb.tcp->state == LISTEN) {
|
||||
conn->err = ERR_CONN;
|
||||
return NULL;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ netconn_recv(struct netconn *conn)
|
||||
|
||||
buf = memp_mallocp(MEMP_NETBUF);
|
||||
|
||||
if(buf == NULL) {
|
||||
if (buf == NULL) {
|
||||
conn->err = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ netconn_recv(struct netconn *conn)
|
||||
|
||||
/* If we are closed, we indicate that we no longer wish to recieve
|
||||
data by setting conn->recvmbox to SYS_MBOX_NULL. */
|
||||
if(p == NULL) {
|
||||
if (p == NULL) {
|
||||
memp_freep(MEMP_NETBUF, buf);
|
||||
sys_mbox_free(conn->recvmbox);
|
||||
conn->recvmbox = SYS_MBOX_NULL;
|
||||
@@ -526,13 +526,13 @@ netconn_recv(struct netconn *conn)
|
||||
buf->fromaddr = NULL;
|
||||
|
||||
/* Let the stack know that we have taken the data. */
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
conn->err = ERR_MEM;
|
||||
return buf;
|
||||
}
|
||||
msg->type = API_MSG_RECV;
|
||||
msg->msg.conn = conn;
|
||||
if(buf != NULL) {
|
||||
if (buf != NULL) {
|
||||
msg->msg.msg.len = buf->p->tot_len;
|
||||
} else {
|
||||
msg->msg.msg.len = 1;
|
||||
@@ -563,15 +563,15 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return conn->err;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
|
||||
@@ -592,22 +592,22 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
struct api_msg *msg;
|
||||
u16_t len;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return conn->err;
|
||||
}
|
||||
|
||||
if(conn->sem == SYS_SEM_NULL) {
|
||||
if (conn->sem == SYS_SEM_NULL) {
|
||||
conn->sem = sys_sem_new(0);
|
||||
if(conn->sem == SYS_SEM_NULL) {
|
||||
if (conn->sem == SYS_SEM_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_WRITE;
|
||||
@@ -615,18 +615,18 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
|
||||
|
||||
conn->state = NETCONN_WRITE;
|
||||
while(conn->err == ERR_OK && size > 0) {
|
||||
while (conn->err == ERR_OK && size > 0) {
|
||||
msg->msg.msg.w.dataptr = dataptr;
|
||||
msg->msg.msg.w.copy = copy;
|
||||
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if(tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||
sys_sem_wait(conn->sem);
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
if(size > tcp_sndbuf(conn->pcb.tcp)) {
|
||||
if (size > tcp_sndbuf(conn->pcb.tcp)) {
|
||||
/* We cannot send more than one send buffer's worth of data at a
|
||||
time. */
|
||||
len = tcp_sndbuf(conn->pcb.tcp);
|
||||
@@ -641,10 +641,10 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
msg->msg.msg.w.len = len;
|
||||
api_msg_post(msg);
|
||||
sys_mbox_fetch(conn->mbox, NULL);
|
||||
if(conn->err == ERR_OK) {
|
||||
if (conn->err == ERR_OK) {
|
||||
dataptr = (void *)((char *)dataptr + len);
|
||||
size -= len;
|
||||
} else if(conn->err == ERR_MEM) {
|
||||
} else if (conn->err == ERR_MEM) {
|
||||
conn->err = ERR_OK;
|
||||
sys_sem_wait(conn->sem);
|
||||
} else {
|
||||
@@ -654,7 +654,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
ret:
|
||||
memp_freep(MEMP_API_MSG, msg);
|
||||
conn->state = NETCONN_NONE;
|
||||
if(conn->sem != SYS_SEM_NULL) {
|
||||
if (conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_free(conn->sem);
|
||||
conn->sem = SYS_SEM_NULL;
|
||||
}
|
||||
@@ -667,10 +667,10 @@ netconn_close(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ netconn_close(struct netconn *conn)
|
||||
msg->msg.conn = conn;
|
||||
api_msg_post(msg);
|
||||
sys_mbox_fetch(conn->mbox, NULL);
|
||||
if(conn->err == ERR_MEM &&
|
||||
if (conn->err == ERR_MEM &&
|
||||
conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_wait(conn->sem);
|
||||
goto again;
|
||||
|
||||
Reference in New Issue
Block a user