[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it
From: |
Juan Quintela |
Subject: |
Re: [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it's data |
Date: |
Fri, 21 Mar 2014 17:05:07 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
"Dr. David Alan Gilbert" <address@hidden> wrote:
>> > + while (index >= f->buf_size) {
>> > + int received = qemu_fill_buffer(f);
>> > +
>> > + if (received <= 0) {
>>
>> here, I don't know really what to do. We just need one character, so
>> the 1st call to qemu_fill_buffer() gives it to us, or we are already on
>> problems. i.e. no need of the while() loop.
>
> The problem is that peek_byte takes an offset, so while qemu_fill_buffer
> will get us a byte, we actually need it to get us all the bytes upto the
> offset, and that's not guaranteed from one call.
that is not a problem.
We never got a "hole" on the things that we ask for. We ask for the
"next byte", or the "next bytes", so in qemu_peek_byte() we are
guaranteed (with current users) that we would only have to read a single
byte.
I.e. qemu_peek_{buffer,byte}(....,offset, size) means that we have
"already" peek until offset, and now we want size more bytes.
Later, Juan.