mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-05 19:07:41 +00:00
ringbufindex: fix bugs of ringbufindex_peek_{put,get}
This commit is contained in:
parent
fbf9bb9e64
commit
2d42b91c7b
@ -83,7 +83,7 @@ ringbufindex_peek_put(const struct ringbufindex *r)
|
|||||||
if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) {
|
if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return (r->put_ptr + 1) & r->mask;
|
return r->put_ptr;
|
||||||
}
|
}
|
||||||
/* Remove the first element and return its index */
|
/* Remove the first element and return its index */
|
||||||
int
|
int
|
||||||
@ -118,7 +118,7 @@ ringbufindex_peek_get(const struct ringbufindex *r)
|
|||||||
first one. If there are no bytes left, we return -1.
|
first one. If there are no bytes left, we return -1.
|
||||||
*/
|
*/
|
||||||
if(((r->put_ptr - r->get_ptr) & r->mask) > 0) {
|
if(((r->put_ptr - r->get_ptr) & r->mask) > 0) {
|
||||||
return (r->get_ptr + 1) & r->mask;
|
return r->get_ptr;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user