andygock/avr-uart — pull request #6 by dlobato (2014-02-05 22:23:18+00:00)
Title: Possible bug in *_available() functions

I believe there's a bug in the available functions. Instead of the actual size of the buffer the mask (size-1) is used which is wrong.

Let's say buffer size is 8, Tail is 0 and Head 7. There are 7 elements available.

With the current code: available = (7+7-0)%7 = 0
whereas if we use the size: available = (8+7-0)%8 = 7

There might be a more optimal way to do the same without the modulus...but it works.