From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR2HR-0001jL-Gh for qemu-devel@nongnu.org; Fri, 21 Mar 2014 12:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WR2HL-0000ok-B0 for qemu-devel@nongnu.org; Fri, 21 Mar 2014 12:26:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WR2HL-0000oZ-30 for qemu-devel@nongnu.org; Fri, 21 Mar 2014 12:26:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2LGQfZL018315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Mar 2014 12:26:42 -0400 Date: Fri, 21 Mar 2014 16:26:37 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20140321162636.GF8476@work-vm> References: <1395320327-16613-1-git-send-email-dgilbert@redhat.com> <871txvit1p.fsf@elfo.mitica> <20140321143919.GA8476@work-vm> <87r45vh70s.fsf@elfo.mitica> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r45vh70s.fsf@elfo.mitica> Subject: Re: [Qemu-devel] [PATCH 1/1] Make qemu_peek_buffer loop until it gets it's data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org * 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. Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK