[SERVER-57428] Coverity analysis defect 120147: Parse warning Created: 03/Jun/21  Updated: 08/Jun/21  Resolved: 08/Jun/21

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

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

Issue Links:
Related
is related to SERVER-56861 Update semantics for server status's ... Closed
is related to SERVER-51240 Add clang tidy rules to prevent const... Closed
Operating System: ALL
Sprint: Repl 2021-06-14
Participants:

 Description   

Parse warning

A parse warning may reduce maintainability of the code, or it may indicate a serious error. A parse warning from the Coverity parser may indicate a bug, or poor coding practice
/src/mongo/db/read_write_concern_provenance.h:128: PW.USELESS_TYPE_QUALIFIER_ON_RETURN_TYPE 120147 type qualifier on return type is meaningless



 Comments   
Comment by Samyukta Lanka [ 08/Jun/21 ]

This was fixed as a part of SERVER-57142, so closing this ticket as a duplicate.

Comment by Andrew Morrow (Inactive) [ 04/Jun/21 ]

I've filed SERVER-57446 in response.

Comment by Andrew Morrow (Inactive) [ 04/Jun/21 ]

Actually, the issue is right there in front of us. From that log you linked:

Use -header-filter=.* to display errors from all non-system headers

We need to be running with something like --header-filter=mongo/.* in order to get clang-tidy reports for code in headers.

Comment by Benety Goh [ 04/Jun/21 ]

The most recent clang-tidy run mentioned the .cpp file but not the header. Maybe this is the issue?

We extract the source files for clang-tidy to process from the scons-generated compile_commands.json build artifact.

[2021/06/04 12:49:45.955] /opt/mongodbtoolchain/v3/bin/clang-tidy -p ./compile_commands.json --checks=-*,bugprone-unused-raii,bugprone-use-after-move,readability-const-return-type,readability-avoid-const-params-in-decls -warnings-as-errors=* src/mongo/db/namespace_string.cpp src/mongo/db/update_index_data.cpp src/mongo/db/collection_index_usage_tracker.cpp src/mongo/db/server_options.cpp src/mongo/db/server_options_helpers.cpp src/mongo/db/server_options_base.cpp src/mongo/db/server_options_server_helpers.cpp src/mongo/db/initialize_server_security_state.cpp src/mongo/db/initialize_server_global_state.cpp src/mongo/db/server_options_init.cpp src/mongo/db/global_settings.cpp src/mongo/db/mongod_options.cpp src/mongo/db/read_write_concern_provenance.cpp src/mongo/db/write_concern_options.cpp src/mongo/db/read_write_concern_defaults.cpp src/mongo/db/read_write_concern_defaults_cache_lookup_mock.cpp src/mongo/db/baton.cpp src/mongo/db/cancelable_operation_context.cpp src/mongo/db/client.cpp src/mongo/db/client_strand.cpp src/mongo/db/default_baton.cpp src/mongo/db/operation_context.cpp src/mongo/db/operation_context_group.cpp src/mongo/db/operation_cpu_timer.cpp src/mongo/db/operation_id.cpp src/mongo/db/operation_key_manager.cpp src/mongo/db/service_context.cpp src/mongo/db/server_recovery.cpp src/mongo/db/repl_set_member_in_standalone_mode.cpp src/mongo/db/prepare_conflict_tracker.cpp src/mongo/db/multi_key_path_tracker.cpp src/mongo/db/lasterror.cpp

Comment by Benety Goh [ 04/Jun/21 ]

The function that Coverity flagged was added in SERVER-56861 but this pattern was already in place for this class.

Comment by Andrew Morrow (Inactive) [ 04/Jun/21 ]

benety.goh - I thought we had enabled the clang-tidy check for this with readability-const-return-type. Any idea why it didn't catch this instance?

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