qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <20140321162636.GF8476@work-vm> (raw)
In-Reply-To: <87r45vh70s.fsf@elfo.mitica>

* Juan Quintela (quintela@redhat.com) wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> 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 / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2014-03-21 16:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 12:58 [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it's data Dr. David Alan Gilbert (git)
2014-03-21 13:24 ` Juan Quintela
2014-03-21 14:39   ` Dr. David Alan Gilbert
2014-03-21 16:05     ` Juan Quintela
2014-03-21 16:26       ` Dr. David Alan Gilbert [this message]
2014-03-21 17:55         ` Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140321162636.GF8476@work-vm \
    --to=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).