samples/bpf: Fix a compilation error with fallthrough marking
authorYonghong Song <yhs@fb.com>
Tue, 6 Oct 2020 04:34:27 +0000 (21:34 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 6 Oct 2020 18:45:03 +0000 (11:45 -0700)
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 <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201006043427.1891805-1-yhs@fb.com
samples/bpf/hbm.c

index 4b22ace52f8051be9a86ba5ad4413aa7718c056d..ff4c533dfac2981c1f0f965739b6b8d65f1dea47 100644 (file)
@@ -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>
@@ -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;