diff --git a/src/api/netdb.c b/src/api/netdb.c index d1f134ce..3185cfb6 100644 --- a/src/api/netdb.c +++ b/src/api/netdb.c @@ -326,7 +326,8 @@ lwip_getaddrinfo(const char *nodename, const char *servname, if (nodename != NULL) { /* copy nodename to canonname if specified */ size_t namelen = strlen(nodename); - ai->ai_canonname = mem_malloc(namelen + 1); + LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1); + ai->ai_canonname = mem_malloc((mem_size_t)(namelen + 1)); if (ai->ai_canonname == NULL) { goto memerr; } diff --git a/src/core/sys.c b/src/core/sys.c index c5a643b9..d1fbda4e 100644 --- a/src/core/sys.c +++ b/src/core/sys.c @@ -65,7 +65,7 @@ struct sswt_cb void sys_mbox_fetch(sys_mbox_t mbox, void **msg) { - u32_t time; + u32_t time_needed; struct sys_timeouts *timeouts; struct sys_timeo *tmptimeout; sys_timeout_handler h; @@ -76,18 +76,18 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg) if (!timeouts || !timeouts->next) { UNLOCK_TCPIP_CORE(); - time = sys_arch_mbox_fetch(mbox, msg, 0); + time_needed = sys_arch_mbox_fetch(mbox, msg, 0); LOCK_TCPIP_CORE(); } else { if (timeouts->next->time > 0) { UNLOCK_TCPIP_CORE(); - time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); + time_needed = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); LOCK_TCPIP_CORE(); } else { - time = SYS_ARCH_TIMEOUT; + time_needed = SYS_ARCH_TIMEOUT; } - if (time == SYS_ARCH_TIMEOUT) { + if (time_needed == SYS_ARCH_TIMEOUT) { /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message could be fetched. We should now call the timeout handler and deallocate the memory allocated for the timeout. */ @@ -107,8 +107,8 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg) /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout occured. The time variable is set to the number of milliseconds we waited for the message. */ - if (time < timeouts->next->time) { - timeouts->next->time -= time; + if (time_needed < timeouts->next->time) { + timeouts->next->time -= time_needed; } else { timeouts->next->time = 0; } @@ -125,7 +125,7 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg) void sys_sem_wait(sys_sem_t sem) { - u32_t time; + u32_t time_needed; struct sys_timeouts *timeouts; struct sys_timeo *tmptimeout; sys_timeout_handler h; @@ -139,12 +139,12 @@ sys_sem_wait(sys_sem_t sem) sys_arch_sem_wait(sem, 0); } else { if (timeouts->next->time > 0) { - time = sys_arch_sem_wait(sem, timeouts->next->time); + time_needed = sys_arch_sem_wait(sem, timeouts->next->time); } else { - time = SYS_ARCH_TIMEOUT; + time_needed = SYS_ARCH_TIMEOUT; } - if (time == SYS_ARCH_TIMEOUT) { + if (time_needed == SYS_ARCH_TIMEOUT) { /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message could be fetched. We should now call the timeout handler and deallocate the memory allocated for the timeout. */ @@ -164,8 +164,8 @@ sys_sem_wait(sys_sem_t sem) /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout occured. The time variable is set to the number of milliseconds we waited for the message. */ - if (time < timeouts->next->time) { - timeouts->next->time -= time; + if (time_needed < timeouts->next->time) { + timeouts->next->time -= time_needed; } else { timeouts->next->time = 0; } diff --git a/src/include/lwip/debug.h b/src/include/lwip/debug.h index 089a80aa..d5c4e474 100644 --- a/src/include/lwip/debug.h +++ b/src/include/lwip/debug.h @@ -61,26 +61,28 @@ #define LWIP_DBG_HALT 0x08U #ifndef LWIP_NOASSERT -#define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) +#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ + LWIP_PLATFORM_ASSERT(message); } while(0) #else /* LWIP_NOASSERT */ -#define LWIP_ASSERT(x,y) +#define LWIP_ASSERT(message, assertion) #endif /* LWIP_NOASSERT */ -/** if "e" isn't true, then print "m" message and execute "h" expression */ +/** if "expression" isn't true, then print "message" and execute "handler" expression */ #ifndef LWIP_ERROR -#define LWIP_ERROR(m,e,h) do { if (!(e)) { LWIP_PLATFORM_ASSERT(m); h;}} while(0) +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + LWIP_PLATFORM_ASSERT(message); handler;}} while(0) #endif /* LWIP_ERROR */ #ifdef LWIP_DEBUG /** print debug message only if debug message type is enabled... * AND is of correct type AND is at least LWIP_DBG_LEVEL */ -#define LWIP_DEBUGF(debug,x) do { \ +#define LWIP_DEBUGF(debug, message) do { \ if ( \ ((debug) & LWIP_DBG_ON) && \ ((debug) & LWIP_DBG_TYPES_ON) && \ ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ - LWIP_PLATFORM_DIAG(x); \ + LWIP_PLATFORM_DIAG(message); \ if ((debug) & LWIP_DBG_HALT) { \ while(1); \ } \ @@ -88,7 +90,7 @@ } while(0) #else /* LWIP_DEBUG */ -#define LWIP_DEBUGF(debug,x) +#define LWIP_DEBUGF(debug, message) #endif /* LWIP_DEBUG */ #endif /* __LWIP_DEBUG_H__ */