Skip to content

Commit 9a70621

Browse files
committed
Review fixes
1 parent feb6a46 commit 9a70621

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

features/lwipstack/lwip-sys/arch/lwip_sys_arch.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ u32_t sys_now(void) {
116116
/* CMSIS-RTOS implementation of the lwip operating system abstraction */
117117
#include "arch/sys_arch.h"
118118

119-
/* modulus subtract: (a - b) mod m, where a, b belongs to mod m ring */
120-
#define SUB_MOD(a, b, m) ((a) >= (b) ? (a) - (b) : (m) - (b) + (a))
121-
122119
/*---------------------------------------------------------------------------*
123120
* Routine: sys_mbox_new
124121
*---------------------------------------------------------------------------*
@@ -181,7 +178,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg) {
181178
mbox->post_idx = (mbox->post_idx + 1) % MB_SIZE;
182179

183180
osEventFlagsSet(mbox->id, SYS_MBOX_FETCH_EVENT);
184-
if (SUB_MOD(mbox->post_idx, mbox->fetch_idx, MB_SIZE) >= MB_SIZE-1)
181+
if ((mbox->post_idx + 1) % MB_SIZE == mbox->fetch_idx)
185182
osEventFlagsClear(mbox->id, SYS_MBOX_POST_EVENT);
186183

187184
osKernelRestoreLock(state);
@@ -214,7 +211,7 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) {
214211
mbox->post_idx = (mbox->post_idx + 1) % MB_SIZE;
215212

216213
osEventFlagsSet(mbox->id, SYS_MBOX_FETCH_EVENT);
217-
if (SUB_MOD(mbox->post_idx, mbox->fetch_idx, MB_SIZE) >= MB_SIZE-1)
214+
if ((mbox->post_idx + 1) % MB_SIZE == mbox->fetch_idx)
218215
osEventFlagsClear(mbox->id, SYS_MBOX_POST_EVENT);
219216

220217
osKernelRestoreLock(state);

0 commit comments

Comments
 (0)