[v2,1/4] Remove check for negative size.
Commit Message
Since CORE_ADDR is unsigned, this value can never be negative.
gdb/ChangeLog:
* score-tdep.c (score7_malloc_and_get_memblock): Remove check for
negative size.
---
gdb/ChangeLog | 5 +++++
gdb/score-tdep.c | 8 +-------
2 files changed, 6 insertions(+), 7 deletions(-)
Comments
On Fri, Jul 1, 2016 at 6:40 PM, John Baldwin <jhb@freebsd.org> wrote:
> Since CORE_ADDR is unsigned, this value can never be negative.
>
score7_malloc_and_get_memblock is called like this,
/* Allocate MEMBLOCK if PC - STARTADDR > 0. */
memblock_ptr = memblock =
score7_malloc_and_get_memblock (startaddr, pc - startaddr);
and startaddr is got by find_pc_partial_function
find_pc_partial_function (pc, NULL, &start_addr, NULL);
so pc >= startaddr, so size is >= 0. Your patch is right to me.
@@ -1,5 +1,10 @@
2016-07-01 John Baldwin <jhb@FreeBSD.org>
+ * score-tdep.c (score7_malloc_and_get_memblock): Remove check for
+ negative size.
+
+2016-07-01 John Baldwin <jhb@FreeBSD.org>
+
* fbsd-nat.c (struct fbsd_fork_child_info): Rename to ...
(struct fbsd_fork_info): ... this.
(struct fbsd_fork_info) <child>: Rename to ...
@@ -813,13 +813,7 @@ score7_malloc_and_get_memblock (CORE_ADDR addr, CORE_ADDR size)
int ret;
gdb_byte *memblock = NULL;
- if (size < 0)
- {
- error (_("Error: malloc size < 0 in file:%s, line:%d!"),
- __FILE__, __LINE__);
- return NULL;
- }
- else if (size == 0)
+ if (size == 0)
return NULL;
memblock = (gdb_byte *) xmalloc (size);