This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 4/6] Return early in target_xfer_partial when LEN is zero.
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Fri, 31 Jan 2014 11:35:23 +0800
- Subject: [PATCH 4/6] Return early in target_xfer_partial when LEN is zero.
- Authentication-results: sourceware.org; auth=none
- References: <1391139325-2758-1-git-send-email-yao at codesourcery dot com>
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 <yao@codesourcery.com>
* 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