tree: remove includes that nothing in the file uses - #4438
Merged
Conversation
Contributor
|
But there seems to be a misalignment now for RTAI, that needed a removed include. |
104 #include lines across 82 files, of 30 distinct in-tree headers. None of them provides a name the including file mentions. Found by taking the names each in-tree header declares, macros, typedefs, tags, prototypes, extern variables and enum members, and checking whether any of them appears in the file that includes it. A heuristic that size is going to be wrong somewhere, so nothing here rests on it: every candidate was then put to the compiler. 209 came out of the heuristic, all 209 were removed at once and the tree built, the files that failed had their includes put back, and this is what survived a build with all of them gone together. Configured --with-realtime=uspace, no errors and no warnings. That build does not cover everything. Five of the files are outside what a uspace configuration compiles, so they were read by hand instead, and two of them kept their include: rtai_ulapi.c needs rtapi_rtai_shm_wrap.h, which declares nothing itself and only wraps rtai_shm.h, and fifousr.c takes FIFO_KEY and FIFO_SIZE from an anonymous enum in its own common.h. The ones that repeat are rtapi_math.h 21 times, rtapi_string.h 15, config.h 10, block.h 7, rtapi_slab.h and rtapi_mutex.h 6 each. An include costs nothing to leave in place, which is why these accumulated, but it is not free to a reader or to a dependency graph: each one asserts a relationship between two directories that turns out not to exist.
grandixximo
force-pushed
the
unused-includes
branch
from
August 21, 2026 22:59
d66b122 to
813da03
Compare
Contributor
Author
|
Restored, the other three read by hand. 104 removals across 82 files now, directory edges unchanged at 131. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
104
#includelines across 82 files, of 30 distinct in-tree headers, that provide nothing the including file mentions. Removals only, no additions and no moves.This is the sweep referred to in #4411, held back until #4425 landed.
How they were found. Take the names each in-tree header declares, macros, typedefs, tags, prototypes, extern variables and enum members, and check whether any of them appears in the file that includes it. That heuristic is going to be wrong somewhere, so nothing rests on it: 209 candidates came out, all 209 were removed at once, the tree was built, and whatever failed had its include put back. What is here is what survived a build with all of them gone together,
--with-realtime=uspace, no errors and no warnings.That build does not cover everything. Five of the files are outside what a uspace configuration compiles, so those were read by hand instead, and two keep their include:
rtai_ulapi.cneedsrtapi_rtai_shm_wrap.h, which declares nothing itself and only wrapsrtai_shm.h, andfifousr.ctakesFIFO_KEYandFIFO_SIZEfrom an anonymous enum in its owncommon.h.What it buys. Against current master,
scripts/include-dep-report.pygoes from 137 directory edges and 1287 cross-directory include sites to 131 and 1213.The cycles do not move: still 3, covering 9 directories and 18 edges. I think that is the honest result and worth stating plainly. Dead includes inflate the picture, they are not what holds the knots together. The three remaining cycles are interface questions, not stray includes.
The ones that repeat are
rtapi_math.h21 times,rtapi_string.h15,config.h10,block.h7,rtapi_slab.handrtapi_mutex.h6 each.