This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PUSHED] Remove TARGET_XFER_STATUS_ERROR_P (Re: [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial)


On 02/23/2014 11:52 AM, Yao Qi wrote:
>> I maintain that using TARGET_XFER_STATUS_ERROR_P tends to
>> > be unnecessary, and actually leads to fragile code.   It doesn't
>> > really help here.  A newer status added in the future that is
>> > not an error will pass by here unhandled.  Handle TARGET_XFER_OK
>> > explicitly instead, like this:
>> > 
>> >       if (status == TARGET_XFER_EOF)
>                       ^^^^^^^^^^^^^^^
> It should be TARGET_XFER_OK
>> > 	/* nothing */;
>> >       else if (status == TARGET_XFER_E_UNAVAILABLE)
>> > 	mark_value_bytes_unavailable (val, embedded_offset + xfered,
>> > 				      xfered_len);
>> >       else if (status == TARGET_XFER_EOF)
>> > 	memory_error (TARGET_XFER_E_IO, memaddr + xfered);
>> >       else
>> > 	memory_error (status, memaddr + xfered);
>> > 
>> >       xfered += xfered_len;
>> >       QUIT;
>> >     }
>> > 
>> > and now all future unhandled statuses fall through to
>> > memory_error.
> OK, update patch as you suggested.  I'll get rid of
> TARGET_XFER_STATUS_ERROR_P in a follow-up patch.
> 

This patch removes macro TARGET_XFER_STATUS_ERROR_P, as Pedro pointed
out during patches review that TARGET_XFER_STATUS_ERROR_P tends to
be unnecessary.

Regression tested on x86_64-linux.

-- 
Yao (éå)

gdb:

2014-02-24  Yao Qi  <yao@codesourcery.com>

	* target.h (TARGET_XFER_STATUS_ERROR_P): Remove.
	* corefile.c (read_memory): Adjusted.
	* target.c (target_write_with_progress): Adjusted.
---
 gdb/ChangeLog  |    6 ++++++
 gdb/corefile.c |    9 +++------
 gdb/target.c   |    7 ++-----
 gdb/target.h   |    2 --
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3b199ac..01be0a3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-24  Yao Qi  <yao@codesourcery.com>
+
+	* target.h (TARGET_XFER_STATUS_ERROR_P): Remove.
+	* corefile.c (read_memory): Adjusted.
+	* target.c (target_write_with_progress): Adjusted.
+
 2014-02-23  Yao Qi  <yao@codesourcery.com>
 
 	Revert two patches:
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 048669b..815adaf 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -260,13 +260,10 @@ read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 				    memaddr + xfered, len - xfered,
 				    &xfered_len);
 
-      if (status == TARGET_XFER_EOF)
-	memory_error (TARGET_XFER_E_IO, memaddr + xfered);
+      if (status != TARGET_XFER_OK)
+	memory_error (status == TARGET_XFER_EOF ? TARGET_XFER_E_IO : status,
+		      memaddr + xfered);
 
-      if (TARGET_XFER_STATUS_ERROR_P (status))
-	memory_error (status, memaddr + xfered);
-
-      gdb_assert (status == TARGET_XFER_OK);
       xfered += xfered_len;
       QUIT;
     }
diff --git a/gdb/target.c b/gdb/target.c
index 0f3bd30..60a11dd 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2002,12 +2002,9 @@ target_write_with_progress (struct target_ops *ops,
 				     offset + xfered, len - xfered,
 				     &xfered_len);
 
-      if (status == TARGET_XFER_EOF)
-	return xfered;
-      if (TARGET_XFER_STATUS_ERROR_P (status))
-	return -1;
+      if (status != TARGET_XFER_OK)
+	return status == TARGET_XFER_EOF ? xfered : -1;
 
-      gdb_assert (status == TARGET_XFER_OK);
       if (progress)
 	(*progress) (xfered_len, baton);
 
diff --git a/gdb/target.h b/gdb/target.h
index 6cc1337..4254609 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -225,8 +225,6 @@ enum target_xfer_status
   /* Keep list in sync with target_xfer_error_to_string.  */
 };
 
-#define TARGET_XFER_STATUS_ERROR_P(STATUS) ((STATUS) < TARGET_XFER_EOF)
-
 /* Return the string form of ERR.  */
 
 extern const char *target_xfer_status_to_string (enum target_xfer_status err);
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]