devtools: check uAPI headers inclusions
PATCH 1/1 devtools: check uAPI headers inclusions
Imported Linux kernel uAPI headers must be included before any other header to avoid a system-installed header being read instead.
Add a check that runs after every operation to catch files where Linux uapi includes are preceded by other includes.
--- devtools/linux-uapi.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
devtools/linux-uapi.sh +25 -0
@@ -138,6 +138,29 @@ check_header() return 0 } +check_include_order() +{ + local errors=0 + + $quiet || echo "Checking uapi/linux inclusion order" + for filename in $(git grep -l '#include <uapi/linux/' ':!devtools/linux-uapi.sh' \ + ':!doc/guides/contributing/linux_uapi.rst' ':!kernel/linux/uapi/'); do + last_uapi=$(grep -n '#include <uapi/linux/' "$filename" | tail -1 | cut -d: -f1) + first_other=$(grep -n '^#include' "$filename" | grep -v 'uapi/linux/' | + head -1 | cut -d: -f1) + if [ -z "$first_other" ] || [ "$first_other" -gt "$last_uapi" ]; then + continue; + fi + $quiet || echo "$filename: uapi headers must be included before other headers" + errors=$((errors + 1)) + done + if [ $errors -ne 0 ] || ! $quiet; then + echo "$errors error(s) found in uapi inclusion order" + fi + + return $errors +} + check_all() { local errors=0
@@ -192,3 +215,5 @@ if $check_headers; then else update_all fi + +check_include_order
Signature · 1 line
2.56.0
Quoted 4 lines · David Marchand
Imported Linux kernel uAPI headers must be included before any other header to avoid a system-installed header being read instead.
Quoted 8 lines
Add a check that runs after every operation to catch files where Linux uapi includes are preceded by other includes.
Signed-off-by David Marchand <[email protected]>--- devtools/linux-uapi.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Thanks,
Maxime
David Marchand
AppliedQuoted 10 lines · Maxime Coquelin
Quoted 8 lines · David Marchand
Imported Linux kernel uAPI headers must be included before any other header to avoid a system-installed header being read instead.
Add a check that runs after every operation to catch files where Linux uapi includes are preceded by other includes.
Signed-off-by David Marchand <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand