Bug 298037
| Summary: | Safer CPP static analyzer erroneously claims the use of `dispatch_get_main_queue()` | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jean-Yves Avenard [:jya] <jean-yves.avenard> |
| Component: | Tools / Tests | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | cdumez, rniwa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Jean-Yves Avenard [:jya]
doing something like this
```
[m_synchronizer addPeriodicTimeObserverForInterval:PAL::toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) { }];
```
will give "Call argument for parameter 'queue' is unretained and unsafe"
the documentation states:
```
* The main queue is a well known global object that is made automatically on
* behalf of the main thread during process initialization and is returned by
* dispatch_get_main_queue(). This object cannot be modified. Calls to
* dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will
* have no effect when used on the main queue.
*/
```
the object returned will never be deleted during a call as shown above, its use can't possibly be unsafe.
An exception should be added. There's currently 377 calls to that method, none wrapping it around a RetainPtr
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/159361681>
Ryosuke Niwa
We added a wrapping function in the bug 298840.
*** This bug has been marked as a duplicate of bug 298840 ***
Chris Dumez
Bug 298840 introduced `mainDispatchQueueSingleton()` in wtf/darwin/DispatchExtras.h, which should now be used instead.