Skip to content

Commit

Permalink
ringbufindex: fix bugs of ringbufindex_peek_{put,get}
Browse files Browse the repository at this point in the history
  • Loading branch information
yatch committed Mar 9, 2017
1 parent fbf9bb9 commit 2d42b91
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/lib/ringbufindex.c
Expand Up @@ -83,7 +83,7 @@ ringbufindex_peek_put(const struct ringbufindex *r)
if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) {
return -1;
}
return (r->put_ptr + 1) & r->mask;
return r->put_ptr;
}
/* Remove the first element and return its index */
int
Expand Down Expand Up @@ -118,7 +118,7 @@ ringbufindex_peek_get(const struct ringbufindex *r)
first one. If there are no bytes left, we return -1.
*/
if(((r->put_ptr - r->get_ptr) & r->mask) > 0) {
return (r->get_ptr + 1) & r->mask;
return r->get_ptr;
} else {
return -1;
}
Expand Down

0 comments on commit 2d42b91

Please sign in to comment.