Skip to contentSkip to conversation

scripts/bpf: Emit an #error directive known types list needs updating

PATCH Applied Jakub Sitnicki 3 participants 4 messages Oct 16, 2019 – Oct 17, 2019

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

PATCH 1/1 scripts/bpf: Emit an #error directive known types list needs updating

Make the compiler report a clear error when bpf_helpers_doc.py needs updating rather than rely on the fact that Clang fails to compile English:

../../../lib/bpf/bpf_helper_defs.h:2707:1: error: unknown type name 'Unrecognized' Unrecognized type 'struct bpf_inet_lookup', please add it to known types!

---
 scripts/bpf_helpers_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/bpf_helpers_doc.py +1 -1
index 7df9ce598ff9..08300bc024da 100755
@@ -489,7 +489,7 @@ class PrinterHelpers(Printer):
         if t in self.mapped_types:
             return self.mapped_types[t]
         print("")
-        print("Unrecognized type '%s', please add it to known types!" % t)
+        print("#error \"Unrecognized type '%s', please add it to known types!\"" % t)
         sys.exit(1)
 
     seen_helpers = set()
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Jakub Sitnicki

Make the compiler report a clear error when bpf_helpers_doc.py needs updating rather than rely on the fact that Clang fails to compile English:

../../../lib/bpf/bpf_helper_defs.h:2707:1: error: unknown type name 'Unrecognized' Unrecognized type 'struct bpf_inet_lookup', please add it to known types!

Applied, thanks!

#2 lore raw
In reply to Jakub Sitnicki
Quoted 18 lines · Jakub Sitnicki

Make the compiler report a clear error when bpf_helpers_doc.py needs updating rather than rely on the fact that Clang fails to compile English:

../../../lib/bpf/bpf_helper_defs.h:2707:1: error: unknown type name 'Unrecognized' Unrecognized type 'struct bpf_inet_lookup', please add it to known types!

---
 scripts/bpf_helpers_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/bpf_helpers_doc.py +0 -0
index 7df9ce598ff9..08300bc024da 100755

scripts/bpf_helpers_doc.py class PrinterHelpers(Printer): · line 492

Quoted 5 lines
scripts/bpf_helpers_doc.py +1 -1
@@ -489,7 +489,7 @@ class PrinterHelpers(Printer):
         if t in self.mapped_types:
             return self.mapped_types[t]
         print("")
-        print("Unrecognized type '%s', please add it to known types!" % t)
+        print("#error \"Unrecognized type '%s', please add it to known types!\"" % t)

My bad, this was intended to be printed to stderr, not to stdout output. Can you please do a follow up patch turning this into eprint instead?

This shouldn't be reported by Clang, rather by tool. And we should ensure in libbpf's Makefile that bpf_helper_defs.h is deleted on error. I'll do it a bit later, unless you'll beat me to it.

Quoted 6 lines
scripts/bpf_helpers_doc.py +0 -1
         sys.exit(1)
 
     seen_helpers = set()
--

2.20.1

#3 lore raw
Quoted 29 lines · Andrii Nakryiko
Quoted 18 lines · Jakub Sitnicki

Make the compiler report a clear error when bpf_helpers_doc.py needs updating rather than rely on the fact that Clang fails to compile English:

../../../lib/bpf/bpf_helper_defs.h:2707:1: error: unknown type name 'Unrecognized' Unrecognized type 'struct bpf_inet_lookup', please add it to known types!

---
 scripts/bpf_helpers_doc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/bpf_helpers_doc.py +0 -0
index 7df9ce598ff9..08300bc024da 100755

scripts/bpf_helpers_doc.py class PrinterHelpers(Printer): · line 492

Quoted 5 lines
scripts/bpf_helpers_doc.py +1 -1
@@ -489,7 +489,7 @@ class PrinterHelpers(Printer):
         if t in self.mapped_types:
             return self.mapped_types[t]
         print("")
-        print("Unrecognized type '%s', please add it to known types!" % t)
+        print("#error \"Unrecognized type '%s', please add it to known types!\"" % t)

My bad, this was intended to be printed to stderr, not to stdout output. Can you please do a follow up patch turning this into eprint instead?

Quoted 3 lines

This shouldn't be reported by Clang, rather by tool. And we should ensure in libbpf's Makefile that bpf_helper_defs.h is deleted on error. I'll do it a bit later, unless you'll beat me to it.

This sounds sensible. I could have guessed it. Here's the fix:

https://lore.kernel.org/bpf/[email protected]/T/#u

-Jakub