[v1,2/2] selftests: kselftest_harness: Fix compile warning
diff mbox series

Message ID 20170611123258.19624-3-mic@digikod.net
State New, archived
Headers show
Series
  • Fix kselftest_harness regression
Related show

Commit Message

Mickaël Salaün June 11, 2017, 12:32 p.m. UTC
Do not confuse the compiler with a semicolon preceding a block. Replace
the semicolon with an empty block to avoid a warning:

  gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
  In file included from seccomp_bpf.c:40:0:
  seccomp_bpf.c: In function ‘change_syscall’:
  ../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
    for (; _metadata->trigger;  _metadata->trigger = __bail(_assert))
    ^
  ../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
   } while (0); OPTIONAL_HANDLER(_assert)
                ^~~~~~~~~~~~~~~~
  ../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
    __EXPECT(expected, seen, ==, 0)
    ^~~~~~~~
  seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
    EXPECT_EQ(0, ret);
    ^~~~~~~~~
  seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
    {
    ^

Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Will Drewry <wad@chromium.org>
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kees Cook June 12, 2017, 2:22 a.m. UTC | #1
On Sun, Jun 11, 2017 at 5:32 AM, Mickaël Salaün <mic@digikod.net> wrote:
> Do not confuse the compiler with a semicolon preceding a block. Replace
> the semicolon with an empty block to avoid a warning:
>
>   gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
>   In file included from seccomp_bpf.c:40:0:
>   seccomp_bpf.c: In function ‘change_syscall’:
>   ../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
>     for (; _metadata->trigger;  _metadata->trigger = __bail(_assert))
>     ^
>   ../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
>    } while (0); OPTIONAL_HANDLER(_assert)
>                 ^~~~~~~~~~~~~~~~
>   ../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
>     __EXPECT(expected, seen, ==, 0)
>     ^~~~~~~~
>   seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
>     EXPECT_EQ(0, ret);
>     ^~~~~~~~~
>   seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
>     {
>     ^
>
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Shuah Khan <shuahkh@osg.samsung.com>
> Cc: Will Drewry <wad@chromium.org>

Eek, thanks for catching that. :)

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 7ba94efb24fd..18dad07ae16b 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -1310,7 +1310,7 @@ void change_syscall(struct __test_metadata *_metadata,
>         iov.iov_len = sizeof(regs);
>         ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
>  #endif
> -       EXPECT_EQ(0, ret);
> +       EXPECT_EQ(0, ret) {}
>
>  #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
>      defined(__s390__) || defined(__hppa__)
> --
> 2.11.0
>
Shuah Khan June 12, 2017, 8:31 p.m. UTC | #2
On 06/11/2017 08:22 PM, Kees Cook wrote:
> On Sun, Jun 11, 2017 at 5:32 AM, Mickaël Salaün <mic@digikod.net> wrote:
>> Do not confuse the compiler with a semicolon preceding a block. Replace
>> the semicolon with an empty block to avoid a warning:
>>
>>   gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /.../linux/tools/testing/selftests/seccomp/seccomp_bpf
>>   In file included from seccomp_bpf.c:40:0:
>>   seccomp_bpf.c: In function ‘change_syscall’:
>>   ../kselftest_harness.h:558:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
>>     for (; _metadata->trigger;  _metadata->trigger = __bail(_assert))
>>     ^
>>   ../kselftest_harness.h:574:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
>>    } while (0); OPTIONAL_HANDLER(_assert)
>>                 ^~~~~~~~~~~~~~~~
>>   ../kselftest_harness.h:440:2: note: in expansion of macro ‘__EXPECT’
>>     __EXPECT(expected, seen, ==, 0)
>>     ^~~~~~~~
>>   seccomp_bpf.c:1313:2: note: in expansion of macro ‘EXPECT_EQ’
>>     EXPECT_EQ(0, ret);
>>     ^~~~~~~~~
>>   seccomp_bpf.c:1317:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
>>     {
>>     ^
>>
>> Signed-off-by: Mickaël Salaün <mic@digikod.net>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Shuah Khan <shuahkh@osg.samsung.com>
>> Cc: Will Drewry <wad@chromium.org>
> 
> Eek, thanks for catching that. :)
> 
> Acked-by: Kees Cook <keescook@chromium.org>
> 
> -Kees

Thanks. Ths fix is now in linux-kselftest next.

-- Shuah

Patch
diff mbox series

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 7ba94efb24fd..18dad07ae16b 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1310,7 +1310,7 @@  void change_syscall(struct __test_metadata *_metadata,
 	iov.iov_len = sizeof(regs);
 	ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
 #endif
-	EXPECT_EQ(0, ret);
+	EXPECT_EQ(0, ret) {}
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
     defined(__s390__) || defined(__hppa__)