Replace 0 with TARGET_XFER_EOF in to_xfer_partial

Message ID 1407306345-4371-1-git-send-email-yao@codesourcery.com
State Superseded
Headers

Commit Message

Yao Qi Aug. 6, 2014, 6:25 a.m. UTC
  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.  I'll commit it in two
days.

gdb:

2014-08-06  Yao Qi  <yao@codesourcery.com>

	* corelow.c (core_xfer_partial): Replace 0 with TARGET_XFER_EOF.
	* remote-m32r-sdi.c (m32r_xfer_memory): Likewise.
---
 gdb/corelow.c         | 2 +-
 gdb/remote-m32r-sdi.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Tom Tromey Aug. 6, 2014, 4:03 p.m. UTC | #1
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> 'TARGET_XFER_EOF' (enum target_xfer_status) is expected to be returned,
Yao> but 0 is returned.  This patch is to replace 0 with TARGET_XFER_EOF
Yao> in the implementations of to_xfer_partial.  I'll commit it in two
Yao> days.

Looks good.

FWIW I think there should be a few more like this.
Maybe in ser-something.c?
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.

Tom
  

Patch

diff --git a/gdb/corelow.c b/gdb/corelow.c
index ad780ed..4d783b6 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -737,7 +737,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 e5b66a0..3d2260d 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1081,7 +1081,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);
 	}
@@ -1095,7 +1095,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);
@@ -1103,7 +1103,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);