Skip to content
Commit 569d4de8 authored by danakj's avatar danakj Committed by Chromium LUCI CQ
Browse files

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: default avatarMaksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarAlberto Juarez <albertojuarez@google.com>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarEvan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/main@{#1281916}
parent b0f9bd2f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment