Fix bug in buffer.c, add buffer mini-unit test.

This commit is contained in:
Michael Brown
2007-01-11 04:46:41 +00:00
parent 83fa318b86
commit c0ef730ec4
2 changed files with 57 additions and 3 deletions

View File

@@ -80,21 +80,21 @@ struct buffer_free_block {
* @ret block Next free block descriptor
* @ret rc Return status code
*
* Set @c block->next=buffer->free before first call to
* Set @c block->next=buffer->fill before first call to
* get_next_free_block().
*/
static int get_next_free_block ( struct buffer *buffer,
struct buffer_free_block *block ) {
/* Check for end of buffer */
if ( block->end >= buffer->len )
if ( block->next >= buffer->len )
return -ENOENT;
/* Move to next block */
block->start = block->next;
if ( block->start >= buffer->free ) {
/* Final block; no in-band descriptor */
block->end = buffer->len;
block->next = block->end = buffer->len;
} else {
/* Retrieve block descriptor */
copy_from_phys ( block, ( buffer->addr + block->start ),