2024-06-03 12:02:29

by Amer Al Shanawany

[permalink] [raw]
Subject: [PATCH] selftests: seccomp: fix format-zero-length warnings

seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
197 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
202 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
204 | ksft_print_msg("");
| ^~

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Amer Al Shanawany <[email protected]>
---
tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
index b83099160fbc..ed04b89de9c6 100644
--- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
+++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
@@ -194,14 +194,14 @@ int main(int argc, char *argv[])
ksft_set_plan(7);

ksft_print_msg("Running on:\n");
- ksft_print_msg("");
+ ksft_print_msg(" ");
system("uname -a");

ksft_print_msg("Current BPF sysctl settings:\n");
/* Avoid using "sysctl" which may not be installed. */
- ksft_print_msg("");
+ ksft_print_msg(" ");
system("grep -H . /proc/sys/net/core/bpf_jit_enable");
- ksft_print_msg("");
+ ksft_print_msg(" ");
system("grep -H . /proc/sys/net/core/bpf_jit_harden");

affinity();
--
2.43.0



2024-06-06 22:42:12

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] selftests: seccomp: fix format-zero-length warnings

On 6/3/24 05:54, Amer Al Shanawany wrote:
> seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 197 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 202 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 204 | ksft_print_msg("");
> | ^~
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Amer Al Shanawany <[email protected]>
> ---
> tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> index b83099160fbc..ed04b89de9c6 100644
> --- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
> +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> @@ -194,14 +194,14 @@ int main(int argc, char *argv[])
> ksft_set_plan(7);
>
> ksft_print_msg("Running on:\n");
> - ksft_print_msg("");
> + ksft_print_msg(" ");

Why not delete this all together?

> system("uname -a");
>
> ksft_print_msg("Current BPF sysctl settings:\n");
> /* Avoid using "sysctl" which may not be installed. */
> - ksft_print_msg("");
> + ksft_print_msg(" ");

Why not delete this all together?

> system("grep -H . /proc/sys/net/core/bpf_jit_enable");
> - ksft_print_msg("");
> + ksft_print_msg(" ");

Why not delete this all together?

> system("grep -H . /proc/sys/net/core/bpf_jit_harden");
>
> affinity();

thanks,
-- Shuah


2024-06-07 12:48:07

by Amer Al Shanawany

[permalink] [raw]
Subject: [PATCH v2] selftests: seccomp: fix format-zero-length warnings

fix the following errors by removing empty print statements:
seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
197 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
202 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
204 | ksft_print_msg("");
| ^~

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Amer Al Shanawany <[email protected]>
---
Changes v1 -> v2:
removed empty print statements
---
tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
index b83099160fbc..6fe34be6c693 100644
--- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
+++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
@@ -194,14 +194,11 @@ int main(int argc, char *argv[])
ksft_set_plan(7);

ksft_print_msg("Running on:\n");
- ksft_print_msg("");
system("uname -a");

ksft_print_msg("Current BPF sysctl settings:\n");
/* Avoid using "sysctl" which may not be installed. */
- ksft_print_msg("");
system("grep -H . /proc/sys/net/core/bpf_jit_enable");
- ksft_print_msg("");
system("grep -H . /proc/sys/net/core/bpf_jit_harden");

affinity();
--
2.43.0


2024-06-07 20:58:59

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH v2] selftests: seccomp: fix format-zero-length warnings

On 6/7/24 06:41, Amer Al Shanawany wrote:
> fix the following errors by removing empty print statements:
> seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 197 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 202 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 204 | ksft_print_msg("");
> | ^~
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Amer Al Shanawany <[email protected]>
> ---
> Changes v1 -> v2:
> removed empty print statements

Kees,

Is this change okay with you. I didn't see any use for
these empty ksft_print_msg().

I will take this patch if you are okay with the change.

> ---
> tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> index b83099160fbc..6fe34be6c693 100644
> --- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
> +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> @@ -194,14 +194,11 @@ int main(int argc, char *argv[])
> ksft_set_plan(7);
>
> ksft_print_msg("Running on:\n");
> - ksft_print_msg("");
> system("uname -a");
>
> ksft_print_msg("Current BPF sysctl settings:\n");
> /* Avoid using "sysctl" which may not be installed. */
> - ksft_print_msg("");
> system("grep -H . /proc/sys/net/core/bpf_jit_enable");
> - ksft_print_msg("");
> system("grep -H . /proc/sys/net/core/bpf_jit_harden");
>
> affinity();


thanks,
-- Shuah

2024-06-10 17:07:02

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v2] selftests: seccomp: fix format-zero-length warnings

On Fri, Jun 07, 2024 at 02:58:47PM -0600, Shuah Khan wrote:
> On 6/7/24 06:41, Amer Al Shanawany wrote:
> > fix the following errors by removing empty print statements:
> > seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
> > string [-Wformat-zero-length]
> > 197 | ksft_print_msg("");
> > | ^~
> > seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
> > string [-Wformat-zero-length]
> > 202 | ksft_print_msg("");
> > | ^~
> > seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
> > string [-Wformat-zero-length]
> > 204 | ksft_print_msg("");
> > | ^~
> >
> > Reported-by: kernel test robot <[email protected]>
> > Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> > Signed-off-by: Amer Al Shanawany <[email protected]>
> > ---
> > Changes v1 -> v2:
> > removed empty print statements
>
> Kees,
>
> Is this change okay with you. I didn't see any use for
> these empty ksft_print_msg().
>
> I will take this patch if you are okay with the change.

Dropping these means that the "#" marks go missing. Currently:

# Running on:
# Linux proton 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

with the proposed patch:

# Running on:
Linux proton 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

This breaks the TAP syntax for the test, so we should find a different
solution.

Perhaps:

ksft_print_msg("%s", "");

?

-Kees


>
> > ---
> > tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> > index b83099160fbc..6fe34be6c693 100644
> > --- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
> > +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> > @@ -194,14 +194,11 @@ int main(int argc, char *argv[])
> > ksft_set_plan(7);
> > ksft_print_msg("Running on:\n");
> > - ksft_print_msg("");
> > system("uname -a");
> > ksft_print_msg("Current BPF sysctl settings:\n");
> > /* Avoid using "sysctl" which may not be installed. */
> > - ksft_print_msg("");
> > system("grep -H . /proc/sys/net/core/bpf_jit_enable");
> > - ksft_print_msg("");
> > system("grep -H . /proc/sys/net/core/bpf_jit_harden");
> > affinity();
>
>
> thanks,
> -- Shuah

--
Kees Cook

2024-06-11 14:46:52

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH v2] selftests: seccomp: fix format-zero-length warnings

On 6/10/24 10:59, Kees Cook wrote:
> On Fri, Jun 07, 2024 at 02:58:47PM -0600, Shuah Khan wrote:
>> On 6/7/24 06:41, Amer Al Shanawany wrote:
>>> fix the following errors by removing empty print statements:
>>> seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
>>> string [-Wformat-zero-length]
>>> 197 | ksft_print_msg("");
>>> | ^~
>>> seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
>>> string [-Wformat-zero-length]
>>> 202 | ksft_print_msg("");
>>> | ^~
>>> seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
>>> string [-Wformat-zero-length]
>>> 204 | ksft_print_msg("");
>>> | ^~
>>>
>>> Reported-by: kernel test robot <[email protected]>
>>> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>>> Signed-off-by: Amer Al Shanawany <[email protected]>
>>> ---
>>> Changes v1 -> v2:
>>> removed empty print statements
>>
>> Kees,
>>
>> Is this change okay with you. I didn't see any use for
>> these empty ksft_print_msg().
>>
>> I will take this patch if you are okay with the change.
>
> Dropping these means that the "#" marks go missing. Currently:
>
> # Running on:
> # Linux proton 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
>
> with the proposed patch:
>
> # Running on:
> Linux proton 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
>
> This breaks the TAP syntax for the test, so we should find a different
> solution.
>
> Perhaps:
>
> ksft_print_msg("%s", "");
>
> ?
>

Thank you Kees. Yes that would work.

Amer, please send me v3 based on Kees's suggestions.

thanks,
-- Shuah


2024-06-11 15:17:28

by Amer Al Shanawany

[permalink] [raw]
Subject: [PATCH v3] selftests: seccomp: fix format-zero-length warnings

fix the following errors by using string format specifier and an empty
parameter:

seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
197 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
202 | ksft_print_msg("");
| ^~
seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
string [-Wformat-zero-length]
204 | ksft_print_msg("");
| ^~

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Suggested-by: Kees Cook <[email protected]>
Signed-off-by: Amer Al Shanawany <[email protected]>
---
v1 -> v2: removed empty print statements
v2 -> v3: used Kees's suggestion
---
tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
index b83099160fbc..94886c82ae60 100644
--- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
+++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
@@ -194,14 +194,14 @@ int main(int argc, char *argv[])
ksft_set_plan(7);

ksft_print_msg("Running on:\n");
- ksft_print_msg("");
+ ksft_print_msg("%s", "");
system("uname -a");

ksft_print_msg("Current BPF sysctl settings:\n");
/* Avoid using "sysctl" which may not be installed. */
- ksft_print_msg("");
+ ksft_print_msg("%s", "");
system("grep -H . /proc/sys/net/core/bpf_jit_enable");
- ksft_print_msg("");
+ ksft_print_msg("%s", "");
system("grep -H . /proc/sys/net/core/bpf_jit_harden");

affinity();
--
2.43.0


2024-06-12 19:09:16

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v3] selftests: seccomp: fix format-zero-length warnings

On Tue, Jun 11, 2024 at 05:16:08PM +0200, Amer Al Shanawany wrote:
> fix the following errors by using string format specifier and an empty
> parameter:
>
> seccomp_benchmark.c:197:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 197 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:202:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 202 | ksft_print_msg("");
> | ^~
> seccomp_benchmark.c:204:24: warning: zero-length gnu_printf format
> string [-Wformat-zero-length]
> 204 | ksft_print_msg("");
> | ^~
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Suggested-by: Kees Cook <[email protected]>
> Signed-off-by: Amer Al Shanawany <[email protected]>

Thanks!

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook