[SERVER-17873] Coverity analysis defect 41876: Copy-paste error Created: 02/Apr/15  Updated: 02/Aug/18  Resolved: 06/Apr/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Coverity Collector User Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

A new defect has been detected and assigned to renctan in Coverity Connect.
http://coverity.mongodb.com//sourcebrowser.htm?projectId=10001#mergedDefectId=41876
The defect was flagged by checker COPY_PASTE_ERROR in
file /src/mongo/s/shard_key_pattern.cpp
function mongo::ShardKeyPattern::flattenBounds(const mongo::IndexBounds &) const
and this ticket was created by renctan



 Comments   
Comment by Daniel Alabi [ 06/Apr/15 ]

The block of code that coverity is having problems with is in fact not a consequence of a copy-paste error.

if (intervals.size() == 1 && intervals.front().isPoint()) {
                    // this field is only a single point-interval
                    BoundBuilders::const_iterator j;
                    for (j = builders.begin(); j != builders.end(); ++j) {
                        j->first->appendAs(intervals.front().start, fieldName);
                        j->second->appendAs(intervals.front().end, fieldName);
                    }
                }
.....

intervals.size() == 1 <==> intervals.front() == intervals.back()

and so lines 391-394 is functionally identical to lines 430-433.

Generated at Thu Feb 08 03:45:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.