Use byte conversions over NetToHost and HostToNet byte swaps (3/x)
This CL is one of many, and modifies chrome/browser, ash, gcm_driver, sync, speech, remoting, and p2p. Outside of data structures provided by the kernel in network byte order (such as seen in //net code), big endian data comes and goes as a byte array, and should be converted to and from integer values with the functions in base::numerics that convert between integers and byte spans/arrays. This effort: * replaces unchecked pointers with spans, * removes UB casts from byte arrays to larger integer types, and * eliminates integers holding both little and big endian values (and the in-place swaps). We use base::SpanReader/SpanWriter when performing a series of structured reads from, or writes to, a span. Or base::BigEndianReader for multiple endian conversions. And we remove adhoc implementations that do the same to consolidate on the base implementations. When appending a byte array to a string or a stream, we use base::as_string_view() to make a string_view, and append that. Bug: 40284755 Change-Id: I962106638ddf2985104d194c4de4e0bc763b50e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5402335 Reviewed-by:Maksim Moskvitin <mmoskvitin@google.com> Reviewed-by:
Peter Beverloo <peter@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Reviewed-by:
Alberto Juarez <albertojuarez@google.com> Reviewed-by:
Ryan Hansberry <hansberry@chromium.org> Reviewed-by:
Evan Liu <evliu@google.com> Cr-Commit-Position: refs/heads/main@{#1281916}
Loading
Please register or sign in to comment