1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

Everywhere: Remove unintentional partial stream reads and writes

This commit is contained in:
Tim Schumacher 2023-03-01 17:24:50 +01:00 committed by Linus Groh
parent 26516ee160
commit ae51c1821c
44 changed files with 109 additions and 192 deletions

View file

@ -179,11 +179,10 @@ ErrorOr<void> ConfigFile::sync()
TRY(m_file->seek(0, SeekMode::SetPosition));
for (auto& it : m_groups) {
// FIXME: This should write the entire span.
TRY(m_file->write_some(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
TRY(m_file->write_until_depleted(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
for (auto& jt : it.value)
TRY(m_file->write_some(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes()));
TRY(m_file->write_some("\n"sv.bytes()));
TRY(m_file->write_until_depleted(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes()));
TRY(m_file->write_until_depleted("\n"sv.bytes()));
}
m_dirty = false;

View file

@ -221,9 +221,7 @@ public:
auto bytes_to_send = serialized.bytes();
u32 length = bytes_to_send.size();
// FIXME: Propagate errors
// FIXME: This should write the entire span.
auto sent = MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) }));
VERIFY(sent == sizeof(length));
MUST(m_socket->write_value(length));
while (!bytes_to_send.is_empty()) {
size_t bytes_sent = MUST(m_socket->write_some(bytes_to_send));
bytes_to_send = bytes_to_send.slice(bytes_sent);