[SERVER-50457] Coverity analysis defect 114610: Useless call Created: 21/Aug/20  Updated: 29/Oct/23  Resolved: 28/Aug/20

Status: Closed
Project: Core Server
Component/s: Querying, Sharding, Testing Infrastructure
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: James Wahlin
Resolution: Fixed Votes: 0
Labels: coverity, qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2020-09-07
Participants:

 Description   

Useless call

A function call that seems to have an intended effect has no actual effect on the logic of the program. A function is called that is only useful for its return value, and this value is ignored.



 Comments   
Comment by Githook User [ 28/Aug/20 ]

Author:

{'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}

Message: SERVER-50457 Handle default_timed_get() return val in ShardingAggTestFixture
Branch: master
https://github.com/mongodb/mongo/commit/acb766a1b74c200af2b675efa850281592d4188a

Comment by James Wahlin [ 26/Aug/20 ]

While the defect report isn't quite right (the call to future.default_timed_get() will wait for the future or time out), we could improve on the current code by capturing the return and confirming that the chunk manager is available. We will use this ticket to do so. Here is a proposed diff:

diff --git a/src/mongo/s/query/sharded_agg_test_fixture.h b/src/mongo/s/query/sharded_agg_test_fixture.h
index 48f1f71f99..f72d6c2f6e 100644
--- a/src/mongo/s/query/sharded_agg_test_fixture.h
+++ b/src/mongo/s/query/sharded_agg_test_fixture.h
@@ -109,7 +109,8 @@ public:
             return response;
         }());
 
-        future.default_timed_get().get();
+        auto routingInfo = future.default_timed_get();
+        ASSERT(routingInfo->cm());
     }
 
 protected:

Generated at Thu Feb 08 05:22:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.