Remove unreachable code reported by Coverity Scan - #13551
Draft
bryancall wants to merge 1 commit into
Draft
Conversation
Each removal is provably unreachable, so there is no behavior change:
- The src_ip, src_ip_category and in_ip filter lambdas tested a pointer
that is the address of an array element, which is never null. The
surrounding bound check already returns before the address is taken.
- HttpCacheSM::open_write tested master_sm after it had already been
dereferenced nine lines earlier in the same function.
- A block in the read-while-write cache test followed two branches that
both returned unconditionally.
Also makes an early exit explicit after a Catch2 REQUIRE(false) in the header
test, and gives a test member an explicit initializer. Neither changes an
observed value; both remove a construct static analysis cannot see through.
Verified with a clean build (no new warnings) and the full unit test suite on
Fedora, GCC 16.1.1.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes Coverity-reported unreachable code paths across remap YAML ACL parsing, cache write handling, and unit tests, aiming to reduce dead branches without changing runtime behavior.
Changes:
- Simplifies YAML remap filter parsing by removing always-true pointer checks and unconditionally updating the corresponding counters/valid flags after bounds checks.
- Removes an ineffective
master_sm &&guard inHttpCacheSM::open_writewheremaster_smis already dereferenced earlier in the function. - Cleans up unreachable unit test control-flow and adds small analyzer-friendly adjustments (explicit
returnafterREQUIRE(false), explicit member initialization).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/proxy/http/remap/RemapYamlConfig.cc | Removes unreachable if (ipi) branches after taking addresses of fixed-array elements and keeps existing bounds checks. |
| src/proxy/http/HttpCacheSM.cc | Drops redundant master_sm && check in open_write after earlier unconditional dereferences of master_sm. |
| src/proxy/hdrs/unit_tests/test_Hdrs.cc | Adds an explicit return; after REQUIRE(false) to make the early-exit clear to readers/analysis. |
| src/iocore/cache/unit_tests/test_RWW.cc | Removes code after unconditional returns and makes the writer-abort intent explicit once the reader starts. |
| plugins/experimental/jax_fingerprint/ja4h/test.cc | Explicitly initializes a test member (_version{}) to satisfy static analysis. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Part 2 of 3 splitting a Coverity Scan cleanup into independently reviewable pieces. Net -13 lines; every removal is provably unreachable, so there is no behavior change.
Removals
YAML remap filters (
RemapYamlConfig.cc, three lambdas): each testedif (ipi)whereipiis&rule->src_ip_array[rule->src_ip_cnt], the address of an array element, which is never null. The surrounding>= ACL_FILTER_MAX_*bound check already returns before the address is taken, so there is no out-of-range address either.HttpCacheSM::open_write: testedmaster_sm &&aftermaster_sm->redirection_trieshad already been dereferenced nine lines earlier in the same function. Every other method in the file dereferences it unguarded. Whethermaster_smcan be null at all is a separate question worth its own look; the identical guard atopen_readis left in place.test_RWW.cc: a block sitting after anif/elsewhere both arms returned unconditionally. The flattened form is byte-for-byte equivalent in control flow, and the assertions that validate the writer abort are untouched.Two additions rather than removals
returnafter a Catch2REQUIRE(false)intest_Hdrs.cc.REQUIREthrows, so this is unreachable at runtime; it makes the exit visible to the compiler and to a reader.Both are there to remove a construct static analysis cannot see through. Happy to drop either if you would rather not carry analyzer-appeasement in the tree.
Verification
Clean build with no new warnings and the full unit test suite passing (134/134) on Fedora, GCC 16.1.1.
Draft while CI runs.