From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR3fY-0008EO-9E for qemu-devel@nongnu.org; Fri, 21 Mar 2014 13:55:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WR3fS-0005Zx-84 for qemu-devel@nongnu.org; Fri, 21 Mar 2014 13:55:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR3fS-0005Zt-09 for qemu-devel@nongnu.org; Fri, 21 Mar 2014 13:55:42 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2LHtfTI009409 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Mar 2014 13:55:41 -0400 From: Juan Quintela In-Reply-To: <20140321162636.GF8476@work-vm> (David Alan Gilbert's message of "Fri, 21 Mar 2014 16:26:37 +0000") References: <1395320327-16613-1-git-send-email-dgilbert@redhat.com> <871txvit1p.fsf@elfo.mitica> <20140321143919.GA8476@work-vm> <87r45vh70s.fsf@elfo.mitica> <20140321162636.GF8476@work-vm> Date: Fri, 21 Mar 2014 18:55:39 +0100 Message-ID: <87ior7h1wk.fsf@elfo.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it's data Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: qemu-devel@nongnu.org "Dr. David Alan Gilbert" wrote: > * Juan Quintela (quintela@redhat.com) wrote: >> "Dr. David Alan Gilbert" 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. thanks very much to take the time to understand it and document it O;-) Later, Juan.