devtools/reduce-includes.sh: don't remove our own .h from .c file includes.
What changed, and why it matters
This commit fixes a developer helper script so it no longer suggests removing a C source file's own matching header file from its #include list. It is a code-quality/build-hygiene fix, not a security patch.
No security action required. Treat as a normal build-tooling/code-quality fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change modifies devtools/reduce-includes.sh, a script used to find redundant #include directives. It now excludes the header that corresponds to the .c file being processed (e.g., foo.c’s own foo.h) from candidates for removal. The project enforces a rule that every .c must directly include its own .h, so the script was previously proposing removals that violated project policy. There is no runtime security issue here.
Changed components
devtools/reduce-includes.shInspect captured patch +3 / −1
diff --git a/devtools/reduce-includes.sh b/devtools/reduce-includes.sh
index 81e4f877..877f17de 100755
--- a/devtools/reduce-includes.sh
+++ b/devtools/reduce-includes.sh
@@ -7,11 +7,13 @@ fi
CCMD=$(make show-flags | sed -n 's/CC://p')
for file; do
+ # We have a rule (and a check!) that a .c includes its own .h directly.
+ OWN_HDR='<'$(echo "$file" | sed -n 's/\.c$/.h/p')'>'
i=1
echo "$file":
while true; do
# Don't eliminate config.h includes!
- LINE="$(grep '^#include <' "$file" | grep -v '[<"]config.h[">]' | tail -n +$i | head -n1)"
+ LINE="$(grep '^#include <' "$file" | grep -v '[<"]config.h[">]' | grep -F -v "$OWN_HDR" | tail -n +$i | head -n1)"
[ -n "$LINE" ] || break
# Make sure even headers end in .c
grep -F -v "$LINE" "$file" > "$file".c
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.