mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
AK: Make ByteBuffer::try_* functions return ErrorOr<void>
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
This commit is contained in:
parent
88b6428c25
commit
a15ed8743d
20 changed files with 59 additions and 70 deletions
|
@ -122,7 +122,8 @@ private:
|
|||
{
|
||||
if (!m_condition()) {
|
||||
write_to_buffer:;
|
||||
if (!m_buffer.try_append(bytes.data(), bytes.size()))
|
||||
// FIXME: Propagate errors.
|
||||
if (m_buffer.try_append(bytes.data(), bytes.size()).is_error())
|
||||
return 0;
|
||||
return bytes.size();
|
||||
}
|
||||
|
|
|
@ -165,9 +165,8 @@ static void tls(const char* message, size_t len)
|
|||
g_loop.quit(0);
|
||||
};
|
||||
}
|
||||
auto ok = write.try_append(message, len);
|
||||
ok = ok && write.try_append("\r\n", 2);
|
||||
VERIFY(ok);
|
||||
MUST(write.try_append(message, len));
|
||||
MUST(write.try_append("\r\n", 2));
|
||||
}
|
||||
|
||||
static void aes_cbc(const char* message, size_t len)
|
||||
|
@ -2039,7 +2038,7 @@ static void tls_test_client_hello()
|
|||
loop.quit(1);
|
||||
} else {
|
||||
// print_buffer(data.value(), 16);
|
||||
if (!contents.try_append(data.value().data(), data.value().size())) {
|
||||
if (contents.try_append(data.value().data(), data.value().size()).is_error()) {
|
||||
FAIL(Allocation failed);
|
||||
loop.quit(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue