Skip to contentSkip to conversation

selftests/bpf: fix flexible_array.cocci warnings

PATCH In review Julia Lawall 4 participants 4 messages Jan 22, 2022 – Jan 25, 2022

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

PATCH 1/1 selftests/bpf: fix flexible_array.cocci warnings

From: kernel test robot <[email protected]>

Zero-length and one-element arrays are deprecated, see Documentation/process/deprecated.rst Flexible-array members should be used instead.

Generated by: scripts/coccinelle/misc/flexible_array.cocci

---

url:    https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Introduce-unstable-CT-lookup-helpers/20220115-004219
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master

:::::: branch date: 8 days ago
:::::: commit date: 8 days ago

Since this is a test, I don't know if you want to change it.

 test_run.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpf/test_run.c +1 -1
@@ -293,7 +293,7 @@ struct prog_test_fail2 {
 struct prog_test_fail3 {
 	int len;
 	char arr1[2];
-	char arr2[0];
+	char arr2[];
 };
 
 noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb)
#1 lore raw
Quoted 13 lines · Julia Lawall

From: kernel test robot <[email protected]>

Zero-length and one-element arrays are deprecated, see Documentation/process/deprecated.rst Flexible-array members should be used instead.

Generated by: scripts/coccinelle/misc/flexible_array.cocci

Quoted 8 lines

---

url:    https://github.com/0day-ci/linux/commits/Kumar-Kartikeya-Dwivedi/Introduce-unstable-CT-lookup-helpers/20220115-004219
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master

:::::: branch date: 8 days ago
:::::: commit date: 8 days ago

Since this is a test, I don't know if you want to change it.

We can definitely change it. It is just used for testing a type check in the verifier. Please resend this to bpf(a)vger.kernel.org, with [PATCH bpf-next] in subject, and use bpf: as prefix instead of selftests/bpf:, and add a Fixes: tag for the commit in bpf-next introducing it

Fixes c1ff181ffabc ("selftests/bpf: Extend kfunc selftests")
Quoted 15 lines
 test_run.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpf/test_run.c +1 -1
@@ -293,7 +293,7 @@ struct prog_test_fail2 {
 struct prog_test_fail3 {
        int len;
        char arr1[2];
-       char arr2[0];
+       char arr2[];
 };
 
 noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb)
#2 lore raw

[PATCH bpf-next] bpf: fix flexible_array.cocci warnings

net/bpf/test_run.c:296:6-10: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

From: kernel test robot <[email protected]>

net/bpf/test_run.c:296:6-10: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Zero-length and one-element arrays are deprecated, see Documentation/process/deprecated.rst Flexible-array members should be used instead.

Generated by: scripts/coccinelle/misc/flexible_array.cocci

Fixes c1ff181ffabc ("selftests/bpf: Extend kfunc selftests")
CC Kumar Kartikeya Dwivedi <[email protected]>
 test_run.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpf/test_run.c +1 -1
@@ -293,7 +293,7 @@ struct prog_test_fail2 {
 struct prog_test_fail3 {
 	int len;
 	char arr1[2];
-	char arr2[0];
+	char arr2[];
 };
 
 noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb)
maintainer
#3 lore raw

Re: [PATCH bpf-next] bpf: fix flexible_array.cocci warnings

Quoted 9 lines · kernel test robot

From: kernel test robot <[email protected]>

net/bpf/test_run.c:296:6-10: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Zero-length and one-element arrays are deprecated, see Documentation/process/deprecated.rst Flexible-array members should be used instead.

Quoted 7 lines

Generated by: scripts/coccinelle/misc/flexible_array.cocci

Fixes c1ff181ffabc ("selftests/bpf: Extend kfunc selftests")
CC Kumar Kartikeya Dwivedi <[email protected]>

Duplicate? Already applied via:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ed8bb03222c965290026c8ead5a902f4140f5440

Quoted 15 lines
  test_run.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/bpf/test_run.c +1 -1
@@ -293,7 +293,7 @@ struct prog_test_fail2 {
  struct prog_test_fail3 {
  	int len;
  	char arr1[2];
-	char arr2[0];
+	char arr2[];
  };
 
  noinline void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb)