Re: [RFC, 2.6] a simple FIFO implementation

From: Sasha Khapyorsky
Date: Mon Sep 20 2004 - 13:00:17 EST


On Mon, 20 Sep 2004 17:14:26 +0200
Stelian Pop <stelian@xxxxxxxxxx> wrote:

> +unsigned int __kfifo_get(struct kfifo *fifo,
> + unsigned char *buffer, unsigned int len)
> +{
> + unsigned int l;
> +
> + len = min(len, fifo->in - fifo->out);
> +
> + /* first get the data from fifo->out until the end of the buffer */
> + l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
> + memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l);
> +
> + /* then get the rest (if any) from the beginning of the buffer */
> + memcpy(buffer, fifo->buffer + l, len - l);

I guess last line should be:

memcpy(buffer + l, fifo->buffer, len - i)

Sasha.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/