1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

Kernel: Make syscalls that take a buffer size use ssize_t instead of size_t.

Dealing with the unsigned overflow propagation here just seems unreasonably
error prone. Let's limit ourselves to 2GB buffer sizes instead.
This commit is contained in:
Andreas Kling 2019-02-25 21:19:57 +01:00
parent 5af4e622b9
commit beda478821
40 changed files with 144 additions and 136 deletions

View file

@ -13,13 +13,13 @@ public:
{
}
ssize_t write(const byte*, size_t);
ssize_t read(byte*, size_t);
ssize_t write(const byte*, ssize_t);
ssize_t read(byte*, ssize_t);
bool is_empty() const { return m_empty; }
// FIXME: Isn't this racy? What if we get interrupted between getting the buffer pointer and dereferencing it?
size_t bytes_in_write_buffer() const { return m_write_buffer->size(); }
ssize_t bytes_in_write_buffer() const { return (ssize_t)m_write_buffer->size(); }
private:
void flip();
@ -29,7 +29,7 @@ private:
Vector<byte>* m_read_buffer { nullptr };
Vector<byte> m_buffer1;
Vector<byte> m_buffer2;
size_t m_read_buffer_index { 0 };
ssize_t m_read_buffer_index { 0 };
bool m_empty { true };
Lock m_lock;
};