Skip to content

Commit 3fe6141

Browse files
rprichardGerrit Code Review
authored andcommitted
Merge changes I2bfa04cc,I156f1032 into main
* changes: vr: avoid missing std::char_traits<const T> ui: use std::span instead of std::basic_string_view<uint8_t>
2 parents f86d02b + 20ff570 commit 3fe6141

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

libs/ui/DisplayIdentification.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cctype>
2222
#include <numeric>
2323
#include <optional>
24+
#include <span>
2425

2526
#include <log/log.h>
2627

@@ -81,15 +82,16 @@ uint64_t hash64Len0To16(const char* s, uint64_t len) {
8182
return k2;
8283
}
8384

84-
using byte_view = std::basic_string_view<uint8_t>;
85+
using byte_view = std::span<const uint8_t>;
8586

8687
constexpr size_t kEdidBlockSize = 128;
8788
constexpr size_t kEdidHeaderLength = 5;
8889

8990
constexpr uint16_t kVirtualEdidManufacturerId = 0xffffu;
9091

9192
std::optional<uint8_t> getEdidDescriptorType(const byte_view& view) {
92-
if (view.size() < kEdidHeaderLength || view[0] || view[1] || view[2] || view[4]) {
93+
if (static_cast<size_t>(view.size()) < kEdidHeaderLength || view[0] || view[1] || view[2] ||
94+
view[4]) {
9395
return {};
9496
}
9597

@@ -164,7 +166,7 @@ Cea861ExtensionBlock parseCea861Block(const byte_view& block) {
164166
constexpr size_t kDataBlockHeaderSize = 1;
165167
const size_t dataBlockSize = bodyLength + kDataBlockHeaderSize;
166168

167-
if (block.size() < dataBlockOffset + dataBlockSize) {
169+
if (static_cast<size_t>(block.size()) < dataBlockOffset + dataBlockSize) {
168170
ALOGW("Invalid EDID: CEA 861 data block is truncated.");
169171
break;
170172
}
@@ -264,7 +266,7 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
264266
}
265267

266268
byte_view view(edid.data(), edid.size());
267-
view.remove_prefix(kDescriptorOffset);
269+
view = view.subspan(kDescriptorOffset);
268270

269271
std::string_view displayName;
270272
std::string_view serialNumber;
@@ -274,13 +276,13 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
274276
constexpr size_t kDescriptorLength = 18;
275277

276278
for (size_t i = 0; i < kDescriptorCount; i++) {
277-
if (view.size() < kDescriptorLength) {
279+
if (static_cast<size_t>(view.size()) < kDescriptorLength) {
278280
break;
279281
}
280282

281283
if (const auto type = getEdidDescriptorType(view)) {
282284
byte_view descriptor(view.data(), kDescriptorLength);
283-
descriptor.remove_prefix(kEdidHeaderLength);
285+
descriptor = descriptor.subspan(kEdidHeaderLength);
284286

285287
switch (*type) {
286288
case 0xfc:
@@ -295,7 +297,7 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
295297
}
296298
}
297299

298-
view.remove_prefix(kDescriptorLength);
300+
view = view.subspan(kDescriptorLength);
299301
}
300302

301303
std::string_view modelString = displayName;
@@ -327,8 +329,8 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
327329
const size_t numExtensions = edid[kNumExtensionsOffset];
328330
view = byte_view(edid.data(), edid.size());
329331
for (size_t blockNumber = 1; blockNumber <= numExtensions; blockNumber++) {
330-
view.remove_prefix(kEdidBlockSize);
331-
if (view.size() < kEdidBlockSize) {
332+
view = view.subspan(kEdidBlockSize);
333+
if (static_cast<size_t>(view.size()) < kEdidBlockSize) {
332334
ALOGW("Invalid EDID: block %zu is truncated.", blockNumber);
333335
break;
334336
}

libs/vr/libpdx/private/pdx/rpc/string_wrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ namespace rpc {
1717
// C strings more efficient by avoiding unnecessary copies when remote method
1818
// signatures specify std::basic_string arguments or return values.
1919
template <typename CharT = std::string::value_type,
20-
typename Traits = std::char_traits<CharT>>
20+
typename Traits = std::char_traits<std::remove_cv_t<CharT>>>
2121
class StringWrapper {
2222
public:
2323
// Define types in the style of STL strings to support STL operators.
2424
typedef Traits traits_type;
25-
typedef typename Traits::char_type value_type;
25+
typedef CharT value_type;
2626
typedef std::size_t size_type;
2727
typedef value_type& reference;
2828
typedef const value_type& const_reference;

0 commit comments

Comments
 (0)