From: Philippe Elie <phil.el@wanadoo.fr>
In a ring buffer controlled by a read and write positions we can't use
buffer_size but only buffer_size - 1 entry, the last free entry act as a
guard to avoid write pos overrun. This bug was hidden because the writer,
oprofile_add_sample(), request one more entry than really needed.
unsigned long tail = b->tail_pos;
if (tail > head)
- return tail - head;
+ return (tail - head) - 1;
- return tail + (b->buffer_size - head);
+ return tail + (b->buffer_size - head) - 1;
}