scripts/bpf: Print an error when known types list needs updating
Subsystems (4)
PATCH v2 1/1 scripts/bpf: Print an error when known types list needs updating
Don't generate a broken bpf_helper_defs.h header if the helper script needs updating because it doesn't recognize a newly added type. Instead print an error that explains why the build is failing, clean up the partially generated header and stop.
v1->v2:
- Switched from temporary file to .DELETE_ON_ERROR.
--- scripts/bpf_helpers_doc.py | 4 ++-- tools/lib/bpf/Makefile | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
scripts/bpf_helpers_doc.py +2 -2
@@ -488,8 +488,8 @@ class PrinterHelpers(Printer): return t if t in self.mapped_types: return self.mapped_types[t] - print("") - print("#error \"Unrecognized type '%s', please add it to known types!\"" % t) + print("Unrecognized type '%s', please add it to known types!" % t, + file=sys.stderr) sys.exit(1) seen_helpers = set()
tools/lib/bpf/Makefile +3 -0
@@ -286,3 +286,6 @@ tags: # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) + +# Delete partially updated (corrupted) files on error +.DELETE_ON_ERROR:
Signature · 1 line
2.20.1
Quoted 11 lines · Jakub Sitnicki
Don't generate a broken
bpf_helper_defs.hheader if the helper script needs updating because it doesn't recognize a newly added type. Instead print an error that explains why the build is failing, clean up the partially generated header and stop.
v1->v2:
- Switched from temporary file to .DELETE_ON_ERROR.Fixes 456a513bb5d4 ("scripts/bpf: Emit an #error directive known types list needs updating")Suggested-by Andrii Nakryiko <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>
Quoted 32 lines
--- scripts/bpf_helpers_doc.py | 4 ++-- tools/lib/bpf/Makefile | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)scripts/bpf_helpers_doc.py +2
-2@@ -488,8 +488,8 @@ class PrinterHelpers(Printer): return t if t in self.mapped_types: return self.mapped_types[t] - print("") - print("#error \"Unrecognized type '%s', please add it to known types!\"" % t) + print("Unrecognized type '%s', please add it to known types!" % t, + file=sys.stderr) sys.exit(1) seen_helpers = set()tools/lib/bpf/Makefile +3
-0@@ -286,3 +286,6 @@ tags: # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) + +# Delete partially updated (corrupted) files on error +.DELETE_ON_ERROR:
Quoted 6 lines · Jakub Sitnicki
Don't generate a broken
bpf_helper_defs.hheader if the helper script needs updating because it doesn't recognize a newly added type. Instead print an error that explains why the build is failing, clean up the partially generated header and stop.
Quoted 7 lines
v1->v2:
- Switched from temporary file to .DELETE_ON_ERROR.Fixes 456a513bb5d4 ("scripts/bpf: Emit an #error directive known types list needs updating")Suggested-by Andrii Nakryiko <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>---
LGTM, thanks!
Quoted 4 lines
scripts/bpf_helpers_doc.py | 4 ++-- tools/lib/bpf/Makefile | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
[...]
Alexei Starovoitov
AppliedQuoted 8 lines · Andrii Nakryiko
Quoted 6 lines · Jakub Sitnicki
Don't generate a broken
bpf_helper_defs.hheader if the helper script needs updating because it doesn't recognize a newly added type. Instead print an error that explains why the build is failing, clean up the partially generated header and stop.
Quoted 6 lines
Quoted 6 lines
v1->v2:
- Switched from temporary file to .DELETE_ON_ERROR.Fixes 456a513bb5d4 ("scripts/bpf: Emit an #error directive known types list needs updating")Suggested-by Andrii Nakryiko <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>
Applied.Thanks