From b035a6196a36330e45a79feffdf000a5c9631214 Mon Sep 17 00:00:00 2001 From: fbernon Date: Mon, 19 Mar 2007 20:35:32 +0000 Subject: [PATCH] Add return types to tcpip_apimsg() and api_msg_post() to check ERR_MEM problems (api_lib.c can be change now). --- CHANGELOG | 4 ++++ src/api/api_msg.c | 4 ++-- src/api/tcpip.c | 5 +++-- src/include/lwip/api_msg.h | 4 ++-- src/include/lwip/tcpip.h | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3160b810..cbf0edf0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -67,6 +67,10 @@ HISTORY ++ Bug fixes: + 2007-03-19 Frédéric Bernon + * api_msg.h, api_msg.c, tcpip.h, tcpip.c: Add return types to tcpip_apimsg() + and api_msg_post(). + 2007-03-19 Frédéric Bernon * Remove unimplemented "memp_realloc" function from memp.h. diff --git a/src/api/api_msg.c b/src/api/api_msg.c index d62e1259..9f69c545 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -848,10 +848,10 @@ api_msg_input(struct api_msg *msg) decode[msg->type](&(msg->msg)); } -void +err_t api_msg_post(struct api_msg *msg) { - tcpip_apimsg(msg); + return tcpip_apimsg(msg); } diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 0660d5be..41ad8ebb 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -267,17 +267,18 @@ tcpip_callback(void (*f)(void *ctx), void *ctx) return ERR_OK; } -void +err_t tcpip_apimsg(struct api_msg *apimsg) { struct tcpip_msg *msg; msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) { - return; + return ERR_MEM; } msg->type = TCPIP_MSG_API; msg->msg.apimsg = apimsg; sys_mbox_post(mbox, msg); + return ERR_OK; } void diff --git a/src/include/lwip/api_msg.h b/src/include/lwip/api_msg.h index b274cd2b..879fe4dc 100644 --- a/src/include/lwip/api_msg.h +++ b/src/include/lwip/api_msg.h @@ -91,8 +91,8 @@ struct api_msg { struct api_msg_msg msg; }; -void api_msg_input(struct api_msg *msg); -void api_msg_post(struct api_msg *msg); +void api_msg_input(struct api_msg *msg); +err_t api_msg_post(struct api_msg *msg); #endif /* __LWIP_API_MSG_H__ */ diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h index 0bbe694f..f3ce388d 100644 --- a/src/include/lwip/tcpip.h +++ b/src/include/lwip/tcpip.h @@ -36,7 +36,7 @@ #include "lwip/pbuf.h" void tcpip_init(void (* tcpip_init_done)(void *), void *arg); -void tcpip_apimsg(struct api_msg *apimsg); +err_t tcpip_apimsg(struct api_msg *apimsg); #if ETHARP_TCPIP_INPUT err_t tcpip_input(struct pbuf *p, struct netif *inp); #endif /* ETHARP_TCPIP_INPUT */