[SERVER-66956] Coverity analysis defect 122327: Redundant test Created: 02/Jun/22  Updated: 29/Oct/23  Resolved: 23/Jun/22

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 6.1.0-rc0, 5.0.16

Type: Improvement Priority: Minor - P4
Reporter: Coverity Collector User Assignee: Daniel Segel
Resolution: Fixed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2022-06-02 at 9.35.08 AM.png    
Issue Links:
Backports
Problem/Incident
is caused by SERVER-64349 Add heuristic-based planning support ... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.0, v5.0
Sprint: QO 2022-06-13, QO 2022-06-27
Participants:

 Description   

Redundant test

By the time the program execution reaches the test of this condition there is only one possible outcome for the test. The code at the destination of this branch is not dead, either because this condition is always true or because there is at least one other branch that reaches it. Test always evaluates the same
/src/mongo/db/pipeline/pipeline_d.cpp:1186: DEADCODE 122327 At condition "mps", the value of "mps" cannot be "nullptr".
/src/mongo/db/pipeline/pipeline_d.cpp:1186: DEADCODE 122327 Assigning: "mps" = "static_cast<mongo::MultiPlanStage *>(rootStage)".
/src/mongo/db/pipeline/pipeline_d.cpp:1175: DEADCODE 122327 Condition "rootStage", taking true branch. Now the value of "rootStage" is not "nullptr".
/src/mongo/db/pipeline/pipeline_d.cpp:1186: DEADCODE 122327 The condition "mps" must be true.



 Comments   
Comment by Githook User [ 21/Feb/23 ]

Author:

{'name': 'Daniel Segel', 'email': 'daniel_segel@brown.edu', 'username': 'dhsegel'}

Message: SERVER-66956 Remove redundant tests in MULTI_PLAN and CACHED_PLAN
Branch: v5.0
https://github.com/mongodb/mongo/commit/df44825889a702664fd9424e2c3422c99ac1ed75

Comment by Sam Mercier [ 23/Jun/22 ]

Sure!

Comment by Githook User [ 23/Jun/22 ]

Author:

{'name': 'Daniel Segel', 'email': 'daniel_segel@brown.edu', 'username': 'dhsegel'}

Message: SERVER-66956 Remove redundant tests in MULTI_PLAN and CACHED_PLAN
Branch: master
https://github.com/mongodb/mongo/commit/7ad5fbf86418d2a6f17d553b5888198c5f9de05a

Comment by Kyle Suarez [ 23/Jun/22 ]

daniel.segel@mongodb.com and samuel.mercier@mongodb.com, since SERVER-64349 is in v6.0 does it make sense to request backport of this to 6.0?

Comment by Kyle Suarez [ 02/Jun/22 ]

There's no need for the wrapping if-statement on line 1186 because the static_cast of a non-null pointer won't ever be nullptr. Ditto the if and static_cast on line 1197.

Generated at Thu Feb 08 06:06:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.