Bug 307347

Summary: [check-webkit-style] Fix false positive in safercpp/protected_getter_for_init checker
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Tools / TestsAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 306787    
Bug Blocks:    

David Kilzer (:ddkilzer)
Reported 2026-02-09 09:43:09 PST
The `check-webkit-style` script produces false positives for code like: ```cpp if (RefPtr document = viewportDocumentForFrame(protect(mainFrame()))) ``` Error message: ``` error: [safercpp/protected_getter_for_init] Do not use protect() for variable initialization. ``` This is a false positive because `protect(mainFrame())` is an argument to `viewportDocumentForFrame()`, not the direct initializer for `document`. The checker should only warn when `protect()`, `protectedFoo()`, or `checkedFoo()` functions are used as the direct initializer, not when they are nested inside other function calls.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-02-09 09:43:16 PST
David Kilzer (:ddkilzer)
Comment 2 2026-02-09 11:15:53 PST
EWS
Comment 3 2026-02-09 16:42:43 PST
Committed 307125@main (d93063803637): <https://commits.webkit.org/307125@main> Reviewed commits have been landed. Closing PR #58222 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.