mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
This commit is contained in:
parent
c70f45ff44
commit
e5f09ea170
51 changed files with 282 additions and 261 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
auto* vic_details = VIC::find_details_by_vic_id(vic_id);
|
||||
if (!vic_details)
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid short video descriptor"sv);
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid short video descriptor");
|
||||
|
||||
IterationDecision decision = callback(is_native, *vic_details);
|
||||
if (decision != IterationDecision::Continue)
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
}
|
||||
|
||||
if (dtd_start > offsetof(Definitions::ExtensionBlock, checksum) - sizeof(Definitions::DetailedTiming))
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD list"sv);
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD list");
|
||||
|
||||
size_t dtd_index = 0;
|
||||
for (size_t offset = dtd_start; offset <= offsetof(Definitions::ExtensionBlock, checksum) - sizeof(Definitions::DetailedTiming); offset += sizeof(Definitions::DetailedTiming)) {
|
||||
|
@ -108,7 +108,7 @@ private:
|
|||
return IterationDecision::Continue;
|
||||
|
||||
if (dtd_start > offsetof(Definitions::ExtensionBlock, checksum))
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD start offset"sv);
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD start offset");
|
||||
|
||||
auto* data_block_header = &m_block->cea861extension.bytes[0];
|
||||
auto* data_block_end = (u8 const*)m_block + dtd_start;
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
size_t payload_size = header_byte & 0x1f;
|
||||
auto tag = (DataBlockTag)((header_byte >> 5) & 0x7);
|
||||
if (tag == DataBlockTag::Extended && payload_size == 0)
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid extended data block size"sv);
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid extended data block size");
|
||||
|
||||
auto decision = TRY(callback(tag, m_edid.m_bytes.slice(data_block_header - m_edid.m_bytes.data() + 1, payload_size)));
|
||||
if (decision != IterationDecision::Continue)
|
||||
|
@ -135,7 +135,7 @@ private:
|
|||
return IterationDecision::Continue;
|
||||
|
||||
if (dtd_start > offsetof(Definitions::ExtensionBlock, checksum) - sizeof(Definitions::DetailedTiming))
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD list"sv);
|
||||
return Error::from_string_literal("CEA 861 extension block has invalid DTD list");
|
||||
|
||||
for (size_t offset = dtd_start; offset <= offsetof(Definitions::ExtensionBlock, checksum) - sizeof(Definitions::DisplayDescriptor); offset += sizeof(Definitions::DisplayDescriptor)) {
|
||||
auto& dd = *(Definitions::DisplayDescriptor const*)((u8 const*)m_block + offset);
|
||||
|
@ -301,17 +301,17 @@ Definitions::EDID const& Parser::raw_edid() const
|
|||
ErrorOr<void> Parser::parse()
|
||||
{
|
||||
if (m_bytes.size() < sizeof(Definitions::EDID))
|
||||
return Error::from_string_literal("Incomplete Parser structure"sv);
|
||||
return Error::from_string_literal("Incomplete Parser structure");
|
||||
|
||||
auto const& edid = raw_edid();
|
||||
u64 header = read_le(&edid.header);
|
||||
if (header != 0x00ffffffffffff00ull)
|
||||
return Error::from_string_literal("No Parser header"sv);
|
||||
return Error::from_string_literal("No Parser header");
|
||||
|
||||
u8 major_version = read_host(&edid.version.version);
|
||||
m_revision = read_host(&edid.version.revision);
|
||||
if (major_version != 1 || m_revision > 4)
|
||||
return Error::from_string_literal("Unsupported Parser version"sv);
|
||||
return Error::from_string_literal("Unsupported Parser version");
|
||||
|
||||
#ifdef KERNEL
|
||||
m_version = TRY(Kernel::KString::formatted("1.{}", (int)m_revision));
|
||||
|
@ -325,7 +325,7 @@ ErrorOr<void> Parser::parse()
|
|||
|
||||
if (checksum != 0) {
|
||||
if (m_revision >= 4) {
|
||||
return Error::from_string_literal("Parser checksum mismatch"sv);
|
||||
return Error::from_string_literal("Parser checksum mismatch");
|
||||
} else {
|
||||
dbgln("EDID checksum mismatch, data may be corrupted!");
|
||||
}
|
||||
|
@ -370,9 +370,9 @@ ErrorOr<IterationDecision> Parser::for_each_extension_block(Function<IterationDe
|
|||
current_extension_map = &raw_extension_blocks[0];
|
||||
raw_index++;
|
||||
if (read_host(¤t_extension_map->tag) != (u8)Definitions::ExtensionBlockTag::ExtensionBlockMap)
|
||||
return Error::from_string_literal("Did not find extension map at block 1"sv);
|
||||
return Error::from_string_literal("Did not find extension map at block 1");
|
||||
if (!validate_block_checksum(*current_extension_map))
|
||||
return Error::from_string_literal("Extension block map checksum mismatch"sv);
|
||||
return Error::from_string_literal("Extension block map checksum mismatch");
|
||||
}
|
||||
} else if (read_host(&raw_extension_blocks[0].tag) == (u8)Definitions::ExtensionBlockTag::ExtensionBlockMap) {
|
||||
current_extension_map = &raw_extension_blocks[0];
|
||||
|
@ -385,18 +385,18 @@ ErrorOr<IterationDecision> Parser::for_each_extension_block(Function<IterationDe
|
|||
|
||||
if (current_extension_map && raw_index == 127) {
|
||||
if (tag != (u8)Definitions::ExtensionBlockTag::ExtensionBlockMap)
|
||||
return Error::from_string_literal("Did not find extension map at block 128"sv);
|
||||
return Error::from_string_literal("Did not find extension map at block 128");
|
||||
current_extension_map = &raw_extension_blocks[127];
|
||||
if (!validate_block_checksum(*current_extension_map))
|
||||
return Error::from_string_literal("Extension block map checksum mismatch"sv);
|
||||
return Error::from_string_literal("Extension block map checksum mismatch");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tag == (u8)Definitions::ExtensionBlockTag::ExtensionBlockMap)
|
||||
return Error::from_string_literal("Unexpected extension map encountered"sv);
|
||||
return Error::from_string_literal("Unexpected extension map encountered");
|
||||
|
||||
if (!validate_block_checksum(raw_block))
|
||||
return Error::from_string_literal("Extension block checksum mismatch"sv);
|
||||
return Error::from_string_literal("Extension block checksum mismatch");
|
||||
|
||||
size_t offset = (u8 const*)&raw_block - m_bytes.data();
|
||||
IterationDecision decision = callback(raw_index + 1, tag, raw_block.block.revision, m_bytes.slice(offset, sizeof(Definitions::ExtensionBlock)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue