diff options
-rw-r--r-- | AK/ByteBuffer.h | 7 | ||||
-rw-r--r-- | Applications/IRCClient/IRCClient.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 62 | ||||
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.h | 28 | ||||
-rw-r--r-- | Kernel/FileSystem/FileSystem.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/FileSystem.h | 6 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 29 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/SyntheticFileSystem.cpp | 4 | ||||
-rw-r--r-- | Kernel/FileSystem/SyntheticFileSystem.h | 2 | ||||
-rw-r--r-- | Kernel/SharedMemory.cpp | 1 | ||||
-rw-r--r-- | Kernel/SharedMemory.h | 2 | ||||
-rw-r--r-- | Kernel/TTY/VirtualConsole.cpp | 2 | ||||
-rwxr-xr-x | Kernel/sync.sh | 2 | ||||
-rw-r--r-- | LibC/stdio.cpp | 2 | ||||
-rw-r--r-- | LibC/stdlib.cpp | 4 | ||||
-rw-r--r-- | LibC/string.cpp | 6 | ||||
-rw-r--r-- | LibC/unistd.cpp | 2 | ||||
-rw-r--r-- | LibGUI/GWindow.cpp | 4 | ||||
-rw-r--r-- | Servers/WindowServer/WSClientConnection.cpp | 2 | ||||
-rw-r--r-- | SharedGraphics/PNGLoader.cpp | 2 |
21 files changed, 89 insertions, 84 deletions
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index bea90cb450..f263c1c13b 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -14,6 +14,7 @@ public: static Retained<ByteBufferImpl> create_zeroed(int); static Retained<ByteBufferImpl> copy(const void*, int); static Retained<ByteBufferImpl> wrap(void*, int); + static Retained<ByteBufferImpl> wrap(const void*, int); static Retained<ByteBufferImpl> adopt(void*, int); ~ByteBufferImpl() { clear(); } @@ -89,6 +90,7 @@ public: static ByteBuffer create_uninitialized(ssize_t size) { return ByteBuffer(ByteBufferImpl::create_uninitialized(size)); } static ByteBuffer create_zeroed(ssize_t size) { return ByteBuffer(ByteBufferImpl::create_zeroed(size)); } static ByteBuffer copy(const void* data, ssize_t size) { return ByteBuffer(ByteBufferImpl::copy(data, size)); } + static ByteBuffer wrap(const void* data, ssize_t size) { return ByteBuffer(ByteBufferImpl::wrap(data, size)); } static ByteBuffer wrap(void* data, ssize_t size) { return ByteBuffer(ByteBufferImpl::wrap(data, size)); } static ByteBuffer adopt(void* data, ssize_t size) { return ByteBuffer(ByteBufferImpl::adopt(data, size)); } @@ -219,6 +221,11 @@ inline Retained<ByteBufferImpl> ByteBufferImpl::wrap(void* data, int size) return ::adopt(*new ByteBufferImpl(data, size, Wrap)); } +inline Retained<ByteBufferImpl> ByteBufferImpl::wrap(const void* data, int size) +{ + return ::adopt(*new ByteBufferImpl(const_cast<void*>(data), size, Wrap)); +} + inline Retained<ByteBufferImpl> ByteBufferImpl::adopt(void* data, int size) { return ::adopt(*new ByteBufferImpl(data, size, Adopt)); diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp index c83a5183c8..fe36914278 100644 --- a/Applications/IRCClient/IRCClient.cpp +++ b/Applications/IRCClient/IRCClient.cpp @@ -158,7 +158,7 @@ void IRCClient::process_line(ByteBuffer&& line) void IRCClient::send(const String& text) { - if (!m_socket->send(ByteBuffer::wrap((void*)text.characters(), text.length()))) { + if (!m_socket->send(ByteBuffer::wrap(text.characters(), text.length()))) { perror("send"); exit(1); } diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 8fb75f2ce9..eb1db44812 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -459,7 +459,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD // This avoids wasting an entire block on short links. (Most links are short.) if (is_symlink() && size() < max_inline_symlink_length) { ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count)); - memcpy(buffer, ((byte*)m_raw_inode.i_block) + offset, (size_t)nread); + memcpy(buffer, ((const byte*)m_raw_inode.i_block) + offset, (size_t)nread); return nread; } @@ -476,17 +476,17 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD return -EIO; } - const size_t block_size = fs().block_size(); + const int block_size = fs().block_size(); - dword first_block_logical_index = offset / block_size; - dword last_block_logical_index = (offset + count) / block_size; + int first_block_logical_index = offset / block_size; + int last_block_logical_index = (offset + count) / block_size; if (last_block_logical_index >= m_block_list.size()) last_block_logical_index = m_block_list.size() - 1; - dword offset_into_first_block = offset % block_size; + int offset_into_first_block = offset % block_size; ssize_t nread = 0; - size_t remaining_count = min((off_t)count, (off_t)size() - offset); + int remaining_count = min((off_t)count, (off_t)size() - offset); byte* out = buffer; #ifdef EXT2_DEBUG @@ -494,15 +494,15 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD //kprintf("ok let's do it, read(%u, %u) -> blocks %u thru %u, oifb: %u\n", offset, count, first_block_logical_index, last_block_logical_index, offset_into_first_block); #endif - for (dword bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) { + for (int bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) { auto block = fs().read_block(m_block_list[bi]); if (!block) { kprintf("ext2fs: read_bytes: read_block(%u) failed (lbi: %u)\n", m_block_list[bi], bi); return -EIO; } - dword offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0; - dword num_bytes_to_copy = min(block_size - offset_into_block, remaining_count); + int offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0; + int num_bytes_to_copy = min(block_size - offset_into_block, remaining_count); memcpy(out, block.pointer() + offset_into_block, num_bytes_to_copy); remaining_count -= num_bytes_to_copy; nread += num_bytes_to_copy; @@ -526,7 +526,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count); #endif memcpy(((byte*)m_raw_inode.i_block) + offset, data, (size_t)count); - if ((offset + count) > m_raw_inode.i_size) + if ((offset + count) > (off_t)m_raw_inode.i_size) m_raw_inode.i_size = offset + count; set_metadata_dirty(true); return count; @@ -551,17 +551,17 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, ASSERT_NOT_REACHED(); } - dword first_block_logical_index = offset / block_size; - dword last_block_logical_index = (offset + count) / block_size; + int first_block_logical_index = offset / block_size; + int last_block_logical_index = (offset + count) / block_size; if (last_block_logical_index >= block_list.size()) last_block_logical_index = block_list.size() - 1; - dword offset_into_first_block = offset % block_size; + int offset_into_first_block = offset % block_size; - dword last_logical_block_index_in_file = size() / block_size; + int last_logical_block_index_in_file = size() / block_size; ssize_t nwritten = 0; - size_t remaining_count = min((off_t)count, (off_t)new_size - offset); + int remaining_count = min((off_t)count, (off_t)new_size - offset); const byte* in = data; #ifdef EXT2_DEBUG @@ -569,9 +569,9 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, #endif auto buffer_block = ByteBuffer::create_uninitialized(block_size); - for (dword bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) { - size_t offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0; - size_t num_bytes_to_copy = min((size_t)block_size - offset_into_block, remaining_count); + for (int bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) { + int offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0; + int num_bytes_to_copy = min(block_size - offset_into_block, remaining_count); ByteBuffer block; if (offset_into_block != 0 || num_bytes_to_copy != block_size) { @@ -585,8 +585,8 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, memcpy(block.pointer() + offset_into_block, in, num_bytes_to_copy); if (bi == last_logical_block_index_in_file && num_bytes_to_copy < block_size) { - size_t padding_start = new_size % block_size; - size_t padding_bytes = block_size - padding_start; + int padding_start = new_size % block_size; + int padding_bytes = block_size - padding_start; #ifdef EXT2_DEBUG dbgprintf("Ext2FSInode::write_bytes padding last block of file with zero x %u (new_size=%u, offset_into_block=%u, num_bytes_to_copy=%u)\n", padding_bytes, new_size, offset_into_block, num_bytes_to_copy); #endif @@ -847,17 +847,17 @@ void Ext2FS::traverse_inode_bitmap(unsigned group_index, F callback) const } template<typename F> -void Ext2FS::traverse_block_bitmap(unsigned group_index, F callback) const +void Ext2FS::traverse_block_bitmap(GroupIndex group_index, F callback) const { ASSERT(group_index <= m_block_group_count); auto& bgd = group_descriptor(group_index); - unsigned blocks_in_group = min(blocks_per_group(), super_block().s_blocks_count); - unsigned block_count = ceil_div(blocks_in_group, 8u); - unsigned first_block_in_group = (group_index - 1) * blocks_per_group(); - unsigned bits_per_block = block_size() * 8; + int blocks_in_group = min(blocks_per_group(), super_block().s_blocks_count); + int block_count = ceil_div(blocks_in_group, 8u); + BlockIndex first_block_in_group = (group_index - 1) * blocks_per_group(); + int bits_per_block = block_size() * 8; - for (unsigned i = 0; i < block_count; ++i) { + for (int i = 0; i < block_count; ++i) { auto block = read_block(bgd.bg_block_bitmap + i); ASSERT(block); bool should_continue = callback(first_block_in_group + (i * bits_per_block) + 1, Bitmap::wrap(block.pointer(), blocks_in_group)); @@ -880,7 +880,7 @@ bool Ext2FS::write_ext2_inode(unsigned inode, const ext2_inode& e2inode) return success; } -Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(unsigned group, unsigned count) +Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(GroupIndex group, int count) { LOCKER(m_lock); dbgprintf("Ext2FS: allocate_blocks(group: %u, count: %u)\n", group, count); @@ -913,7 +913,7 @@ Vector<Ext2FS::BlockIndex> Ext2FS::allocate_blocks(unsigned group, unsigned coun return blocks; } -unsigned Ext2FS::allocate_inode(unsigned preferred_group, unsigned expected_size) +unsigned Ext2FS::allocate_inode(GroupIndex preferred_group, off_t expected_size) { LOCKER(m_lock); dbgprintf("Ext2FS: allocate_inode(preferredGroup: %u, expectedSize: %u)\n", preferred_group, expected_size); @@ -1134,7 +1134,7 @@ RetainPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const Strin return inode; } -RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, unsigned size, int& error) +RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, int& error) { LOCKER(m_lock); ASSERT(parent_id.fsid() == fsid()); @@ -1388,10 +1388,10 @@ KResult Ext2FSInode::chown(uid_t uid, gid_t gid) return KSuccess; } -KResult Ext2FSInode::truncate(int size) +KResult Ext2FSInode::truncate(off_t size) { LOCKER(m_lock); - if (m_raw_inode.i_size == size) + if ((off_t)m_raw_inode.i_size == size) return KSuccess; m_raw_inode.i_size = size; set_metadata_dirty(true); diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 80f779b278..966aab5db7 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -42,7 +42,7 @@ private: virtual size_t directory_entry_count() const override; virtual KResult chmod(mode_t) override; virtual KResult chown(uid_t, gid_t) override; - virtual KResult truncate(int) override; + virtual KResult truncate(off_t) override; void populate_lookup_cache() const; @@ -83,36 +83,36 @@ private: unsigned blocks_per_group() const; unsigned inode_size() const; - bool write_ext2_inode(unsigned, const ext2_inode&); - ByteBuffer read_block_containing_inode(unsigned inode, unsigned& block_index, unsigned& offset) const; + bool write_ext2_inode(InodeIndex, const ext2_inode&); + ByteBuffer read_block_containing_inode(InodeIndex inode, BlockIndex& block_index, unsigned& offset) const; ByteBuffer read_super_block() const; bool write_super_block(const ext2_super_block&); virtual const char* class_name() const override; virtual InodeIdentifier root_inode() const override; - virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) override; + virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, int& error) override; virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override; - unsigned allocate_inode(unsigned preferredGroup, unsigned expectedSize); - Vector<BlockIndex> allocate_blocks(unsigned group, unsigned count); - unsigned group_index_from_inode(unsigned) const; + InodeIndex allocate_inode(GroupIndex preferred_group, off_t expected_size); + Vector<BlockIndex> allocate_blocks(GroupIndex, int count); + GroupIndex group_index_from_inode(InodeIndex) const; GroupIndex group_index_from_block_index(BlockIndex) const; - Vector<unsigned> block_list_for_inode(const ext2_inode&, bool include_block_list_blocks = false) const; + Vector<BlockIndex> block_list_for_inode(const ext2_inode&, bool include_block_list_blocks = false) const; bool write_block_list_for_inode(InodeIndex, ext2_inode&, const Vector<BlockIndex>&); - void dump_block_bitmap(unsigned groupIndex) const; - void dump_inode_bitmap(unsigned groupIndex) const; + void dump_block_bitmap(GroupIndex) const; + void dump_inode_bitmap(GroupIndex) const; - template<typename F> void traverse_inode_bitmap(unsigned groupIndex, F) const; - template<typename F> void traverse_block_bitmap(unsigned groupIndex, F) const; + template<typename F> void traverse_inode_bitmap(GroupIndex, F) const; + template<typename F> void traverse_block_bitmap(GroupIndex, F) const; bool add_inode_to_directory(InodeIndex parent, InodeIndex child, const String& name, byte file_type, int& error); - bool write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&&); + bool write_directory_inode(InodeIndex, Vector<DirectoryEntry>&&); bool get_inode_allocation_state(InodeIndex) const; - bool set_inode_allocation_state(unsigned inode, bool); + bool set_inode_allocation_state(InodeIndex, bool); bool set_block_allocation_state(BlockIndex, bool); void uncache_inode(InodeIndex); diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp index 93d8d8d256..b3ec211785 100644 --- a/Kernel/FileSystem/FileSystem.cpp +++ b/Kernel/FileSystem/FileSystem.cpp @@ -77,7 +77,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft) name[name_length] = '\0'; } -FS::DirectoryEntry::DirectoryEntry(const char* n, size_t nl, InodeIdentifier i, byte ft) +FS::DirectoryEntry::DirectoryEntry(const char* n, int nl, InodeIdentifier i, byte ft) : name_length(nl) , inode(i) , file_type(ft) diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 833f09d440..847c2280c3 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -45,14 +45,14 @@ public: struct DirectoryEntry { DirectoryEntry(const char* name, InodeIdentifier, byte file_type); - DirectoryEntry(const char* name, size_t name_length, InodeIdentifier, byte file_type); + DirectoryEntry(const char* name, int name_length, InodeIdentifier, byte file_type); char name[256]; int name_length { 0 }; InodeIdentifier inode; byte file_type { 0 }; }; - virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) = 0; + virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, int& error) = 0; virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0; virtual RetainPtr<Inode> get_inode(InodeIdentifier) const = 0; @@ -102,7 +102,7 @@ public: virtual size_t directory_entry_count() const = 0; virtual KResult chmod(mode_t) = 0; virtual KResult chown(uid_t, gid_t) = 0; - virtual KResult truncate(int) { return KSuccess; } + virtual KResult truncate(off_t) { return KSuccess; } LocalSocket* socket() { return m_socket.ptr(); } const LocalSocket* socket() const { return m_socket.ptr(); } diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 4dd4810c21..f401fe2e7a 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -77,7 +77,7 @@ static inline int to_fd(const InodeIdentifier& identifier) return (identifier.index() & 0xff) - FI_MaxStaticFileIndex; } -static inline unsigned to_sys_index(const InodeIdentifier& identifier) +static inline int to_sys_index(const InodeIdentifier& identifier) { ASSERT(to_proc_parent_directory(identifier) == PDI_Root_sys); return identifier.index() & 0xff; @@ -186,7 +186,7 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier) if (process.number_of_open_file_descriptors() == 0) return { }; StringBuilder builder; - for (size_t i = 0; i < process.max_open_file_descriptors(); ++i) { + for (int i = 0; i < process.max_open_file_descriptors(); ++i) { auto* descriptor = process.file_descriptor(i); if (!descriptor) continue; @@ -714,28 +714,28 @@ void ProcFS::add_sys_bool(String&& name, Lockable<bool>& var, Function<void()>&& { InterruptDisabler disabler; - unsigned index = m_sys_entries.size(); + int index = m_sys_entries.size(); auto inode = adopt(*new ProcFSInode(*this, sys_var_to_identifier(fsid(), index).index())); auto data = make<SysVariableData>(); data->type = SysVariableData::Boolean; data->notify_callback = move(notify_callback); data->address = &var; inode->set_custom_data(move(data)); - m_sys_entries.append({ strdup(name.characters()), name.length(), read_sys_bool, write_sys_bool, move(inode) }); + m_sys_entries.append({ strdup(name.characters()), 0, read_sys_bool, write_sys_bool, move(inode) }); } void ProcFS::add_sys_string(String&& name, Lockable<String>& var, Function<void()>&& notify_callback) { InterruptDisabler disabler; - unsigned index = m_sys_entries.size(); + int index = m_sys_entries.size(); auto inode = adopt(*new ProcFSInode(*this, sys_var_to_identifier(fsid(), index).index())); auto data = make<SysVariableData>(); data->type = SysVariableData::String; data->notify_callback = move(notify_callback); data->address = &var; inode->set_custom_data(move(data)); - m_sys_entries.append({ strdup(name.characters()), name.length(), read_sys_string, write_sys_string, move(inode) }); + m_sys_entries.append({ strdup(name.characters()), 0, read_sys_string, write_sys_string, move(inode) }); } bool ProcFS::initialize() @@ -748,13 +748,8 @@ const char* ProcFS::class_name() const return "ProcFS"; } -RetainPtr<Inode> ProcFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, unsigned size, int& error) +RetainPtr<Inode> ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, int&) { - (void) parentInode; - (void) name; - (void) mode; - (void) size; - (void) error; kprintf("FIXME: Implement ProcFS::create_inode()?\n"); return { }; } @@ -934,7 +929,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&) if (!entry.name) continue; if (entry.proc_file_type > __FI_Root_Start && entry.proc_file_type < __FI_Root_End) - callback({ entry.name, strlen(entry.name), to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 }); + callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 }); } for (auto pid_child : Process::all_pids()) { char name[16]; @@ -946,7 +941,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&) case FI_Root_sys: for (int i = 0; i < fs().m_sys_entries.size(); ++i) { auto& entry = fs().m_sys_entries[i]; - callback({ entry.name, strlen(entry.name), sys_var_to_identifier(fsid(), i), 0 }); + callback({ entry.name, (int)strlen(entry.name), sys_var_to_identifier(fsid(), i), 0 }); } break; @@ -960,7 +955,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&) if (entry.proc_file_type == FI_PID_exe && !process.executable_inode()) continue; // FIXME: strlen() here is sad. - callback({ entry.name, strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 }); + callback({ entry.name, (int)strlen(entry.name), to_identifier(fsid(), PDI_PID, pid, (ProcFileType)entry.proc_file_type), 0 }); } } } @@ -976,7 +971,7 @@ bool ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&) if (!descriptor) continue; char name[16]; - size_t name_length = ksprintf(name, "%u", i); + int name_length = ksprintf(name, "%u", i); callback({ name, name_length, to_identifier_with_fd(fsid(), pid, i), 0 }); } } @@ -1100,7 +1095,7 @@ ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, ASSERT(is_persistent_inode(identifier())); // FIXME: Being able to write into ProcFS at a non-zero offset seems like something we should maybe support.. ASSERT(offset == 0); - bool success = directory_entry->write_callback(identifier(), ByteBuffer::wrap((byte*)buffer, size)); + bool success = directory_entry->write_callback(identifier(), ByteBuffer::wrap(buffer, size)); ASSERT(success); return 0; } diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index e86bf38e21..d08af28db7 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -22,7 +22,7 @@ public: virtual InodeIdentifier root_inode() const override; virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override; - virtual RetainPtr<Inode> create_inode(InodeIdentifier parent_id, const String& name, mode_t, unsigned size, int& error) override; + virtual RetainPtr<Inode> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, int& error) override; virtual RetainPtr<Inode> create_directory(InodeIdentifier parent_id, const String& name, mode_t, int& error) override; void add_sys_file(String&&, Function<ByteBuffer(ProcFSInode&)>&& read_callback, Function<ssize_t(ProcFSInode&, const ByteBuffer&)>&& write_callback); diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp index e55d31f061..222c66a03b 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.cpp +++ b/Kernel/FileSystem/SyntheticFileSystem.cpp @@ -138,7 +138,7 @@ InodeIdentifier SynthFS::root_inode() const return { fsid(), 1 }; } -RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, unsigned size, int& error) +RetainPtr<Inode> SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, int& error) { (void) parentInode; (void) name; @@ -274,7 +274,7 @@ ssize_t SynthFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer return -EPERM; // FIXME: Being able to write into SynthFS at a non-zero offset seems like something we should support.. ASSERT(offset == 0); - bool success = m_write_callback(*this, ByteBuffer::wrap((byte*)buffer, size)); + bool success = m_write_callback(*this, ByteBuffer::wrap(buffer, size)); ASSERT(success); return 0; } diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h index c1b95e5fe6..f3619a1b1e 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.h +++ b/Kernel/FileSystem/SyntheticFileSystem.h @@ -14,7 +14,7 @@ public: virtual bool initialize() override; virtual const char* class_name() const override; virtual InodeIdentifier root_inode() const override; - virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, unsigned size, int& error) override; + virtual RetainPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, int& error) override; virtual RetainPtr<Inode> create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; virtual RetainPtr<Inode> get_inode(InodeIdentifier) const override; diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp index 40437026f5..c2239624eb 100644 --- a/Kernel/SharedMemory.cpp +++ b/Kernel/SharedMemory.cpp @@ -14,6 +14,7 @@ Lockable<HashMap<String, RetainPtr<SharedMemory>>>& shared_memories() KResultOr<Retained<SharedMemory>> SharedMemory::open(const String& name, int flags, mode_t mode) { + UNUSED_PARAM(flags); LOCKER(shared_memories().lock()); auto it = shared_memories().resource().find(name); if (it != shared_memories().resource().end()) { diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h index b45eff726b..4dc2463f07 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -15,7 +15,7 @@ public: ~SharedMemory(); String name() const { return m_name; } - KResult truncate(int); + KResult truncate(off_t); VMObject* vmo() { return m_vmo.ptr(); } const VMObject* vmo() const { return m_vmo.ptr(); } uid_t uid() const { return m_uid; } diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index 16afe5e3b8..5c48276b7e 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -131,7 +131,7 @@ inline bool is_valid_final_character(byte ch) unsigned parse_uint(const String& str, bool& ok) { unsigned value = 0; - for (size_t i = 0; i < str.length(); ++i) { + for (int i = 0; i < str.length(); ++i) { if (str[i] < '0' || str[i] > '9') { ok = false; return 0; diff --git a/Kernel/sync.sh b/Kernel/sync.sh index 72ca5cb893..b84ee183c3 100755 --- a/Kernel/sync.sh +++ b/Kernel/sync.sh @@ -4,7 +4,7 @@ if [ $(id -u) != 0 ]; then fi rm -vf _fs_contents.lock rm -vf _fs_contents -dd if=/dev/zero of=_fs_contents bs=1M count=256 +dd if=/dev/zero of=_fs_contents bs=1M count=512 mke2fs _fs_contents chown 1000:1000 _fs_contents mkdir -vp mnt diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp index 25096819d3..12a33092ca 100644 --- a/LibC/stdio.cpp +++ b/LibC/stdio.cpp @@ -9,6 +9,7 @@ #include <unistd.h> #include <fcntl.h> #include <AK/printf.cpp> +#include <AK/StdLibExtras.h> #include <Kernel/Syscall.h> extern "C" { @@ -405,6 +406,7 @@ FILE* freopen(const char* pathname, const char* mode, FILE* stream) FILE* fdopen(int fd, const char* mode) { + UNUSED_PARAM(mode); // FIXME: Verify that the mode matches how fd is already open. if (fd < 0) return nullptr; diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index 07096155a3..ecc57f6cad 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -133,7 +133,7 @@ void free(void* ptr) return; } - for (unsigned i = header->first_chunk_index; i < (header->first_chunk_index + header->chunk_count); ++i) + for (int i = header->first_chunk_index; i < (header->first_chunk_index + header->chunk_count); ++i) s_malloc_map[i / 8] &= ~(1 << (i % 8)); s_malloc_sum_alloc -= header->chunk_count * CHUNK_SIZE; @@ -473,7 +473,7 @@ long strtol(const char* str, char** endptr, int base) } else if (neg) acc = -acc; if (endptr) - *endptr = (char*)(any ? s - 1 : str); + *endptr = const_cast<char*>((any ? s - 1 : str)); return acc; } diff --git a/LibC/string.cpp b/LibC/string.cpp index eed302db5f..3b84340d62 100644 --- a/LibC/string.cpp +++ b/LibC/string.cpp @@ -202,10 +202,10 @@ char* strchr(const char* str, int c) void* memchr(const void* ptr, int c, size_t size) { char ch = c; - char* cptr = (char*)ptr; + auto* cptr = (const char*)ptr; for (size_t i = 0; i < size; ++i) { if (cptr[i] == ch) - return cptr + i; + return const_cast<char*>(cptr + i); } return nullptr; } @@ -358,7 +358,7 @@ char* strpbrk(const char* s, const char* accept) { while (*s) if(strchr(accept, *s++)) - return (char*)--s; + return const_cast<char*>(--s); return nullptr; } diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp index 5cba9f33ae..28190bdbfd 100644 --- a/LibC/unistd.cpp +++ b/LibC/unistd.cpp @@ -83,7 +83,7 @@ int execl(const char* filename, const char* arg0, ...) } va_end(ap); args.append(nullptr); - return execve(filename, (char* const *)args.data(), environ); + return execve(filename, const_cast<char* const*>(args.data()), environ); } uid_t getuid() diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index b25fa3efe3..cf1d1214fa 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -245,7 +245,7 @@ void GWindow::event(CEvent& event) message.rects[i] = rects[i]; ByteBuffer extra_data; if (rects.size() > WSAPI_ClientMessage::max_inline_rect_count) - extra_data = ByteBuffer::wrap((void*)&rects[WSAPI_ClientMessage::max_inline_rect_count], (rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); + extra_data = ByteBuffer::wrap(&rects[WSAPI_ClientMessage::max_inline_rect_count], (rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); GEventLoop::current().post_message_to_server(message, extra_data); } return; @@ -324,7 +324,7 @@ void GWindow::update(const Rect& a_rect) request.rects[i] = m_pending_paint_event_rects[i]; ByteBuffer extra_data; if (m_pending_paint_event_rects.size() > WSAPI_ClientMessage::max_inline_rect_count) - extra_data = ByteBuffer::wrap((void*)&m_pending_paint_event_rects[WSAPI_ClientMessage::max_inline_rect_count], (m_pending_paint_event_rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); + extra_data = ByteBuffer::wrap(&m_pending_paint_event_rects[WSAPI_ClientMessage::max_inline_rect_count], (m_pending_paint_event_rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); request.rect_count = m_pending_paint_event_rects.size(); GEventLoop::current().post_message_to_server(request, extra_data); m_pending_paint_event_rects.clear_with_capacity(); diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 22cb858356..a0efa9e258 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -516,7 +516,7 @@ void WSClientConnection::post_paint_message(WSWindow& window) message.paint.window_size = window.size(); ByteBuffer extra_data; if (rects.size() > WSAPI_ServerMessage::max_inline_rect_count) - extra_data = ByteBuffer::wrap((void*)&rects[WSAPI_ServerMessage::max_inline_rect_count], (rects.size() - WSAPI_ServerMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); + extra_data = ByteBuffer::wrap(&rects[WSAPI_ServerMessage::max_inline_rect_count], (rects.size() - WSAPI_ServerMessage::max_inline_rect_count) * sizeof(WSAPI_Rect)); post_message(message, extra_data); } diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp index f44d1f281d..f2b8721808 100644 --- a/SharedGraphics/PNGLoader.cpp +++ b/SharedGraphics/PNGLoader.cpp @@ -82,7 +82,7 @@ public: { if (m_size_remaining < count) return false; - buffer = ByteBuffer::wrap((void*)m_data_ptr, count); + buffer = ByteBuffer::wrap(m_data_ptr, count); m_data_ptr += count; m_size_remaining -= count; return true; |