From d09f2c3fc15dd4491e9cfa455191045c0729a3c3 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 27 Oct 2015 17:25:09 +0000 Subject: target_read_memory&co: no longer return target_xfer_status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Years ago, these functions used to return errno/EIO. Later, through a series of changes that intended to remove native/remote differences, they ended up returning a target_xfer_status in disguise. Unlike target_xfer_partial&co, the point of target_read_memory&co is to either fully succeed or fail. On error, they always return TARGET_XFER_E_IO. So there's no real point in casting the return of target_read_memory to a target_xfer_status to pass it to memory_error. Instead, it results in clearer code to simply decouple target_read_memory&co's return from target_xfer_status. This fixes build errors like this in C++ mode: ../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’: ../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive] memory_error (status, memaddr); ^ ../../src/gdb/corefile.c:216:1: error: initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive] gdb/ChangeLog: 2015-10-27 Pedro Alves * alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to memory_error. Rename local 'status' to 'res'. * c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to memory_error. * corefile.c (read_stack, read_code, write_memory): Always pass TARGET_XFER_E_IO to memory_error. * disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to memory_error. Rename parameter 'status' to 'err'. (dump_insns): Rename local 'status' to 'err'. * mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp' to 'errp'. Rename local 'status' to 'err'. Always pass TARGET_XFER_E_IO to memory_error. (mips_breakpoint_from_pc): Rename local 'status' to 'err'. * target.c (target_read_memory, target_read_raw_memory) (target_read_stack, target_read_code, target_write_memory) (target_write_raw_memory): Return -1 on error instead of TARGET_XFER_E_IO. * valprint.c (val_print_string): Rename local 'errcode' to 'err'. Always pass TARGET_XFER_E_IO to memory_error. Update comment. --- gdb/alpha-tdep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gdb/alpha-tdep.c') diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 0696b6e..ca0e109 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -682,11 +682,11 @@ alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte buf[ALPHA_INSN_SIZE]; - int status; + int res; - status = target_read_memory (pc, buf, sizeof (buf)); - if (status) - memory_error (status, pc); + res = target_read_memory (pc, buf, sizeof (buf)); + if (res != 0) + memory_error (TARGET_XFER_E_IO, pc); return extract_unsigned_integer (buf, sizeof (buf), byte_order); } -- cgit v1.1