diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-20 12:54:15 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-20 13:20:34 +0100 |
commit | 88b9fcb9764bba777fe18bb28114a3743bb971a4 (patch) | |
tree | d3eb3caba906f2ec0beab721d4b69626a0b249ab /Kernel/FileSystem | |
parent | 1dfc66c7cc055d03a87f5851334c5ae2f65d1e2d (diff) | |
download | serenity-88b9fcb9764bba777fe18bb28114a3743bb971a4.zip |
AK: Use size_t for ByteBuffer sizes
This matches what we already do for string types.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 4 | ||||
-rw-r--r-- | Kernel/FileSystem/FileDescription.cpp | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 8778c2ca05..5bfb9cd4aa 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -923,8 +923,10 @@ bool Ext2FSInode::write_directory(const Vector<FS::DirectoryEntry>& entries) stream.fill_to_end(0); ssize_t nwritten = write_bytes(0, directory_data.size(), directory_data.data(), nullptr); + if (nwritten < 0) + return false; set_metadata_dirty(true); - return nwritten == directory_data.size(); + return static_cast<size_t>(nwritten) == directory_data.size(); } KResult Ext2FSInode::add_child(InodeIdentifier child_id, const StringView& name, mode_t mode) diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 30cba4dd13..1bd1659563 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -182,7 +182,10 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size) if (!metadata.is_valid()) return -EIO; - int size_to_allocate = max(PAGE_SIZE, metadata.size); + if (size < 0) + return -EINVAL; + + size_t size_to_allocate = max(PAGE_SIZE, metadata.size); auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate); BufferStream stream(temp_buffer); @@ -195,8 +198,8 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size) }); stream.snip(); - if (size < temp_buffer.size()) - return -1; + if (static_cast<size_t>(size) < temp_buffer.size()) + return -EINVAL; copy_to_user(buffer, temp_buffer.data(), temp_buffer.size()); return stream.offset(); |