From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7484 invoked by alias); 9 Jul 2010 18:54:18 -0000 Received: (qmail 7473 invoked by uid 22791); 9 Jul 2010 18:54:17 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Jul 2010 18:54:11 +0000 Received: (qmail 27466 invoked from network); 9 Jul 2010 18:54:09 -0000 Received: from unknown (HELO wind.localnet) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Jul 2010 18:54:09 -0000 From: Vladimir Prus To: Daniel Jacobowitz Subject: Re: Better MI memory commands Date: Fri, 09 Jul 2010 18:54:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-21-generic-pae; KDE/4.3.2; i686; ; ) Cc: gdb-patches@sources.redhat.com References: <201006251232.55281.vladimir@codesourcery.com> <20100707162952.GA6530@caradoc.them.org> In-Reply-To: <20100707162952.GA6530@caradoc.them.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201007092254.07434.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00186.txt.bz2 On Wednesday 07 July 2010 20:29:55 Daniel Jacobowitz wrote: > > - if (xfer == 0) > > - return xfered; > > - if (xfer < 0) > > - { > > - remaining = half; > > - } > > - else > > - { > > - /* We have successfully read the first half. So, the > > - error must be in the second half. Adjust start and > > - remaining to point at the second half. */ > > - xfered += xfer; > > - start += xfer; > > - remaining -= xfer; > > - } > > - half = remaining/2; > > + xfree (buffer); > > + xfered += to_read; > > } > > Why do we skip to_read bytes if we succeed at reading zero bytes? > For that matter, what does a return value of zero mean? It seems like > this would mean the same as -1. I am not really sure. Per documentation of target_read: Return the number of bytes actually transfered, or -1 if the transfer is not supported or otherwise fails. Return of a positive value less than LEN indicates that no further transfer is possible. So, value of 0 seems to mean 'there are no more bytes that that, honest', and that we probably don't need to try further. Documentation for to_xfer_partial seem to give such meaning to return of 0. On the other hand, it's not clear what return value of