public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Change len's type to ULONGEST: remote_write_bytes_aux
@ 2014-01-22 12:58 Yao Qi
  2014-01-23 14:37 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2014-01-22 12:58 UTC (permalink / raw)
  To: gdb-patches

Hi,
This patch changes the type of 'len' from ssize_t to ULONGEST.

At the beginning Siddhesh Poyarekar proposed this patch

  [PATCH] Memory reads and writes should have size_t length
  https://sourceware.org/ml/gdb-patches/2012-05/msg01073.html

to change type of 'len' to size_t.  However, after Jan's review, we
decide to change it to ssize_t, because callers of these functions
may pass signed type to them.

AFAICS, the target layer is a boundary.  In one side, we pass size_t
or ssize_t to target related APIs, and in the other side, the
implementation side, we used LONGEST (ULONGEST in latest code) because
of to_xfer_partial.

Since remote_write_bytes_aux and remote_write_bytes belong to the
implementation of remote target, we should use ULONGEST for len, IMO.

Regression tested on x86_64-linux.  Is it OK?

gdb:

2014-01-22  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_write_bytes_aux): Change type of 'len' to
	ULONGEST.  Don't check 'len' is negative.
	(remote_write_bytes):  Change type of 'len' to ULONGEST.
---
 gdb/remote.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index d886929..15e7394 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6848,7 +6848,7 @@ check_binary_download (CORE_ADDR addr)
 
 static LONGEST
 remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
-			const gdb_byte *myaddr, ssize_t len,
+			const gdb_byte *myaddr, ULONGEST len,
 			char packet_format, int use_length)
 {
   struct remote_state *rs = get_remote_state ();
@@ -6865,7 +6865,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
     internal_error (__FILE__, __LINE__,
 		    _("remote_write_bytes_aux: bad packet format"));
 
-  if (len <= 0)
+  if (len == 0)
     return 0;
 
   payload_size = get_memory_write_packet_size ();
@@ -7003,7 +7003,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
    packet.  */
 
 static LONGEST
-remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
+remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len)
 {
   char *packet_format = 0;
 
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Change len's type to ULONGEST: remote_write_bytes_aux
  2014-01-22 12:58 [PATCH] Change len's type to ULONGEST: remote_write_bytes_aux Yao Qi
@ 2014-01-23 14:37 ` Pedro Alves
  2014-01-24 13:38   ` Yao Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2014-01-23 14:37 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 01/22/2014 12:56 PM, Yao Qi wrote:

> AFAICS, the target layer is a boundary.  In one side, we pass size_t
> or ssize_t to target related APIs, and in the other side, the
> implementation side, we used LONGEST (ULONGEST in latest code) because
> of to_xfer_partial.
> 
> Since remote_write_bytes_aux and remote_write_bytes belong to the
> implementation of remote target, we should use ULONGEST for len, IMO.
> 
> Regression tested on x86_64-linux.  Is it OK?

This is fine with me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Change len's type to ULONGEST: remote_write_bytes_aux
  2014-01-23 14:37 ` Pedro Alves
@ 2014-01-24 13:38   ` Yao Qi
  0 siblings, 0 replies; 3+ messages in thread
From: Yao Qi @ 2014-01-24 13:38 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 01/23/2014 10:37 PM, Pedro Alves wrote:
> On 01/22/2014 12:56 PM, Yao Qi wrote:
> 
>> AFAICS, the target layer is a boundary.  In one side, we pass size_t
>> or ssize_t to target related APIs, and in the other side, the
>> implementation side, we used LONGEST (ULONGEST in latest code) because
>> of to_xfer_partial.
>>
>> Since remote_write_bytes_aux and remote_write_bytes belong to the
>> implementation of remote target, we should use ULONGEST for len, IMO.
>>
>> Regression tested on x86_64-linux.  Is it OK?
> 
> This is fine with me.
> 

Patch is pushed.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-24 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-22 12:58 [PATCH] Change len's type to ULONGEST: remote_write_bytes_aux Yao Qi
2014-01-23 14:37 ` Pedro Alves
2014-01-24 13:38   ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).