Skip to contentSkip to conversation

samples/bpf: use canonical fallthrough pseudo-keyword in hbm.c

PATCH In review Andrii Nakryiko 3 participants 3 messages May 15, 2023 – May 16, 2023 BPF

lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 samples/bpf: use canonical fallthrough pseudo-keyword in hbm.c

Rename now unsupported __fallthrough into fallthrough ([0]) in samples/bpf/hbm.c to fix samples/bpf compilation.

[0] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

---
 samples/bpf/hbm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/hbm.c +1 -1
index 6448b7826107..7ddf25e9d098 100644
@@ -498,7 +498,7 @@ int main(int argc, char **argv)
 					"Option -%c requires an argument.\n\n",
 					optopt);
 		case 'h':
-			__fallthrough;
+			fallthrough;
 		default:
 			Usage();
 			return 0;
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Andrii Nakryiko

Rename now unsupported __fallthrough into fallthrough ([0]) in samples/bpf/hbm.c to fix samples/bpf compilation.

[0] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

LGTM. But there is an alternative, see below.

Quoted 9 lines
---
  samples/bpf/hbm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/hbm.c +0 -0
index 6448b7826107..7ddf25e9d098 100644

samples/bpf/hbm.c int main(int argc, char **argv) · line 501

Quoted 5 lines
samples/bpf/hbm.c +1 -1
@@ -498,7 +498,7 @@ int main(int argc, char **argv)
  					"Option -%c requires an argument.\n\n",
  					optopt);
  		case 'h':
-			__fallthrough;
+			fallthrough;

We could remove this 'fallthrough' completely since there is no code under case 'h'.

Quoted 3 lines
samples/bpf/hbm.c +0 -0
  		default:
  			Usage();
  			return 0;
#2 lore raw
Quoted 19 lines · Yonghong Song
Quoted 6 lines · Andrii Nakryiko

Rename now unsupported __fallthrough into fallthrough ([0]) in samples/bpf/hbm.c to fix samples/bpf compilation.

[0] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

LGTM. But there is an alternative, see below.

Quoted 4 lines
---
  samples/bpf/hbm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

samples/bpf/hbm.c int main(int argc, char **argv) · line 501

Quoted 10 lines
samples/bpf/hbm.c +1 -1
index 6448b7826107..7ddf25e9d098 100644
@@ -498,7 +498,7 @@ int main(int argc, char **argv)
                                      "Option -%c requires an argument.\n\n",
                                      optopt);
              case 'h':
-                     __fallthrough;
+                     fallthrough;

We could remove this 'fallthrough' completely since there is no code under case 'h'.

yep, should have done it from the get go, will send v2

Quoted 4 lines
Quoted 4 lines
samples/bpf/hbm.c +0 -0
              default:
                      Usage();
                      return 0;