forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate SharedMemoryRegion memory(), replace it with data() and spans
The accessor returns an unbounded void* which is dangerous to use. Callers should instead use GetMemoryAsSpan() or GetMemoryAs(). To ease this we introduce `uint8_t* data()` which allows SharedMemoryMappings to convert implicitly or explicitly to base::span<uint8_t>. We enable unsafe-buffer-usage warning in the shared memory unit tests, which mostly required changing tests to use span apis instead of working with the unbounded pointer accessor. The span apis return the same pointer but with a length attached. Other code is changed to span(mapping), GetMemoryAsSpan() or GetMemoryAs(). These require the types being pulled out of shared memory are trivially copyable. However a couple classes used in this way in devices were _not_ trivially copyable. This can cause UB. These classes wanted to be trivially copyable but could not be because of the out-of-line ctor requirements of the chromium clang plugin. So we template these and use a type alias to avoid rewriting 1000 LOC with useless template arguments. This works around the clang plugin for now. [email protected] Bug: 40284755, 355003174 Change-Id: Id7fd4c9bcf0b86b8109134c18740453bb24aa5de Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5734584 Reviewed-by: James Cook <[email protected]> Reviewed-by: Łukasz Anforowicz <[email protected]> Reviewed-by: Khushal Sagar <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Alex Moshchuk <[email protected]> Reviewed-by: Avi Drissman <[email protected]> Owners-Override: Daniel Cheng <[email protected]> Commit-Queue: danakj <[email protected]> Reviewed-by: Reilly Grant <[email protected]> Code-Coverage: [email protected] <[email protected]> Reviewed-by: Jonathan Ross <[email protected]> Cr-Commit-Position: refs/heads/main@{#1333755}
- Loading branch information
Showing
64 changed files
with
423 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.