[SERVER-32221] Coverity analysis defect 102259: Redundant test Created: 08/Dec/17  Updated: 30/Oct/23  Resolved: 29/Dec/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 3.7.1

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2018-01-01, Query 2018-01-15
Participants:

 Description   

Test always evaluates the same

Defect 102259 (STATIC_C)
Checker DEADCODE (subcategory redundant_test)
File: /src/mongo/db/pipeline/document_source_sort.cpp
Function mongo::DocumentSourceSort::doOptimizeAt(std::List_iterator<boost::intrusive_ptr<mongo::DocumentSource>>, std::_cxx11::list<boost::intrusive_ptr<mongo::DocumentSource>, std::allocator<boost::intrusive_ptr<mongo::DocumentSource>>> *)
/src/mongo/db/pipeline/document_source_sort.cpp, line: 206
At condition "nextSkip", the value of "nextSkip" must be "NULL".

            } else if (!nextStage->constraints().canSwapWithLimit && !nextSkip) {

/src/mongo/db/pipeline/document_source_sort.cpp, line: 197
Condition "nextSkip", taking false branch. Now the value of "nextSkip" is "NULL".

            if (auto nextSkip = dynamic_cast<DocumentSourceSkip*>(nextStage)) {

/src/mongo/db/pipeline/document_source_sort.cpp, line: 206
The condition "!nextSkip" must be true.

            } else if (!nextStage->constraints().canSwapWithLimit && !nextSkip) {



 Comments   
Comment by Githook User [ 29/Dec/17 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@10gen.com'}

Message: SERVER-32221 Remove unnecessary null check in DocumentSourceSort.
Branch: master
https://github.com/mongodb/mongo/commit/4af16ae93ff1de3597ba36c6b7539fa851387b48

Comment by David Storch [ 08/Dec/17 ]

kyle.suarez, yeah, I think it's worth cleaning this up while it's fresh in our heads. It looks like a trivial fix. Assigning to you for next sprint.

Comment by Kyle Suarez [ 08/Dec/17 ]

charlie.swanson, want me to take a look at this? This is code committed by Janna.

Generated at Thu Feb 08 04:29:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.