fix mailbox offset overflow
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1486 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
3077aea698
commit
8cae5c147f
@ -1278,7 +1278,7 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag)
|
||||
* @return the error code
|
||||
*/
|
||||
rt_err_t rt_mb_delete (rt_mailbox_t mb)
|
||||
{
|
||||
{
|
||||
/* parameter check */
|
||||
RT_ASSERT(mb != RT_NULL);
|
||||
|
||||
@ -1398,7 +1398,7 @@ rt_err_t rt_mb_send_wait (rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout
|
||||
mb->msg_pool[mb->in_offset] = value;
|
||||
/* increase input offset */
|
||||
++ mb->in_offset;
|
||||
if (mb->in_offset > mb->size) mb->in_offset = 0;
|
||||
if (mb->in_offset >= mb->size) mb->in_offset = 0;
|
||||
/* increase message entry */
|
||||
mb->entry ++;
|
||||
|
||||
@ -1529,7 +1529,7 @@ rt_err_t rt_mb_recv (rt_mailbox_t mb, rt_uint32_t* value, rt_int32_t timeout)
|
||||
|
||||
/* increase output offset */
|
||||
++mb->out_offset;
|
||||
if (mb->out_offset > mb->size) mb->out_offset = 0;
|
||||
if (mb->out_offset >= mb->size) mb->out_offset = 0;
|
||||
/* decrease message entry */
|
||||
mb->entry --;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user