Changed the expression of LWIP_ERROR to the same as for LWIP_ASSERT

This commit is contained in:
goldsimon 2007-06-22 20:50:21 +00:00
parent 786a7fbaf4
commit bb9e9e5480
10 changed files with 97 additions and 67 deletions

View File

@ -98,7 +98,7 @@ netbuf_delete(struct netbuf *buf)
void *
netbuf_alloc(struct netbuf *buf, u16_t size)
{
LWIP_ERROR("netbuf_alloc: invalid buf", (buf == NULL), return NULL;);
LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;);
/* Deallocate any previously allocated memory. */
if (buf->p != NULL) {
@ -120,7 +120,7 @@ netbuf_alloc(struct netbuf *buf, u16_t size)
void
netbuf_free(struct netbuf *buf)
{
LWIP_ERROR("netbuf_free: invalid buf", (buf == NULL), return;);
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
if (buf->p != NULL) {
pbuf_free(buf->p);
}
@ -139,7 +139,7 @@ netbuf_free(struct netbuf *buf)
err_t
netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size)
{
LWIP_ERROR("netbuf_ref: invalid buf", (buf == NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;);
if (buf->p != NULL) {
pbuf_free(buf->p);
}
@ -163,8 +163,8 @@ netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size)
void
netbuf_chain(struct netbuf *head, struct netbuf *tail)
{
LWIP_ERROR("netbuf_ref: invalid head", (head == NULL), return;);
LWIP_ERROR("netbuf_chain: invalid tail", (tail == NULL), return;);
LWIP_ERROR("netbuf_ref: invalid head", (head != NULL), return;);
LWIP_ERROR("netbuf_chain: invalid tail", (tail != NULL), return;);
pbuf_chain(head->p, tail->p);
head->ptr = head->p;
memp_free(MEMP_NETBUF, tail);
@ -182,9 +182,9 @@ netbuf_chain(struct netbuf *head, struct netbuf *tail)
err_t
netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
{
LWIP_ERROR("netbuf_data: invalid buf", (buf == NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_data: invalid dataptr", (dataptr == NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_data: invalid len", (len == NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_data: invalid dataptr", (dataptr != NULL), return ERR_ARG;);
LWIP_ERROR("netbuf_data: invalid len", (len != NULL), return ERR_ARG;);
if (buf->ptr == NULL) {
return ERR_BUF;
@ -207,7 +207,7 @@ netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
s8_t
netbuf_next(struct netbuf *buf)
{
LWIP_ERROR("netbuf_free: invalid buf", (buf == NULL), return -1;);
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;);
if (buf->ptr->next == NULL) {
return -1;
}
@ -228,7 +228,7 @@ netbuf_next(struct netbuf *buf)
void
netbuf_first(struct netbuf *buf)
{
LWIP_ERROR("netbuf_free: invalid buf", (buf == NULL), return;);
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
buf->ptr = buf->p;
}
@ -248,8 +248,8 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
u16_t left;
u16_t buf_copy_len;
LWIP_ERROR("netbuf_copy_partial: invalid buf", (buf == NULL), return;);
LWIP_ERROR("netbuf_copy_partial: invalid dataptr", (dataptr == NULL), return;);
LWIP_ERROR("netbuf_copy_partial: invalid buf", (buf != NULL), return;);
LWIP_ERROR("netbuf_copy_partial: invalid dataptr", (dataptr != NULL), return;);
left = 0;
@ -410,7 +410,7 @@ netconn_delete(struct netconn *conn)
enum netconn_type
netconn_type(struct netconn *conn)
{
LWIP_ERROR("netconn_type: invalid conn", (conn == NULL), return NETCONN_INVALID;);
LWIP_ERROR("netconn_type: invalid conn", (conn != NULL), return NETCONN_INVALID;);
return conn->type;
}
@ -429,7 +429,7 @@ netconn_type(struct netconn *conn)
err_t
netconn_peer(struct netconn *conn, struct ip_addr *addr, u16_t *port)
{
LWIP_ERROR("netconn_peer: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_peer: invalid conn", (conn != NULL), return ERR_ARG;);
switch (NETCONNTYPE_GROUP(conn->type)) {
case NETCONN_RAW:
/* return an error as connecting is only a helper for upper layers */
@ -463,9 +463,9 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr, u16_t *port)
err_t
netconn_addr(struct netconn *conn, struct ip_addr **addr, u16_t *port)
{
LWIP_ERROR("netconn_addr: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid addr", (addr == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid port", (port == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid conn", (conn != NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid addr", (addr != NULL), return ERR_ARG;);
LWIP_ERROR("netconn_addr: invalid port", (port != NULL), return ERR_ARG;);
switch (NETCONNTYPE_GROUP(conn->type)) {
case NETCONN_RAW:
*addr = &(conn->pcb.raw->local_ip);
@ -498,7 +498,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr, u16_t port)
{
struct api_msg msg;
LWIP_ERROR("netconn_bind: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;);
if (conn->type != NETCONN_TCP && conn->recvmbox == SYS_MBOX_NULL) {
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
@ -527,7 +527,7 @@ netconn_connect(struct netconn *conn, struct ip_addr *addr, u16_t port)
{
struct api_msg msg;
LWIP_ERROR("netconn_connect: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;);
if (conn->recvmbox == SYS_MBOX_NULL) {
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
@ -555,7 +555,7 @@ netconn_disconnect(struct netconn *conn)
{
struct api_msg msg;
LWIP_ERROR("netconn_disconnect: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_disconnect: invalid conn", (conn != NULL), return ERR_ARG;);
msg.function = do_disconnect;
msg.msg.conn = conn;
@ -576,7 +576,7 @@ netconn_listen(struct netconn *conn)
{
struct api_msg msg;
LWIP_ERROR("netconn_listen: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_listen: invalid conn", (conn != NULL), return ERR_ARG;);
msg.function = do_listen;
msg.msg.conn = conn;
@ -595,8 +595,8 @@ netconn_accept(struct netconn *conn)
{
struct netconn *newconn;
LWIP_ERROR("netconn_accept: invalid conn", (conn == NULL), return NULL;);
LWIP_ERROR("netconn_accept: invalid acceptmbox", (conn->acceptmbox == SYS_MBOX_NULL), return NULL;);
LWIP_ERROR("netconn_accept: invalid conn", (conn != NULL), return NULL;);
LWIP_ERROR("netconn_accept: invalid acceptmbox", (conn->acceptmbox != SYS_MBOX_NULL), return NULL;);
#if LWIP_SO_RCVTIMEO
if (sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, conn->recv_timeout)==SYS_ARCH_TIMEOUT) {
@ -627,7 +627,7 @@ netconn_recv(struct netconn *conn)
struct pbuf *p;
u16_t len;
LWIP_ERROR("netconn_recv: invalid conn", (conn == NULL), return NULL;);
LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return NULL;);
if (conn->recvmbox == SYS_MBOX_NULL) {
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
@ -751,7 +751,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
{
struct api_msg msg;
LWIP_ERROR("netconn_send: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_send: invalid conn", (conn != NULL), return ERR_ARG;);
if (conn->err != ERR_OK) {
return conn->err;
@ -779,8 +779,8 @@ netconn_write(struct netconn *conn, const void *dataptr, int size, u8_t copy)
{
struct api_msg msg;
LWIP_ERROR("netconn_write: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_write: invalid conn->type", (conn->type != NETCONN_TCP), return ERR_VAL;);
LWIP_ERROR("netconn_write: invalid conn", (conn != NULL), return ERR_ARG;);
LWIP_ERROR("netconn_write: invalid conn->type", (conn->type == NETCONN_TCP), return ERR_VAL;);
if (conn->err != ERR_OK) {
return conn->err;
@ -810,7 +810,7 @@ netconn_close(struct netconn *conn)
{
struct api_msg msg;
LWIP_ERROR("netconn_close: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_close: invalid conn", (conn != NULL), return ERR_ARG;);
conn->state = NETCONN_CLOSE;
@ -845,7 +845,7 @@ netconn_join_leave_group(struct netconn *conn,
{
struct api_msg msg;
LWIP_ERROR("netconn_join_leave_group: invalid conn", (conn == NULL), return ERR_ARG;);
LWIP_ERROR("netconn_join_leave_group: invalid conn", (conn != NULL), return ERR_ARG;);
if (conn->err != ERR_OK) {
return conn->err;

View File

@ -309,7 +309,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
conn = (struct netconn *)arg;
LWIP_ERROR("accept_function: invalid conn->acceptmbox",
conn->acceptmbox == SYS_MBOX_NULL, return ERR_VAL;);
conn->acceptmbox != SYS_MBOX_NULL, return ERR_VAL;);
newconn = memp_malloc(MEMP_NETCONN);
if (newconn == NULL) {

View File

@ -251,8 +251,8 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
if (!sock)
return -1;
LWIP_ERROR("lwip_bind: invalid address", ((namelen != sizeof(struct sockaddr_in)) ||
((((struct sockaddr_in *)name)->sin_family) != AF_INET)),
LWIP_ERROR("lwip_bind: invalid address", ((namelen == sizeof(struct sockaddr_in)) &&
((((struct sockaddr_in *)name)->sin_family) == AF_INET)),
sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;);
local_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
@ -313,8 +313,8 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
if (!sock)
return -1;
LWIP_ERROR("lwip_connect: invalid address", ((namelen != sizeof(struct sockaddr_in)) &&
((((struct sockaddr_in *)name)->sin_family) != AF_INET)),
LWIP_ERROR("lwip_connect: invalid address", ((namelen == sizeof(struct sockaddr_in)) &&
((((struct sockaddr_in *)name)->sin_family) == AF_INET)),
sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;);
if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) {
@ -541,9 +541,9 @@ lwip_sendto(int s, const void *data, int size, unsigned int flags,
LWIP_ASSERT("lwip_sendto: size must fit in u16_t",
((size >= 0) && (size <= 0xffff)));
LWIP_ERROR("lwip_sendto: invalid address", (((to != NULL) || (tolen != 0)) &&
((tolen != sizeof(struct sockaddr_in)) ||
((((struct sockaddr_in *)to)->sin_family) != AF_INET))),
LWIP_ERROR("lwip_sendto: invalid address", (((to == NULL) && (tolen == 0)) ||
((tolen == sizeof(struct sockaddr_in)) &&
((((struct sockaddr_in *)to)->sin_family) == AF_INET))),
sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;);
#if LWIP_TCPIP_CORE_LOCKING

View File

@ -539,7 +539,7 @@ err_t dhcp_start(struct netif *netif)
struct dhcp *dhcp;
err_t result = ERR_OK;
LWIP_ERROR("netif == NULL", (netif == NULL), return ERR_ARG;);
LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;);
dhcp = netif->dhcp;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
netif->flags &= ~NETIF_FLAG_DHCP;
@ -656,7 +656,7 @@ void dhcp_inform(struct netif *netif)
*/
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
{
LWIP_ERROR("netif == NULL", (netif == NULL), return;);
LWIP_ERROR("netif != NULL", (netif != NULL), return;);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
/* is a DHCP client doing an ARP check? */
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
@ -792,9 +792,9 @@ static void dhcp_bind(struct netif *netif)
u32_t timeout;
struct dhcp *dhcp;
struct ip_addr sn_mask, gw_addr;
LWIP_ERROR("dhcp_bind: netif == NULL", (netif == NULL), return;);
LWIP_ERROR("dhcp_bind: netif != NULL", (netif != NULL), return;);
dhcp = netif->dhcp;
LWIP_ERROR("dhcp_bind: dhcp == NULL", (dhcp == NULL), return;);
LWIP_ERROR("dhcp_bind: dhcp != NULL", (dhcp != NULL), return;);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
/* temporary DHCP lease? */
@ -1026,7 +1026,7 @@ err_t dhcp_release(struct netif *netif)
void dhcp_stop(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
LWIP_ERROR("dhcp_stop: netif == NULL", (netif == NULL), return;);
LWIP_ERROR("dhcp_stop: netif != NULL", (netif != NULL), return;);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_stop()\n"));
/* netif is DHCP configured? */
@ -1116,9 +1116,9 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
u8_t *ptr;
u16_t i;
u16_t j = 0;
LWIP_ERROR("dhcp == NULL", (dhcp == NULL), return ERR_ARG;);
LWIP_ERROR("dhcp != NULL", (dhcp != NULL), return ERR_ARG;);
p = dhcp->p;
LWIP_ERROR("dhcp->p == NULL", (dhcp->p == NULL), return ERR_VAL;);
LWIP_ERROR("dhcp->p != NULL", (dhcp->p != NULL), return ERR_VAL;);
/* free any left-overs from previous unfolds */
dhcp_free_reply(dhcp);
/* options present? */
@ -1302,9 +1302,9 @@ static err_t dhcp_create_request(struct netif *netif)
{
struct dhcp *dhcp;
u16_t i;
LWIP_ERROR("dhcp_create_request: netif == NULL", (netif == NULL), return ERR_ARG;);
LWIP_ERROR("dhcp_create_request: netif != NULL", (netif != NULL), return ERR_ARG;);
dhcp = netif->dhcp;
LWIP_ERROR("dhcp_create_request: dhcp == NULL", (dhcp == NULL), return ERR_VAL;);
LWIP_ERROR("dhcp_create_request: dhcp != NULL", (dhcp != NULL), return ERR_VAL;);
LWIP_ASSERT("dhcp_create_request: dhcp->p_out == NULL", dhcp->p_out == NULL);
LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL);
dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM);
@ -1348,9 +1348,9 @@ static err_t dhcp_create_request(struct netif *netif)
static void dhcp_delete_request(struct netif *netif)
{
struct dhcp *dhcp;
LWIP_ERROR("dhcp_create_request: netif == NULL", (netif == NULL), return;);
LWIP_ERROR("dhcp_create_request: netif != NULL", (netif != NULL), return;);
dhcp = netif->dhcp;
LWIP_ERROR("dhcp_create_request: dhcp == NULL", (dhcp == NULL), return;);
LWIP_ERROR("dhcp_create_request: dhcp != NULL", (dhcp != NULL), return;);
LWIP_ASSERT("dhcp_free_msg: dhcp->p_out != NULL", dhcp->p_out != NULL);
LWIP_ASSERT("dhcp_free_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
if (dhcp->p_out != NULL) {
@ -1369,7 +1369,7 @@ static void dhcp_delete_request(struct netif *netif)
static void dhcp_option_trailer(struct dhcp *dhcp)
{
LWIP_ERROR("dhcp_create_request: dhcp == NULL", (dhcp == NULL), return;);
LWIP_ERROR("dhcp_create_request: dhcp != NULL", (dhcp != NULL), return;);
LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL\n", dhcp->msg_out != NULL);
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN);
dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END;

View File

@ -326,7 +326,7 @@ memp_malloc(memp_t type)
struct memp *memp;
SYS_ARCH_DECL_PROTECT(old_level);
LWIP_ERROR("memp_malloc: type >= MEMP_MAX", (type >= MEMP_MAX), return NULL;);
LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
SYS_ARCH_PROTECT(old_level);
#if MEMP_OVERFLOW_CHECK >= 2

View File

@ -72,6 +72,11 @@
#include "lwip/sys.h"
#include "arch/perf.h"
#define PBUF_MEM_USES_PBUF_POOL 1
#define PBUF_POOL_RX_LOW_WATER_MARK 25
static u32_t pbuf_pool_count = PBUF_POOL_SIZE;
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically
aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */
@ -126,6 +131,9 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
struct pbuf *p, *q, *r;
u16_t offset;
s32_t rem_len; /* remaining length */
#if PBUF_MEM_USES_PBUF_POOL
unsigned int is_mem = 0;
#endif
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F")\n", length));
/* determine header offset */
@ -151,13 +159,23 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
}
switch (flag) {
case PBUF_RAM:
is_mem = 1;
/* fall through */
case PBUF_POOL:
/* allocate head of pbuf chain into p */
p = memp_malloc(MEMP_PBUF_POOL);
if(is_mem && (pbuf_pool_count <= PBUF_POOL_RX_LOW_WATER_MARK)) {
p = NULL;
} else {
p = memp_malloc(MEMP_PBUF_POOL);
}
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
if (p == NULL) {
return NULL;
}
#if PBUF_MEM_USES_PBUF_POOL
pbuf_pool_count--;
#endif
p->flags = PBUF_FLAG_POOL;
p->next = NULL;
@ -184,13 +202,20 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
rem_len = length - p->len;
/* any remaining pbufs to be allocated? */
while (rem_len > 0) {
q = memp_malloc(MEMP_PBUF_POOL);
if(is_mem && (pbuf_pool_count <= PBUF_POOL_RX_LOW_WATER_MARK)) {
q = NULL;
} else {
q = memp_malloc(MEMP_PBUF_POOL);
}
if (q == NULL) {
/* free chain so far allocated */
pbuf_free(p);
/* bail out unsuccesfully */
return NULL;
}
#if PBUF_MEM_USES_PBUF_POOL
pbuf_pool_count--;
#endif
q->flags = PBUF_FLAG_POOL;
q->next = NULL;
/* make previous pbuf point to this pbuf */
@ -216,6 +241,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
/*r->next = NULL;*/
break;
#if !PBUF_MEM_USES_PBUF_POOL
case PBUF_RAM:
/* If pbuf is to be allocated in RAM, allocate memory for it. */
p = mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length));
@ -231,6 +257,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
break;
#endif /* !PBUF_MEM_USES_PBUF_POOL */
/* pbuf references existing (non-volatile static constant) ROM payload? */
case PBUF_ROM:
/* pbuf references existing (externally allocated) RAM payload? */
@ -366,7 +393,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment)
if (header_size_increment < 0){
increment_magnitude = -header_size_increment;
/* Check that we aren't going to move off the end of the pbuf */
LWIP_ERROR("increment_magnitude > p->len", (increment_magnitude > p->len), return 1;);
LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;);
} else {
increment_magnitude = header_size_increment;
#if 0
@ -504,6 +531,9 @@ pbuf_free(struct pbuf *p)
/* is this a pbuf from the pool? */
if (flags == PBUF_FLAG_POOL) {
memp_free(MEMP_PBUF_POOL, p);
#if PBUF_MEM_USES_PBUF_POOL
pbuf_pool_count++;
#endif
/* is this a ROM or RAM referencing pbuf? */
} else if (flags == PBUF_FLAG_ROM || flags == PBUF_FLAG_REF) {
memp_free(MEMP_PBUF, p);
@ -580,8 +610,8 @@ pbuf_cat(struct pbuf *h, struct pbuf *t)
{
struct pbuf *p;
LWIP_ERROR("(h == NULL) || (t == NULL) (programmer violates API)",
((h == NULL) || (t == NULL)), return;);
LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)",
((h != NULL) && (t != NULL)), return;);
/* proceed to last pbuf of chain */
for (p = h; p->next != NULL; p = p->next) {
@ -693,8 +723,8 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 3, ("pbuf_copy(%p, %p)\n", p_to, p_from));
/* is the target big enough to hold the source? */
LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to == NULL) ||
(p_from == NULL) || (p_to->tot_len < p_from->tot_len)), return ERR_ARG;);
LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) &&
(p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;);
#ifdef LWIP_DEBUG
shouldbe = p_from->tot_len;
#endif
@ -733,12 +763,12 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
if((p_from != NULL) && (p_from->len == p_from->tot_len)) {
/* don't copy more than one packet! */
LWIP_ERROR("pbuf_copy() does not allow packet queues!\n",
(p_from->next != NULL), return ERR_VAL;);
(p_from->next == NULL), return ERR_VAL;);
}
if((p_to != NULL) && (p_to->len == p_to->tot_len)) {
/* don't copy more than one packet! */
LWIP_ERROR("pbuf_copy() does not allow packet queues!\n",
(p_to->next != NULL), return ERR_VAL;);
(p_to->next == NULL), return ERR_VAL;);
}
} while (p_from);
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE | 1, ("pbuf_copy: end of chain reached.\n"));

View File

@ -137,10 +137,10 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%"U16_F", flags=%"X16_F", copy=%"U16_F")\n",
(void *)pcb, arg, len, (u16_t)flags, (u16_t)copy));
LWIP_ERROR("tcp_enqueue: len != 0 && optlen != 0 (programmer violates API)",
(len != 0 && optlen != 0), return ERR_ARG;);
LWIP_ERROR("tcp_enqueue: arg != NULL && optdata != NULL (programmer violates API)",
(arg != NULL && optdata != NULL), return ERR_ARG;);
LWIP_ERROR("tcp_enqueue: len == 0 || optlen == 0 (programmer violates API)",
((len == 0) || (optlen == 0)), return ERR_ARG;);
LWIP_ERROR("tcp_enqueue: arg == NULL || optdata == NULL (programmer violates API)",
((arg == NULL) || (optdata == NULL)), return ERR_ARG;);
/* fail on too much data */
if (len > pcb->snd_buf) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", len, pcb->snd_buf));

View File

@ -69,7 +69,7 @@
/** print "m" message only if "e" is true, and execute "h" expression */
#ifndef LWIP_ERROR
#define LWIP_ERROR(m,e,h) do { if (e) { LWIP_PLATFORM_ASSERT(m); h;}} while(0)
#define LWIP_ERROR(m,e,h) do { if (!(e)) { LWIP_PLATFORM_ASSERT(m); h;}} while(0)
#endif /* LWIP_ERROR */
#ifdef LWIP_DEBUG

View File

@ -516,7 +516,7 @@ void
etharp_ip_input(struct netif *netif, struct pbuf *p)
{
struct ethip_hdr *hdr;
LWIP_ERROR("netif == NULL", (netif == NULL), return;);
LWIP_ERROR("netif != NULL", (netif != NULL), return;);
/* Only insert an entry if the source IP address of the
incoming IP packet comes from a host on the local network. */
hdr = p->payload;
@ -558,7 +558,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
u8_t i;
u8_t for_us;
LWIP_ERROR("netif == NULL", (netif == NULL), return;);
LWIP_ERROR("netif != NULL", (netif != NULL), return;);
/* drop short ARP packets */
if (p->tot_len < sizeof(struct etharp_hdr)) {

View File

@ -64,7 +64,7 @@ loopif_poll(struct netif *netif)
struct pbuf *in = NULL;
struct loopif_private *priv = (struct loopif_private*)netif->state;
LWIP_ERROR("priv == NULL", (priv == NULL), return;);
LWIP_ERROR("priv != NULL", (priv != NULL), return;);
do {
/* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */