Bug 210336 - check-webkit-style should warn about 'decode' functions with missing WARN_UNUSED_RETURN attribute
Summary: check-webkit-style should warn about 'decode' functions with missing WARN_UNU...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-10 08:45 PDT by David Kilzer (:ddkilzer)
Modified: 2020-04-13 15:06 PDT (History)
6 users (show)

See Also:


Attachments
Patch v1 (9.73 KB, patch)
2020-04-10 08:54 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch for landing (9.51 KB, patch)
2020-04-11 03:51 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2020-04-10 08:45:54 PDT
check-webkit-style should warn about 'decode' functions that are missing the WARN_UNUSED_RETURN attribute.

This will help to find bugs when using CoreIPC decode() methods.
Comment 1 Radar WebKit Bug Importer 2020-04-10 08:52:38 PDT
<rdar://problem/61585835>
Comment 2 David Kilzer (:ddkilzer) 2020-04-10 08:54:52 PDT
Created attachment 396088 [details]
Patch v1
Comment 3 Darin Adler 2020-04-10 09:00:47 PDT
Comment on attachment 396088 [details]
Patch v1

For functions returning bool I think this is a good rule. For ones returning Optional I think this is not helpful, but I suppose no big deal to comply anyway.
Comment 4 Jonathan Bedard 2020-04-10 09:07:21 PDT
Comment on attachment 396088 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=396088&action=review

> Tools/Scripts/webkitpy/style/checkers/cpp.py:1818
> +            if function_state.has_return_type('(auto|bool|Optional<.+>)'):

I would actually expect this to be an inverse check. If a function does not have a void return type, then we should trigger this logic. Any reason we picked this set of types?
Comment 5 Jonathan Bedard 2020-04-10 09:08:03 PDT
Comment on attachment 396088 [details]
Patch v1

Darin r+ed it, I accidentally removed the r+ when adding a comment
Comment 6 Darin Adler 2020-04-10 09:18:36 PDT
If we are going to consider return types, the real issue is about bool return types. I don’t see a real unused return value issue outside of the bool return type case.
Comment 7 Alex Christensen 2020-04-10 11:44:41 PDT
Comment on attachment 396088 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=396088&action=review

> Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:3039
> +            '    static WARN_UNUSED_RETURN Optional<std::tuple<>> decode(Decoder&)\n'

This shouldn't be added.
Comment 8 David Kilzer (:ddkilzer) 2020-04-10 17:42:30 PDT
Comment on attachment 396088 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=396088&action=review

>> Tools/Scripts/webkitpy/style/checkers/cpp.py:1818
>> +            if function_state.has_return_type('(auto|bool|Optional<.+>)'):
> 
> I would actually expect this to be an inverse check. If a function does not have a void return type, then we should trigger this logic. Any reason we picked this set of types?

This set of types are specific to the decode() methods we care about.

I'm going to remove Optional<.+> from the list per feedback from Alex and Darin.

>> Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:3039
>> +            '    static WARN_UNUSED_RETURN Optional<std::tuple<>> decode(Decoder&)\n'
> 
> This shouldn't be added.

I will remove "Optional<.+>" from the list of types based on feedback from you and Darin, and remove this test (since it's a dupe of the one above) before landing.
Comment 9 David Kilzer (:ddkilzer) 2020-04-11 03:51:28 PDT
Created attachment 396158 [details]
Patch for landing
Comment 10 EWS 2020-04-11 04:28:44 PDT
Committed r259925: <https://trac.webkit.org/changeset/259925>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396158 [details].