Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: Bug in ring buffer implementation
On Sat, Feb 08, 2003 at 04:10:42AM +0100, Oliver Endriss wrote:
> Hi,
>
> while reading through the driver sources, I found that the free byte
> count of the ring buffers is not calculated correctly.
>
> In the current implementation, code like this is used (example taken
> from dmxdev.c):
>
> free=buf->pread-buf->pwrite; (1)
> split=0;
> if (free<=0) {
> free+=buf->size;
> split=buf->size-buf->pwrite;
> }
>
> (1) is not correct. It should read:
> free=buf->pread-buf->pwrite-1; (2)
> ^^
> ...
>
> Obviously a ring buffer of size <n> cannot hold more than <n-1> bytes.
> Otherwise you cannot distinguish between an empty and a full buffer.
Good point. Better to have one byte less in the buffer than to think
should we have used "<=" or just "<" :)
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index