Re: the random driver

Ingo Oeser
2002-11-20T15:28:24Z

Hi Andrew,

On Tue, Nov 19, 2002 at 11:46:53PM -0800, Andrew Morton wrote:
> c) The ring-buffer handling is awkward. It shouldn't be masking
> the head and tail pointers to always remain within bounds.
>
> A better technique is to allow these indices to wrap at
> 0xffffffff and only mask their values when you actually use
> them as a subscript. This allows you to distinguish the
> completely-full case from the completely-empty one. See
> LOG_BUF* in kernel/printk.c.

Care to implement a generic ringbuffer in a header file, to avoid
this kind of errors? I'm sure there are more (and even overflows
on some implementations).

The gory implementation details of basic computer science
algorithms seem to cause problems for many driver writers.

So the trend of abstracting these away in the kernel, if it costs
no time and doesn't lead to ugly code, is right.

Regards

Ingo Oeser
--
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth