From: Yao Qi Date: Wed, 29 Jan 2014 03:48:40 +0000 (+0800) Subject: Return early in target_xfer_partial when LEN is zero. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce6d08922f2875544f9ba461a849726ceff84528;p=binutils-gdb.git Return early in target_xfer_partial when LEN is zero. 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-02-07 Yao Qi * target.c (target_xfer_partial): Return zero if LEN is zero. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6601b480ace..6bcc20568b5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2014-02-07 Yao Qi + + * target.c (target_xfer_partial): Return zero if LEN is zero. + 2014-02-07 Yao Qi * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. diff --git a/gdb/target.c b/gdb/target.c index 3ca3e71fb63..65a226ee653 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));