Re: [PATCH v1 2/2] selftests: kselftest_harness: Fix compile warning

From: Shuah Khan
Date: Mon Jun 12 2017 - 16:31:28 EST


On 06/11/2017 08:22 PM, Kees Cook wrote:
> On Sun, Jun 11, 2017 at 5:32 AM, MickaÃl SalaÃn <mic@xxxxxxxxxxx> 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@xxxxxxxxxxx>
>> Cc: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
>> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
>> Cc: Shuah Khan <shuahkh@xxxxxxxxxxxxxxx>
>> Cc: Will Drewry <wad@xxxxxxxxxxxx>
>
> Eek, thanks for catching that. :)
>
> Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> -Kees

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

-- Shuah