Fixed an off-by-one error in the read_from_buffer function,
testcase: size=7, in=7, first=0, read length=7 Fixed an off-by-(buffer->size) error in the write_to_buffer function, testcase: size=7, in=2, first=3, write length=3 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14473 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3d5ecf962c
commit
31b6023a85
@ -50,7 +50,7 @@ read_from_buffer(struct ring_buffer *buffer, uint8 *data, ssize_t length,
|
||||
|
||||
ssize_t bytesRead = length;
|
||||
|
||||
if (buffer->first + length < buffer->size) {
|
||||
if (buffer->first + length <= buffer->size) {
|
||||
// simple copy
|
||||
if (user) {
|
||||
if (user_memcpy(data, buffer->buffer + buffer->first, length) < B_OK)
|
||||
@ -91,7 +91,7 @@ write_to_buffer(struct ring_buffer *buffer, const uint8 *data, ssize_t length,
|
||||
return 0;
|
||||
|
||||
ssize_t bytesWritten = length;
|
||||
int32 position = buffer->first + buffer->in;
|
||||
int32 position = (buffer->first + buffer->in) % buffer->size;
|
||||
|
||||
if (position + length <= buffer->size) {
|
||||
// simple copy
|
||||
|
Loading…
Reference in New Issue
Block a user