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]

Re: [PATCH] Replace 0 with TARGET_XFER_EOF in to_xfer_partial


On 08/07/2014 12:03 AM, Tom Tromey wrote:
> Looks good.
> 

Patch is pushed in, in addition to the same replacement to
remote_read_bytes in remote.c.

> FWIW I think there should be a few more like this.
> Maybe in ser-something.c?

I'll take a look.

> And also this code in remote_xfer_partial:
> 
>   /* Note: a zero OFFSET and LEN can be used to query the minimum
>      buffer size.  */
>   if (offset == 0 && len == 0)
>     return (get_remote_packet_size ());
> 
> There's a bug filed for this one.

It is PR 17060.

-- 
Yao (éå)

commit 96c4f946a8c8d53141189852c0ba28c45366830b
Author: Yao Qi <yao@codesourcery.com>
Date:   Wed Aug 6 14:02:35 2014 +0800

    Replace 0 with TARGET_XFER_EOF in to_xfer_partial
    
    I run splint in gdb source and get the following warnings:
    
      ../../../git/gdb/corelow.c:740: Return value type int does not match declared type enum target_xfer_status: 0
    
    'TARGET_XFER_EOF' (enum target_xfer_status) is expected to be returned,
    but 0 is returned.  This patch is to replace 0 with TARGET_XFER_EOF
    in the implementations of to_xfer_partial.
    
    gdb:
    
    2014-08-07  Yao Qi  <yao@codesourcery.com>
    
    	* corelow.c (core_xfer_partial): Replace 0 with TARGET_XFER_EOF.
    	* remote-m32r-sdi.c (m32r_xfer_memory): Likewise.
    	* remote.c (remote_read_bytes): Likewise.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 68d1db9..93bfc72 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2014-08-07  Yao Qi  <yao@codesourcery.com>
 
+	* corelow.c (core_xfer_partial): Replace 0 with TARGET_XFER_EOF.
+	* remote-m32r-sdi.c (m32r_xfer_memory): Likewise.
+	* remote.c (remote_read_bytes): Likewise.
+
+2014-08-07  Yao Qi  <yao@codesourcery.com>
+
 	* dwarf2read.c (struct dwarf2_per_cu_data) <u>: Tweak comments.
 
 2014-08-07  Yao Qi  <yao@codesourcery.com>
diff --git a/gdb/corelow.c b/gdb/corelow.c
index ff4d733..ecd99f6 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -734,7 +734,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
 
 	  size = bfd_section_size (core_bfd, section);
 	  if (offset >= size)
-	    return 0;
+	    return TARGET_XFER_EOF;
 	  size -= offset;
 	  if (size > len)
 	    size = len;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 5443fe0..3d6b0c6 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1080,7 +1080,7 @@ m32r_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
 	      if (remote_debug)
 		fprintf_unfiltered (gdb_stdlog,
 				    "m32r_xfer_memory() failed\n");
-	      return 0;
+	      return TARGET_XFER_EOF;
 	    }
 	  ret = send_data (writebuf, len);
 	}
@@ -1094,7 +1094,7 @@ m32r_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
 	{
 	  if (remote_debug)
 	    fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory() failed\n");
-	  return 0;
+	  return TARGET_XFER_EOF;
 	}
 
       c = serial_readchar (sdi_desc, SDI_TIMEOUT);
@@ -1102,7 +1102,7 @@ m32r_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
 	{
 	  if (remote_debug)
 	    fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory() failed\n");
-	  return 0;
+	  return TARGET_XFER_EOF;
 	}
 
       ret = recv_data (readbuf, len);
diff --git a/gdb/remote.c b/gdb/remote.c
index 8decd08..473bb72 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6823,7 +6823,7 @@ remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
 		   gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len)
 {
   if (len == 0)
-    return 0;
+    return TARGET_XFER_EOF;
 
   if (get_traceframe_number () != -1)
     {


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