On Mon, Apr 14, 2014 at 7:56 AM, Beniamino Galvani <[email protected]> wrote:
> On Wed, Apr 09, 2014 at 11:42:31PM -0700, Peter Crosthwaite wrote:
>> Add support for 16, 32 and 64 bit width FIFOs. The push and pop
>> functions are replicated to accept all four different integer types.
>> The element width of the FIFO is set at creation time.
>>
>> The backing storage for all element types is still uint8_t regardless of
>> element width so some save-load logic is needed to handle endianness
>> issue WRT VMSD.
>>
>> Signed-off-by: Peter Crosthwaite <[email protected]>
>> ---
>> /**
>> * fifo_reset:
>> diff --git a/util/fifo.c b/util/fifo.c
>> index 4ee6c85..a52e920 100644
>> --- a/util/fifo.c
>> +++ b/util/fifo.c
>> @@ -15,9 +15,11 @@
>> #include "qemu-common.h"
>> #include "qemu/fifo.h"
>>
>> -void fifo_create(Fifo *fifo, uint32_t capacity)
>> +void fifo_create(Fifo *fifo, uint32_t capacity, int width)
>> {
>> - fifo->data = g_new(uint8_t, capacity);
>> + assert(width == 8 || width == 16 || width == 32 || width == 64);
>> + fifo->width = width / 8;
>> + fifo->data = g_new(uint8_t, capacity * fifo->width);
>> fifo->capacity = capacity;
>
> Maybe buffer_size should be initialized here as well.
>
Yes you are right. Nice catch.
Regards,
Peter
P.S. I dropped your RB from V1 due to the major changes prompted by
Don's review.