Use byte conversions over NetToHost and HostToNet byte swaps (4/x)
This CL is one of many, and modifies media. 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: I4680bfc3aedec0a05ab71b64ee5f377e677a68bf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5403093 Reviewed-by:Frank Liberato <liberato@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/main@{#1282131}
Loading
Please register or sign in to comment