diff mbox

[1/3] linux-record: Fix bad fall-through for pipe/pipe2

Message ID 1458154517-25441-2-git-send-email-arnez@linux.vnet.ibm.com
State New
Headers show

Commit Message

Andreas Arnez March 16, 2016, 6:54 p.m. UTC
This patch added handling for some syscalls to linux-record.c:

  https://sourceware.org/ml/gdb-patches/2015-10/msg00452.html

But for both `pipe' and `pipe2' the patch lacks a statement after an
`if', such that the following `break' is interpreted as the `if'-body
instead.

This adds the missing (return-) statements for the conditionals.

gdb/ChangeLog:

	* linux-record.c (record_linux_system_call): Add missing return
	statements to handling of pipe and pipe2 syscalls.
---
 gdb/linux-record.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Marcin Koƛcielnicki March 16, 2016, 8:23 p.m. UTC | #1
On 16/03/16 19:54, Andreas Arnez wrote:
> This patch added handling for some syscalls to linux-record.c:
>
>    https://sourceware.org/ml/gdb-patches/2015-10/msg00452.html
>
> But for both `pipe' and `pipe2' the patch lacks a statement after an
> `if', such that the following `break' is interpreted as the `if'-body
> instead.
>
> This adds the missing (return-) statements for the conditionals.

Whoops, my bad.  This looks like obvious patch material.  Though I 
wonder why it wasn't detected earlier by someone running GCC 6 with its 
-Wmisleading-indentation warning - does it not catch it?

Btw, it seems that cases gdb_sys_pipe2 and gdb_sys_pipe could be 
squashed into one.
>
> gdb/ChangeLog:
>
> 	* linux-record.c (record_linux_system_call): Add missing return
> 	statements to handling of pipe and pipe2 syscalls.
> ---
>   gdb/linux-record.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/gdb/linux-record.c b/gdb/linux-record.c
> index a40845a..2e86936 100644
> --- a/gdb/linux-record.c
> +++ b/gdb/linux-record.c
> @@ -354,6 +354,7 @@ record_linux_system_call (enum gdb_syscall syscall,
>         regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
>         if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
>   					 tdep->size_int * 2))
> +        return -1;
>         break;
>
>       case gdb_sys_times:
> @@ -2312,6 +2313,7 @@ Do you want to stop the program?"),
>         regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
>         if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
>   					 tdep->size_int * 2))
> +        return -1;
>         break;
>
>       case gdb_sys_inotify_init1:
>
Yao Qi March 17, 2016, 8:42 a.m. UTC | #2
Andreas Arnez <arnez@linux.vnet.ibm.com> writes:

> gdb/ChangeLog:
>
> 	* linux-record.c (record_linux_system_call): Add missing return
> 	statements to handling of pipe and pipe2 syscalls.

Patch is good to me.
Andreas Arnez March 17, 2016, 9:01 a.m. UTC | #3
On Thu, Mar 17 2016, Yao Qi wrote:

> Andreas Arnez <arnez@linux.vnet.ibm.com> writes:
>
>> gdb/ChangeLog:
>>
>> 	* linux-record.c (record_linux_system_call): Add missing return
>> 	statements to handling of pipe and pipe2 syscalls.
>
> Patch is good to me.

Thanks, pushed.
Andreas Arnez March 17, 2016, 12:50 p.m. UTC | #4
On Wed, Mar 16 2016, Marcin Koƛcielnicki wrote:

> On 16/03/16 19:54, Andreas Arnez wrote:
>> This patch added handling for some syscalls to linux-record.c:
>>
>>    https://sourceware.org/ml/gdb-patches/2015-10/msg00452.html
>>
>> But for both `pipe' and `pipe2' the patch lacks a statement after an
>> `if', such that the following `break' is interpreted as the `if'-body
>> instead.
>>
>> This adds the missing (return-) statements for the conditionals.
>
> Whoops, my bad.  This looks like obvious patch material.  Though I
> wonder why it wasn't detected earlier by someone running GCC 6 with
> its -Wmisleading-indentation warning - does it not catch it?

Right, it doesn't catch it (yet):

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66298

> Btw, it seems that cases gdb_sys_pipe2 and gdb_sys_pipe could be
> squashed into one.

Right, and a few other cases could be squashed as well.  Mabye I'll post
another patch for that...

--
Andreas
diff mbox

Patch

diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index a40845a..2e86936 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -354,6 +354,7 @@  record_linux_system_call (enum gdb_syscall syscall,
       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
       if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
 					 tdep->size_int * 2))
+        return -1;
       break;
 
     case gdb_sys_times:
@@ -2312,6 +2313,7 @@  Do you want to stop the program?"),
       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
       if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
 					 tdep->size_int * 2))
+        return -1;
       break;
 
     case gdb_sys_inotify_init1: