[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: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it's data |
Date: |
Fri, 21 Mar 2014 16:26:37 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
* Juan Quintela (address@hidden) wrote:
> "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.
Hmm ok, that is convenient but is neither documented or enforced;
I'll rework my patch and at least document it, and possibly enforce it.
Dave
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK