Skip to contentSkip to conversation

selftests: seccomp: fix format-zero-length warnings

PATCH Superseded Amer Al Shanawany 3 participants 8 messages Jun 3, 2024 – Jun 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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("");
| ^~

---
 tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +3 -3
index b83099160fbc..ed04b89de9c6 100644
@@ -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();
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 25 lines · Amer Al Shanawany

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("");
| ^~

---
  tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -0
index b83099160fbc..ed04b89de9c6 100644

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 197

Quoted 5 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +1 -1
@@ -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?

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 202

Quoted 6 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +1 -1
  	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?

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 204

Quoted 3 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +1 -1
  	system("grep -H . /proc/sys/net/core/bpf_jit_enable");
-	ksft_print_msg("");
+	ksft_print_msg(" ");

Why not delete this all together?

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 207

Quoted 3 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -0
  	system("grep -H . /proc/sys/net/core/bpf_jit_harden");
 
  	affinity();

thanks,
-- Shuah

#2 lore raw

PATCH v2 1/1 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("");
| ^~

---
Changes v1 -> v2:
removed empty print statements

---
 tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
 1 file changed, 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -3
index b83099160fbc..6fe34be6c693 100644
@@ -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();
Signature · 1 line
2.43.0
maintainer
#3 lore raw
Quoted 14 lines · Amer Al Shanawany

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("");
| ^~

Quoted 6 lines

---
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.

Quoted 13 lines
---
  tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
  1 file changed, 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -1
index b83099160fbc..6fe34be6c693 100644
@@ -194,14 +194,11 @@ int main(int argc, char *argv[])
  	ksft_set_plan(7);
 
  	ksft_print_msg("Running on:\n");
-	ksft_print_msg("");

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 204

Quoted 10 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -2
  	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

maintainer
#4 lore raw
Quoted 22 lines · Shuah Khan
Quoted 14 lines · Amer Al Shanawany

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("");
| ^~

Quoted 6 lines

---
Changes v1 -> v2:
removed empty print statements

Quoted 6 lines

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

Quoted 25 lines
Quoted 11 lines
---
  tools/testing/selftests/seccomp/seccomp_benchmark.c | 3 ---
  1 file changed, 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -0
index b83099160fbc..6fe34be6c693 100644
@@ -194,14 +194,11 @@ int main(int argc, char *argv[])
  	ksft_set_plan(7);

tools/testing/selftests/seccomp/seccomp_benchmark.c int main(int argc, char *argv[]) · line 201

Quoted 10 lines
tools/testing/selftests/seccomp/seccomp_benchmark.c +0 -3
  	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

Signature · 1 line
Kees Cook
maintainer
#5 lore raw
Quoted 40 lines · Kees Cook
Quoted 22 lines · Shuah Khan
Quoted 14 lines · Amer Al Shanawany

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("");
        |                        ^~
Quoted 6 lines

---
Changes v1 -> v2:
removed empty print statements

Quoted 6 lines

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

Quoted 9 lines

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

#6 lore raw

PATCH v3 1/1 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("");
| ^~

---
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(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +3 -3
index b83099160fbc..94886c82ae60 100644
@@ -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();
Signature · 1 line
2.43.0
maintainer Reviewed-by on v3 1/1
#7 lore raw
Quoted 16 lines · Amer Al Shanawany

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("");
| ^~

Quoted 4 lines

Thanks!

Signature · 1 line
Kees Cook