[dhcpmon] Clean up source include dependencies#88
Open
Xichen96 wants to merge 1 commit into
Open
Conversation
Make headers self-contained, move implementation-only dependencies into source files, and remove unused or redundant imports. This keeps compile dependencies explicit without changing runtime behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: be978a4b-32ee-4a29-bd1c-3699552d52d0 Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR refactors the C++ include structure to make dependencies explicit, reduce transitive-include reliance, and keep public headers self-contained—helping keep compilation dependencies stable as the codebase evolves.
Changes:
- Updated public headers to directly include standard/library headers required by their exposed APIs and inline helpers.
- Moved implementation-only dependencies (e.g.,
<memory>,<vector>,<errno.h>) into.cppfiles where the symbols are actually used. - Removed unused/redundant includes across multiple translation units to reduce coupling.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/util.h | Makes the header self-contained for its inline helpers and exported APIs (adds required C/stdlib and <utility> includes; drops transitive deps like <memory>). |
| src/util.cpp | Adds direct implementation includes required for exceptions, smart pointers, and stdio/stdlib usage. |
| src/sock_mgr.h | Adds <stddef.h> so size_t usage in the header doesn’t rely on transitive includes. |
| src/sock_mgr.cpp | Adds direct includes (<arpa/inet.h>, <memory>) used by the implementation. |
| src/packet_handler.h | Switches to <string> for the public interface types and drops unused <string.h> from the header. |
| src/packet_handler.cpp | Adds direct includes used by the implementation (<errno.h>, <string.h>, <vector>). |
| src/main.cpp | Removes unused headers and adds direct includes required by the file’s usage (stdint/stdio). |
| src/dhcp_mon.h | Adds <stddef.h> to make the size_t API self-contained. |
| src/dhcp_mon.cpp | Moves implementation-only includes into the .cpp and removes unused ones. |
| src/dhcp_devman.h | Removes unused <stdint.h> from the header. |
| src/dhcp_devman.cpp | Adds <memory> to cover smart pointer declarations used in the implementation. |
| src/dhcp_device.cpp | Adds direct includes for errno/stdlib/socket and unordered containers used in the implementation. |
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.
Description of PR
Summary:
Make source dependencies explicit and keep public headers self-contained. The change removes unused or redundant includes, moves implementation-only dependencies into
.cppfiles, and adds direct includes where code previously relied on transitive imports.Dependencies: None.
Work item tracking
Type of change
Approach
What is the motivation for this PR?
Several files rely on unrelated headers to expose declarations such as
errno, smart pointers, fixed-width integers, andsize_t. Other files retain imports they do not use. This makes compilation dependencies fragile and increases header coupling.How did you do it?
util.hand into their implementation users.How did you verify/test it?
1173128passed for amd64, arm64, and armhf; DCO passed.Any platform specific information?
No. This is a compile-dependency cleanup with no runtime or platform-specific behavior change.
Back port request
None.
Tested branch
Test result
PR CI passed on amd64, arm64, and armhf.
Documentation
Not applicable; there is no user-facing behavior or interface change.