Skip to content

Commit

Permalink
samples/bpf: Fix a compilation error with fallthrough marking
Browse files Browse the repository at this point in the history
Compiling samples/bpf hits an error related to fallthrough marking.
    ...
    CC  samples/bpf/hbm.o
  samples/bpf/hbm.c: In function ‘main’:
  samples/bpf/hbm.c:486:4: error: ‘fallthrough’ undeclared (first use in this function)
      fallthrough;
      ^~~~~~~~~~~

The "fallthrough" is not defined under tools/include directory.
Rather, it is "__fallthrough" is defined in linux/compiler.h.
Including "linux/compiler.h" and using "__fallthrough" fixed the issue.

Signed-off-by: Yonghong Song <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
yonghong-song authored and Alexei Starovoitov committed Oct 6, 2020
1 parent 9618bde commit 544d6ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion samples/bpf/hbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/unistd.h>
#include <linux/compiler.h>

#include <linux/bpf.h>
#include <bpf/bpf.h>
Expand Down Expand Up @@ -483,7 +484,7 @@ int main(int argc, char **argv)
"Option -%c requires an argument.\n\n",
optopt);
case 'h':
fallthrough;
__fallthrough;
default:
Usage();
return 0;
Expand Down

0 comments on commit 544d6ad

Please sign in to comment.