From 46a06c23e30668d90cb5efb44eab05bb4577d08d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Jun 2019 16:22:34 +0200 Subject: [PATCH] Kernel: Fix all compiler warnings. --- Kernel/FileSystem/DiskBackedFileSystem.cpp | 3 ++- Kernel/FileSystem/DiskBackedFileSystem.h | 2 +- Kernel/FileSystem/ProcFS.cpp | 2 +- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/Net/IPv4Socket.h | 2 +- Kernel/Net/TCPSocket.cpp | 3 +-- Kernel/Net/TCPSocket.h | 2 +- Kernel/Net/UDPSocket.cpp | 3 +-- Kernel/Net/UDPSocket.h | 2 +- Kernel/Process.cpp | 2 +- Kernel/VM/PhysicalRegion.cpp | 7 ++++--- Kernel/VM/VMObject.cpp | 6 +++--- Kernel/VM/VMObject.h | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Kernel/FileSystem/DiskBackedFileSystem.cpp b/Kernel/FileSystem/DiskBackedFileSystem.cpp index afb4a8cc5f2..d8b66803a1d 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.cpp +++ b/Kernel/FileSystem/DiskBackedFileSystem.cpp @@ -139,8 +139,9 @@ ByteBuffer DiskBackedFS::read_blocks(unsigned index, unsigned count) const return blocks; } -void DiskBackedFS::set_block_size(unsigned block_size) +void DiskBackedFS::set_block_size(int block_size) { + ASSERT(block_size > 0); if (block_size == m_block_size) return; m_block_size = block_size; diff --git a/Kernel/FileSystem/DiskBackedFileSystem.h b/Kernel/FileSystem/DiskBackedFileSystem.h index 8f75435e710..d1b01e74d8c 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.h +++ b/Kernel/FileSystem/DiskBackedFileSystem.h @@ -17,7 +17,7 @@ public: protected: explicit DiskBackedFS(NonnullRefPtr&&); - void set_block_size(unsigned); + void set_block_size(int); ByteBuffer read_block(unsigned index) const; ByteBuffer read_blocks(unsigned index, unsigned count) const; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index fc712e9e990..b64fd703439 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -294,7 +294,7 @@ ByteBuffer procfs$pid_vmo(InodeIdentifier identifier) region->vmo().name().characters(), ®ion->vmo(), region->vmo().ref_count()); - for (size_t i = 0; i < region->vmo().page_count(); ++i) { + for (int i = 0; i < region->vmo().page_count(); ++i) { auto& physical_page = region->vmo().physical_pages()[i]; builder.appendf("P%x%s(%u) ", physical_page ? physical_page->paddr().get() : 0, diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 95ea2a4d196..1d2ec7a57e0 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -246,7 +246,7 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t return ipv4_packet.payload_size(); } - return protocol_receive(packet.data, buffer, buffer_length, flags, addr, addr_length); + return protocol_receive(packet.data, buffer, buffer_length, flags); } void IPv4Socket::did_receive(const IPv4Address& source_address, word source_port, ByteBuffer&& packet) diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index e983bf8bc39..63f90fe346f 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -50,7 +50,7 @@ protected: int allocate_local_port_if_needed(); virtual KResult protocol_bind() { return KSuccess; } - virtual int protocol_receive(const ByteBuffer&, void*, size_t, int, sockaddr*, socklen_t*) { return -ENOTIMPL; } + virtual int protocol_receive(const ByteBuffer&, void*, size_t, int) { return -ENOTIMPL; } virtual int protocol_send(const void*, int) { return -ENOTIMPL; } virtual KResult protocol_connect(FileDescription&, ShouldBlock) { return KSuccess; } virtual int protocol_allocate_local_port() { return 0; } diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 595958dd028..f9d1c1281d7 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -43,10 +43,9 @@ NonnullRefPtr TCPSocket::create(int protocol) return adopt(*new TCPSocket(protocol)); } -int TCPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) +int TCPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, size_t buffer_size, int flags) { (void)flags; - (void)addr_length; ASSERT(!packet_buffer.is_null()); auto& ipv4_packet = *(const IPv4Packet*)(packet_buffer.pointer()); auto& tcp_packet = *static_cast(ipv4_packet.payload()); diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index 905089abba3..4c71a9be8d2 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -33,7 +33,7 @@ private: static NetworkOrdered compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, word payload_size); - virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override; + virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags) override; virtual int protocol_send(const void*, int) override; virtual KResult protocol_connect(FileDescription&, ShouldBlock) override; virtual int protocol_allocate_local_port() override; diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 0d1b815d373..c36f09c4bf9 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -43,10 +43,9 @@ NonnullRefPtr UDPSocket::create(int protocol) return adopt(*new UDPSocket(protocol)); } -int UDPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) +int UDPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, size_t buffer_size, int flags) { (void)flags; - (void)addr_length; ASSERT(!packet_buffer.is_null()); auto& ipv4_packet = *(const IPv4Packet*)(packet_buffer.pointer()); auto& udp_packet = *static_cast(ipv4_packet.payload()); diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index 3cd147d7e59..fbfce367b2d 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -16,7 +16,7 @@ private: virtual const char* class_name() const override { return "UDPSocket"; } static Lockable>& sockets_by_port(); - virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags, sockaddr* addr, socklen_t* addr_length) override; + virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags) override; virtual int protocol_send(const void*, int) override; virtual KResult protocol_connect(FileDescription&, ShouldBlock) override { return KSuccess; } virtual int protocol_allocate_local_port() override; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index aa18ee1131e..00454a048fe 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -2499,7 +2499,7 @@ int Process::sys$create_shared_buffer(pid_t peer_pid, int size, void** buffer) int shared_buffer_id = ++s_next_shared_buffer_id; auto shared_buffer = make(m_pid, peer_pid, size); shared_buffer->m_shared_buffer_id = shared_buffer_id; - ASSERT(shared_buffer->size() >= size); + ASSERT((int)shared_buffer->size() >= size); shared_buffer->m_pid1_region = allocate_region_with_vmo(VirtualAddress(), shared_buffer->size(), shared_buffer->m_vmo.copy_ref(), 0, "SharedBuffer", PROT_READ | PROT_WRITE); shared_buffer->m_pid1_region->set_shared(true); *buffer = shared_buffer->m_pid1_region->vaddr().as_ptr(); diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index 1aa2b73caf8..af0947cc574 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -78,10 +78,11 @@ void PhysicalRegion::return_page_at(PhysicalAddress addr) int local_offset = addr.get() - m_lower.get(); ASSERT(local_offset >= 0); - ASSERT(local_offset < m_pages * PAGE_SIZE); + ASSERT(local_offset < (int)(m_pages * PAGE_SIZE)); - auto page = local_offset / PAGE_SIZE; - if (page < m_last) m_last = page; + auto page = (unsigned)local_offset / PAGE_SIZE; + if (page < m_last) + m_last = page; m_bitmap.set(page, false); m_used--; diff --git a/Kernel/VM/VMObject.cpp b/Kernel/VM/VMObject.cpp index 9bcd6875eba..0d7bfa65ffa 100644 --- a/Kernel/VM/VMObject.cpp +++ b/Kernel/VM/VMObject.cpp @@ -98,16 +98,16 @@ void VMObject::inode_size_changed(Badge, size_t old_size, size_t new_size InterruptDisabler disabler; - size_t old_page_count = page_count(); + auto old_page_count = page_count(); m_size = new_size; if (page_count() > old_page_count) { // Add null pages and let the fault handler page these in when that day comes. - for (size_t i = old_page_count; i < page_count(); ++i) + for (auto i = old_page_count; i < page_count(); ++i) m_physical_pages.append(nullptr); } else { // Prune the no-longer valid pages. I'm not sure this is actually correct behavior. - for (size_t i = page_count(); i < old_page_count; ++i) + for (auto i = page_count(); i < old_page_count; ++i) m_physical_pages.take_last(); } diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index aff8e2af7c1..c96179201cf 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -33,7 +33,7 @@ public: const String& name() const { return m_name; } void set_name(const String& name) { m_name = name; } - size_t page_count() const { return m_size / PAGE_SIZE; } + int page_count() const { return m_size / PAGE_SIZE; } const Vector>& physical_pages() const { return m_physical_pages; } Vector>& physical_pages() { return m_physical_pages; }