* [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast
@ 2017-06-18 21:18 Thomas Petazzoni
2017-06-18 21:32 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Petazzoni @ 2017-06-18 21:18 UTC (permalink / raw)
To: gdb-patches; +Cc: Thomas Petazzoni
On noMMU platforms, the following code gets compiled:
child_stack = xmalloc (STACK_SIZE * 4);
Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
the lack of cast is valid in C, it is not in C++, causing the
following build failure:
../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
child_stack = xmalloc (STACK_SIZE * 4);
Therefore, this commit adds the appropriate cast.
gdb/ChangeLog:
* nat/linux-ptrace.c (linux_fork_to_function): fix cast to
gdb_byte*, needed for C++ build.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
gdb/nat/linux-ptrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 3265b16..5d38a66 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -272,7 +272,7 @@ linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *))
#define STACK_SIZE 4096
if (child_stack == NULL)
- child_stack = xmalloc (STACK_SIZE * 4);
+ child_stack = (gdb_byte*) xmalloc (STACK_SIZE * 4);
/* Use CLONE_VM instead of fork, to support uClinux (no MMU). */
#ifdef __ia64__
--
2.9.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast
2017-06-18 21:18 [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast Thomas Petazzoni
@ 2017-06-18 21:32 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2017-06-18 21:32 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: gdb-patches
On 2017-06-18 23:18, Thomas Petazzoni wrote:
> On noMMU platforms, the following code gets compiled:
>
> child_stack = xmalloc (STACK_SIZE * 4);
>
> Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
> the lack of cast is valid in C, it is not in C++, causing the
> following build failure:
>
> ../nat/linux-ptrace.c: In function 'int
> linux_fork_to_function(gdb_byte*, int (*)(void*))':
> ../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*'
> to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
> child_stack = xmalloc (STACK_SIZE * 4);
>
> Therefore, this commit adds the appropriate cast.
>
> gdb/ChangeLog:
>
> * nat/linux-ptrace.c (linux_fork_to_function): fix cast to
> gdb_byte*, needed for C++ build.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thanks for the patch! I pushed it with minor changes (formatting &
ChangeLog).
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-18 21:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-18 21:18 [PATCH] nat/linux-ptrace.c: add missing gdb_byte* cast Thomas Petazzoni
2017-06-18 21:32 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox