From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16339 invoked by alias); 31 Jan 2014 03:38:07 -0000 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 Received: (qmail 16089 invoked by uid 89); 31 Jan 2014 03:38:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Jan 2014 03:38:03 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1W94vY-0002Y7-EF from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 30 Jan 2014 19:38:00 -0800 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 30 Jan 2014 19:38:00 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Thu, 30 Jan 2014 19:37:58 -0800 From: Yao Qi To: Subject: [PATCH 4/6] Return early in target_xfer_partial when LEN is zero. Date: Fri, 31 Jan 2014 03:38:00 -0000 Message-ID: <1391139325-2758-5-git-send-email-yao@codesourcery.com> In-Reply-To: <1391139325-2758-1-git-send-email-yao@codesourcery.com> References: <1391139325-2758-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg01068.txt.bz2 Nowadays, argument LEN of to_xfer_partial can be zero in some cases, and each implementation may do nothing and return zero, indicating transfer is done. That is fine. However, when we change to_xfer_partial to return target_xfer_status, we have to check every return value of most of to_xfer_partial implementations, return TARGET_XFER_DONE if return value is zero. This patch simplifies this by checking LEN in target_xfer_partial, and return 0 if LEN is zero. Regression tested on x86_84-linux. Is it OK? gdb: 2014-01-30 Yao Qi * target.c (target_xfer_partial): Return zero if LEN is zero. --- gdb/target.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 3ca3e71..65a226e 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1697,6 +1697,10 @@ target_xfer_partial (struct target_ops *ops, gdb_assert (ops->to_xfer_partial != NULL); + /* Transfer is done when LEN is zero. */ + if (len == 0) + return 0; + if (writebuf && !may_write_memory) error (_("Writing to memory is not allowed (addr %s, len %s)"), core_addr_to_string_nz (offset), plongest (len)); -- 1.7.7.6