From 9e89fa158d5e68ca445adeee75a0d5e0cc8ed973 Mon Sep 17 00:00:00 2001 From: wangqiang Date: Wed, 12 Jan 2022 17:51:40 +0800 Subject: [PATCH 1/2] fixed the return value for sys_arch_mbox_fetch in lwip stack --- components/net/lwip-1.4.1/src/arch/sys_arch.c | 2 +- components/net/lwip-2.0.2/src/arch/sys_arch.c | 2 +- components/net/lwip-2.0.3/src/arch/sys_arch.c | 2 +- components/net/lwip-2.1.2/src/arch/sys_arch.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index 793568d836..09de3f3ecc 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -534,7 +534,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) else { if (ret == RT_EOK) - ret = 1; + ret = 0; } return ret; diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index 3de85b338c..6556fd0c9f 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -544,7 +544,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) else { if (ret == RT_EOK) - ret = 1; + ret = 0; } return ret; diff --git a/components/net/lwip-2.0.3/src/arch/sys_arch.c b/components/net/lwip-2.0.3/src/arch/sys_arch.c index 3de85b338c..6556fd0c9f 100644 --- a/components/net/lwip-2.0.3/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.3/src/arch/sys_arch.c @@ -544,7 +544,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) else { if (ret == RT_EOK) - ret = 1; + ret = 0; } return ret; diff --git a/components/net/lwip-2.1.2/src/arch/sys_arch.c b/components/net/lwip-2.1.2/src/arch/sys_arch.c index a7d3f98968..c89ab737c9 100644 --- a/components/net/lwip-2.1.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.1.2/src/arch/sys_arch.c @@ -558,7 +558,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) else { if (ret == RT_EOK) - ret = 1; + ret = 0; } return ret; From 3842d3749ce7c2066bc69aa5bd92fdd3df5becd7 Mon Sep 17 00:00:00 2001 From: wangqiang Date: Thu, 13 Jan 2022 14:46:35 +0800 Subject: [PATCH 2/2] modify annotation for sys_arch_mbox_tryfetch --- components/net/lwip-1.4.1/src/arch/sys_arch.c | 13 +++++++++++-- components/net/lwip-2.0.2/src/arch/sys_arch.c | 13 +++++++++++-- components/net/lwip-2.0.3/src/arch/sys_arch.c | 13 +++++++++++-- components/net/lwip-2.1.2/src/arch/sys_arch.c | 13 +++++++++++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index 09de3f3ecc..3cdb637d15 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -515,10 +515,19 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) return tick; } -/** Wait for a new message to arrive in the mbox +/** + * @ingroup sys_mbox + * This is similar to sys_arch_mbox_fetch, however if a message is not + * present in the mailbox, it immediately returns with the code + * SYS_MBOX_EMPTY. On success 0 is returned. + * To allow for efficient implementations, this can be defined as a + * function-like macro in sys_arch.h instead of a normal function. For + * example, a naive implementation could be: + * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) + * although this would introduce unnecessary delays. + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message * @return 0 (milliseconds) if a message has been received * or SYS_MBOX_EMPTY if the mailbox is empty */ diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index 6556fd0c9f..b779264f96 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -526,10 +526,19 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) return tick; } -/** Wait for a new message to arrive in the mbox +/** + * @ingroup sys_mbox + * This is similar to sys_arch_mbox_fetch, however if a message is not + * present in the mailbox, it immediately returns with the code + * SYS_MBOX_EMPTY. On success 0 is returned. + * To allow for efficient implementations, this can be defined as a + * function-like macro in sys_arch.h instead of a normal function. For + * example, a naive implementation could be: + * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) + * although this would introduce unnecessary delays. + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message * @return 0 (milliseconds) if a message has been received * or SYS_MBOX_EMPTY if the mailbox is empty */ diff --git a/components/net/lwip-2.0.3/src/arch/sys_arch.c b/components/net/lwip-2.0.3/src/arch/sys_arch.c index 6556fd0c9f..b779264f96 100644 --- a/components/net/lwip-2.0.3/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.3/src/arch/sys_arch.c @@ -526,10 +526,19 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) return tick; } -/** Wait for a new message to arrive in the mbox +/** + * @ingroup sys_mbox + * This is similar to sys_arch_mbox_fetch, however if a message is not + * present in the mailbox, it immediately returns with the code + * SYS_MBOX_EMPTY. On success 0 is returned. + * To allow for efficient implementations, this can be defined as a + * function-like macro in sys_arch.h instead of a normal function. For + * example, a naive implementation could be: + * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) + * although this would introduce unnecessary delays. + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message * @return 0 (milliseconds) if a message has been received * or SYS_MBOX_EMPTY if the mailbox is empty */ diff --git a/components/net/lwip-2.1.2/src/arch/sys_arch.c b/components/net/lwip-2.1.2/src/arch/sys_arch.c index c89ab737c9..62dc493007 100644 --- a/components/net/lwip-2.1.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.1.2/src/arch/sys_arch.c @@ -540,10 +540,19 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) return tick; } -/** Wait for a new message to arrive in the mbox +/** + * @ingroup sys_mbox + * This is similar to sys_arch_mbox_fetch, however if a message is not + * present in the mailbox, it immediately returns with the code + * SYS_MBOX_EMPTY. On success 0 is returned. + * To allow for efficient implementations, this can be defined as a + * function-like macro in sys_arch.h instead of a normal function. For + * example, a naive implementation could be: + * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) + * although this would introduce unnecessary delays. + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message * @return 0 (milliseconds) if a message has been received * or SYS_MBOX_EMPTY if the mailbox is empty */