rem: error == B_OK && remainingBytes > 0;
add: remainingBytes > 0;
context: get_buffer(struct fs_buffer_cache *cache, off_t offset, size_t size,		   void **_buffer, size_t *actualSize){	status_t error = (cache && _buffer && actualSize					  && offset >= 0 && size > 0					  ? B_OK : B_BAD_VALUE);	uint8 *buffer = NULL;	// check the bounds	if (error == B_OK) {		offset += cache->offset;	// make relative to beginning of device		if (offset >= cache->offset + cache->size)			size = 0;		else if (offset + size > cache->offset + cache->size)			size = cache->offset + cache->size - offset;	}	// allocate the buffer	if (error == B_OK && size > 0) {		buffer = (uint8*)malloc(size);		if (buffer) {			// iterate through the list of cached blocks			off_t blockOffset = offset - offset % cache->block_size;			size_t remainingBytes = size;			fs_block *block = NULL;			for (block = cache->first_block;				 error == B_OK && remainingBytes > 0;				 block = block->next) {				if (!block || block->offset >= blockOffset) {					if (!block || block->offset > blockOffset) {						// the block is not in cache, read it						fs_block *newBlock = NULL;						error = new_fs_block(cache->fd, blockOffset,											 cache->block_size, &newBlock);						if (error == B_OK) {							// insert the new block							if (block)								newBlock->previous = block->previous;							else								newBlock->previous = cache->last_block;							newBlock->next = block;							if (newBlock->previous)								newBlock->previous->next = newBlock;							else								cache->first_block = newBlock;							if (newBlock->next)								newBlock->next->previous = newBlock;							else								cache->last_block = newBlock;							block = newBlock;						}					}					if (error == B_OK) {						// block is (now) in cache, copy the data						off_t inBlockOffset = 0;						size_t toCopy = cache->block_size;						if (blockOffset < offset) {							inBlockOffset = offset - blockOffset;							toCopy -= inBlockOffset;						}						if (toCopy > remainingBytes)							toCopy = remainingBytes;						memcpy(buffer + blockOffset + inBlockOffset - offset,							   (uint8*)block->data + inBlockOffset, toCopy);						blockOffset += cache->block_size;						remainingBytes -= toCopy;					}				}			}		} else			error = B_NO_MEMORY;	}	// set results	/ cleanup on error	if (error == B_OK) {		*_buffer = buffer;		*actualSize = size;	} else {		if (buffer)			free(buffer);	}	return error;}