[SERVER-27244] Status class should have gnu::warn_unused_result attribute Created: 01/Dec/16  Updated: 06/Dec/17  Resolved: 19/Jun/17

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

Type: New Feature Priority: Major - P3
Reporter: Mathias Stearn Assignee: ADAM Martin (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-06-19
Participants:

 Description   

Far too many places are silently not checking the Statuses returned by functions. We should add this attribute and make all existing silent ignores either check the Status or use a void cast to explicitly ignore it.



 Comments   
Comment by Githook User [ 19/Jun/17 ]

Author:

{u'username': u'adamlsd', u'name': u'ADAM David Alan Martin', u'email': u'adam.martin@10gen.com'}

Message: SERVER-27244 Status usage compile-time error.

This change activates the compile-time checking for unused
`mongo::Status` results. A few more `transitional_ignore`
calls were needed for a few more tests which appeared.
Branch: master
https://github.com/mongodb/mongo/commit/3542249772f1a9b836d1f9e97f631dc922877c72

Comment by Githook User [ 19/Jun/17 ]

Author:

{u'username': u'adamlsd', u'name': u'ADAM David Alan Martin', u'email': u'adam.martin@10gen.com'}

Message: SERVER-27244 Turn on `Status::transitional_ignore`.

The enterprise module has a few ignored `Status` and
`StatusWith` cases. These cases have been marked
`transitional_ignore` to permit enabling the compile
time enforcement of status checking on Clang based
builds.
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/53c5f4005ce7da304ee8840ac062278a25ffbf29

Comment by Githook User [ 19/Jun/17 ]

Author:

{u'username': u'adamlsd', u'name': u'ADAM David Alan Martin', u'email': u'adam.martin@10gen.com'}

Message: SERVER-27244 Fix Lint in compiler_gcc.h

A comment describing the new `MONGO_WARN_UNUSED_RESULT` flag went
a few characters over the 100 character limit. Re-ran clang
format.
Branch: master
https://github.com/mongodb/mongo/commit/ead729bb5a801ab925c6b06de940e7ba9a738261

Comment by Githook User [ 19/Jun/17 ]

Author:

{u'username': u'adamlsd', u'name': u'ADAM David Alan Martin', u'email': u'adam.martin@10gen.com'}

Message: SERVER-27244 Status usage compile-time facilities.

There are numerous places in the codebase where `mongo::Status` or
`mongo::StatusWith< T >` objects are returned and never checked.
Many of these are innocuous, but many of them are potentially
severe bugs. This change introduces facilities to permit
compile-time warning of unchecked `Status` and `StatusWith` usage
on clang compilers. It introduces an `ignore` function which is
useful to state that a specific "ignored status" case was
intentional. It not presently an error, in clang builds, to
forget to check a `Status` – this will come in a later commit.

This also introduces a `transitional_ignore` function, which allows
for easy continual auditing of the codebase for current "whitelisted"
unchecked-status instances. All present "ignored status" cases
have been marked `transitional_ignore`.
Branch: master
https://github.com/mongodb/mongo/commit/9abef6f25aadfd04309cb2219068097f93dc961d

Comment by ADAM Martin (Inactive) [ 02/Jun/17 ]

C+17 introduced `[[nodiscard]]` as a new attribute to provide this kind of functionality as well. We may wish to have some kind of `MONGO_NODISCARD` macro to allow us to use the more portable C+17 attribute when the time comes, and such a macro lets us use `gnu::warn_unused_result` where supported, in the meantime.

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