From 318ce5dec8321407e6ecb06399113215924d3ee6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 18 Jun 2024 20:32:43 +0300 Subject: [PATCH] All: Fix a lot of compiler warnings from header files While reworking build system, header files started to report warnings. --- BAN/include/BAN/StringView.h | 2 +- kernel/CMakeLists.txt | 1 + kernel/include/kernel/ACPI/AML/Index.h | 2 +- kernel/include/kernel/ACPI/AML/Integer.h | 2 +- kernel/include/kernel/ACPI/AML/Node.h | 2 +- kernel/include/kernel/ACPI/AML/Notify.h | 10 +- kernel/include/kernel/ACPI/AML/Package.h | 1 - kernel/include/kernel/ACPI/AML/Region.h | 24 +- kernel/include/kernel/Device/DebugDevice.h | 2 +- kernel/include/kernel/Device/Device.h | 2 +- kernel/include/kernel/Device/NullDevice.h | 2 +- kernel/include/kernel/Device/ZeroDevice.h | 2 +- kernel/include/kernel/FS/FAT/FileSystem.h | 6 +- kernel/include/kernel/FS/Inode.h | 2 +- kernel/include/kernel/FS/TmpFS/Definitions.h | 6 +- kernel/include/kernel/GDT.h | 2 +- kernel/include/kernel/IDT.h | 4 +- kernel/include/kernel/Input/PS2/Mouse.h | 2 +- kernel/include/kernel/Interruptable.h | 2 +- .../include/kernel/Networking/NetworkLayer.h | 14 +- .../include/kernel/Networking/UNIX/Socket.h | 2 +- kernel/include/kernel/Panic.h | 1 + kernel/kernel/ACPI/ACPI.cpp | 12 +- kernel/kernel/ACPI/AML/Namespace.cpp | 28 +- kernel/kernel/ACPI/AML/Scope.cpp | 6 +- kernel/kernel/APIC.cpp | 2 +- kernel/kernel/Credentials.cpp | 2 +- kernel/kernel/FS/Ext2/Inode.cpp | 10 +- kernel/kernel/FS/FAT/Inode.cpp | 5 +- kernel/kernel/FS/Inode.cpp | 2 +- kernel/kernel/FS/ProcFS/Inode.cpp | 12 +- kernel/kernel/FS/TmpFS/Inode.cpp | 12 +- kernel/kernel/FS/VirtualFileSystem.cpp | 16 +- kernel/kernel/Input/PS2/Controller.cpp | 2 +- kernel/kernel/Networking/NetworkLayer.cpp | 20 ++ kernel/kernel/OpenFileDescriptorSet.cpp | 8 +- kernel/kernel/Process.cpp | 4 +- kernel/kernel/Terminal/TTY.cpp | 6 +- kernel/kernel/Timer/HPET.cpp | 2 +- kernel/kernel/kernel.cpp | 4 +- .../0001-Add-support-for-banan-os.patch | 2 +- userspace/Shell/main.cpp | 40 +-- userspace/Terminal/Terminal.cpp | 4 +- userspace/WindowServer/WindowServer.h | 2 +- userspace/WindowServer/main.cpp | 4 +- userspace/aoc2023/day19/main.cpp | 8 +- userspace/aoc2023/day20/main.cpp | 2 +- userspace/aoc2023/day8/main.cpp | 4 +- userspace/libraries/LibC/include/sys/select.h | 2 +- .../libraries/LibC/include/sys/sysmacros.h | 6 +- userspace/libraries/LibC/include/sys/types.h | 2 +- .../libraries/LibGUI/include/LibGUI/Window.h | 2 +- userspace/libraries/LibImage/PNG.cpp | 10 +- .../LibImage/include/LibImage/Image.h | 4 +- .../libraries/LibInput/KeyboardLayout.cpp | 318 +++++++++--------- .../LibInput/include/LibInput/KeyEvent.h | 2 +- userspace/ls/main.cpp | 2 +- userspace/resolver/main.cpp | 3 + userspace/stat/main.cpp | 2 +- 59 files changed, 339 insertions(+), 326 deletions(-) create mode 100644 kernel/kernel/Networking/NetworkLayer.cpp diff --git a/BAN/include/BAN/StringView.h b/BAN/include/BAN/StringView.h index 4484979c1c..1b6486ef71 100644 --- a/BAN/include/BAN/StringView.h +++ b/BAN/include/BAN/StringView.h @@ -193,7 +193,7 @@ namespace BAN } -inline constexpr BAN::StringView operator""sv(const char* str, BAN::StringView::size_type len) { return BAN::StringView(str, len); } +inline constexpr BAN::StringView operator""_sv(const char* str, BAN::StringView::size_type len) { return BAN::StringView(str, len); } namespace BAN::Formatter { diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index ce4738ebe0..931b3016b1 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -66,6 +66,7 @@ set(KERNEL_SOURCES kernel/Networking/E1000/E1000E.cpp kernel/Networking/IPv4Layer.cpp kernel/Networking/NetworkInterface.cpp + kernel/Networking/NetworkLayer.cpp kernel/Networking/NetworkManager.cpp kernel/Networking/NetworkSocket.cpp kernel/Networking/TCPSocket.cpp diff --git a/kernel/include/kernel/ACPI/AML/Index.h b/kernel/include/kernel/ACPI/AML/Index.h index d350f3e3ac..3928b092e2 100644 --- a/kernel/include/kernel/ACPI/AML/Index.h +++ b/kernel/include/kernel/ACPI/AML/Index.h @@ -48,7 +48,7 @@ namespace Kernel::ACPI::AML AML_ERROR("IndexOp index is out of buffer bounds"); return ParseResult::Failure; } - auto buffer_field = MUST(BAN::RefPtr::create(NameSeg(""sv), buffer, index.value() * 8, 8)); + auto buffer_field = MUST(BAN::RefPtr::create(NameSeg(""_sv), buffer, index.value() * 8, 8)); result = MUST(BAN::RefPtr::create(buffer_field)); break; } diff --git a/kernel/include/kernel/ACPI/AML/Integer.h b/kernel/include/kernel/ACPI/AML/Integer.h index 2fe80d4ef5..5a459f8297 100644 --- a/kernel/include/kernel/ACPI/AML/Integer.h +++ b/kernel/include/kernel/ACPI/AML/Integer.h @@ -21,8 +21,8 @@ namespace Kernel::ACPI::AML static BAN::RefPtr Ones; }; - const bool constant; uint64_t value; + const bool constant; Integer(uint64_t value, bool constant = false) : Node(Node::Type::Integer) diff --git a/kernel/include/kernel/ACPI/AML/Node.h b/kernel/include/kernel/ACPI/AML/Node.h index 10c0876be7..55a78f3112 100644 --- a/kernel/include/kernel/ACPI/AML/Node.h +++ b/kernel/include/kernel/ACPI/AML/Node.h @@ -45,7 +45,7 @@ namespace Kernel::ACPI::AML [[nodiscard]] BAN::Optional as_integer(); [[nodiscard]] virtual BAN::RefPtr evaluate() { AML_TODO("evaluate, type {}", static_cast(type)); return nullptr; } - [[nodiscard]] virtual bool store(BAN::RefPtr source) { AML_TODO("store, type {}", static_cast(type)); return false; } + [[nodiscard]] virtual bool store(BAN::RefPtr) { AML_TODO("store, type {}", static_cast(type)); return false; } virtual void debug_print(int indent) const = 0; }; diff --git a/kernel/include/kernel/ACPI/AML/Notify.h b/kernel/include/kernel/ACPI/AML/Notify.h index 044de6070b..1a0c3a6525 100644 --- a/kernel/include/kernel/ACPI/AML/Notify.h +++ b/kernel/include/kernel/ACPI/AML/Notify.h @@ -41,20 +41,20 @@ namespace Kernel::ACPI::AML switch (object->type) { case AML::Node::Type::Device: - object_type_sv = "Device"sv; + object_type_sv = "Device"_sv; object_name_sv = static_cast(object.ptr())->name.sv(); break; case AML::Node::Type::Processor: - object_type_sv = "Processor"sv; + object_type_sv = "Processor"_sv; object_name_sv = static_cast(object.ptr())->name.sv(); break; case AML::Node::Type::ThermalZone: - object_type_sv = "ThermalZone"sv; + object_type_sv = "ThermalZone"_sv; object_name_sv = static_cast(object.ptr())->name.sv(); break; default: - object_type_sv = "Unknown"sv; - object_name_sv = "????"sv; + object_type_sv = "Unknown"_sv; + object_name_sv = "????"_sv; break; } diff --git a/kernel/include/kernel/ACPI/AML/Package.h b/kernel/include/kernel/ACPI/AML/Package.h index 13923cc694..fa2d591bee 100644 --- a/kernel/include/kernel/ACPI/AML/Package.h +++ b/kernel/include/kernel/ACPI/AML/Package.h @@ -60,7 +60,6 @@ namespace Kernel::ACPI::AML PackageElement(BAN::RefPtr parent) : Node(Node::Type::PackageElement) , parent(parent) - , unresolved_name(unresolved_name) { resolved = false; initialized = false; diff --git a/kernel/include/kernel/ACPI/AML/Region.h b/kernel/include/kernel/ACPI/AML/Region.h index f38c0e0fdd..1d19d07a23 100644 --- a/kernel/include/kernel/ACPI/AML/Region.h +++ b/kernel/include/kernel/ACPI/AML/Region.h @@ -82,18 +82,18 @@ namespace Kernel::ACPI::AML BAN::StringView region_space_name; switch (region_space) { - case RegionSpace::SystemMemory: region_space_name = "SystemMemory"sv; break; - case RegionSpace::SystemIO: region_space_name = "SystemIO"sv; break; - case RegionSpace::PCIConfig: region_space_name = "PCIConfig"sv; break; - case RegionSpace::EmbeddedController: region_space_name = "EmbeddedController"sv; break; - case RegionSpace::SMBus: region_space_name = "SMBus"sv; break; - case RegionSpace::SystemCMOS: region_space_name = "SystemCMOS"sv; break; - case RegionSpace::PCIBarTarget: region_space_name = "PCIBarTarget"sv; break; - case RegionSpace::IPMI: region_space_name = "IPMI"sv; break; - case RegionSpace::GeneralPurposeIO: region_space_name = "GeneralPurposeIO"sv; break; - case RegionSpace::GenericSerialBus: region_space_name = "GenericSerialBus"sv; break; - case RegionSpace::PlatformCommunicationChannel: region_space_name = "PlatformCommunicationChannel"sv; break; - default: region_space_name = "Unknown"sv; break; + case RegionSpace::SystemMemory: region_space_name = "SystemMemory"_sv; break; + case RegionSpace::SystemIO: region_space_name = "SystemIO"_sv; break; + case RegionSpace::PCIConfig: region_space_name = "PCIConfig"_sv; break; + case RegionSpace::EmbeddedController: region_space_name = "EmbeddedController"_sv; break; + case RegionSpace::SMBus: region_space_name = "SMBus"_sv; break; + case RegionSpace::SystemCMOS: region_space_name = "SystemCMOS"_sv; break; + case RegionSpace::PCIBarTarget: region_space_name = "PCIBarTarget"_sv; break; + case RegionSpace::IPMI: region_space_name = "IPMI"_sv; break; + case RegionSpace::GeneralPurposeIO: region_space_name = "GeneralPurposeIO"_sv; break; + case RegionSpace::GenericSerialBus: region_space_name = "GenericSerialBus"_sv; break; + case RegionSpace::PlatformCommunicationChannel: region_space_name = "PlatformCommunicationChannel"_sv; break; + default: region_space_name = "Unknown"_sv; break; } AML_DEBUG_PRINT_INDENT(indent); AML_DEBUG_PRINT("OperationRegion("); diff --git a/kernel/include/kernel/Device/DebugDevice.h b/kernel/include/kernel/Device/DebugDevice.h index 57897b3f6b..7403be7002 100644 --- a/kernel/include/kernel/Device/DebugDevice.h +++ b/kernel/include/kernel/Device/DebugDevice.h @@ -10,7 +10,7 @@ namespace Kernel virtual dev_t rdev() const override { return m_rdev; } - virtual BAN::StringView name() const override { return "debug"sv; } + virtual BAN::StringView name() const override { return "debug"_sv; } protected: DebugDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) diff --git a/kernel/include/kernel/Device/Device.h b/kernel/include/kernel/Device/Device.h index 53fbb37a79..b038946f0f 100644 --- a/kernel/include/kernel/Device/Device.h +++ b/kernel/include/kernel/Device/Device.h @@ -16,7 +16,7 @@ namespace Kernel virtual bool is_partition() const { return false; } virtual bool is_storage_device() const { return false; } - virtual BAN::ErrorOr> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t) { return BAN::Error::from_errno(EINVAL); } + virtual BAN::ErrorOr> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t) { (void)offset; (void)len; return BAN::Error::from_errno(EINVAL); } virtual dev_t rdev() const override = 0; diff --git a/kernel/include/kernel/Device/NullDevice.h b/kernel/include/kernel/Device/NullDevice.h index ce3ba6fa84..2114aa0e09 100644 --- a/kernel/include/kernel/Device/NullDevice.h +++ b/kernel/include/kernel/Device/NullDevice.h @@ -12,7 +12,7 @@ namespace Kernel virtual dev_t rdev() const override { return m_rdev; } - virtual BAN::StringView name() const override { return "null"sv; } + virtual BAN::StringView name() const override { return "null"_sv; } protected: NullDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) diff --git a/kernel/include/kernel/Device/ZeroDevice.h b/kernel/include/kernel/Device/ZeroDevice.h index 809f54e66c..cf3b7339ca 100644 --- a/kernel/include/kernel/Device/ZeroDevice.h +++ b/kernel/include/kernel/Device/ZeroDevice.h @@ -10,7 +10,7 @@ namespace Kernel virtual dev_t rdev() const override { return m_rdev; } - virtual BAN::StringView name() const override { return "zero"sv; } + virtual BAN::StringView name() const override { return "zero"_sv; } protected: ZeroDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) diff --git a/kernel/include/kernel/FS/FAT/FileSystem.h b/kernel/include/kernel/FS/FAT/FileSystem.h index 7003b6c910..9dcc3cd8fe 100644 --- a/kernel/include/kernel/FS/FAT/FileSystem.h +++ b/kernel/include/kernel/FS/FAT/FileSystem.h @@ -53,12 +53,12 @@ namespace Kernel uint32_t first_fat_sector() const { return m_bpb.reserved_sector_count; } private: - const FAT::BPB m_bpb; - const Type m_type; - BAN::RefPtr m_block_device; BAN::RefPtr m_root_inode; + const FAT::BPB m_bpb; + const Type m_type; + BAN::HashMap> m_inode_cache; BAN::Vector m_fat_two_sector_buffer; diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index 94a48e9978..b9647349da 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -155,7 +155,7 @@ namespace Kernel virtual bool can_write_impl() const = 0; virtual bool has_error_impl() const = 0; - virtual BAN::ErrorOr ioctl_impl(int request, void* arg) { return BAN::Error::from_errno(ENOTSUP); } + virtual BAN::ErrorOr ioctl_impl(int, void*) { return BAN::Error::from_errno(ENOTSUP); } protected: mutable PriorityMutex m_mutex; diff --git a/kernel/include/kernel/FS/TmpFS/Definitions.h b/kernel/include/kernel/FS/TmpFS/Definitions.h index 1b57c0d6c6..a07143452f 100644 --- a/kernel/include/kernel/FS/TmpFS/Definitions.h +++ b/kernel/include/kernel/FS/TmpFS/Definitions.h @@ -14,9 +14,9 @@ namespace Kernel mode_t mode { 0 }; uid_t uid { 0 }; gid_t gid { 0 }; - timespec atime { 0 }; - timespec ctime { 0 }; - timespec mtime { 0 }; + timespec atime { 0, 0 }; + timespec ctime { 0, 0 }; + timespec mtime { 0, 0 }; nlink_t nlink { 0 }; size_t size { 0 }; blkcnt_t blocks { 0 }; diff --git a/kernel/include/kernel/GDT.h b/kernel/include/kernel/GDT.h index bf8bfa5e91..c242d47e19 100644 --- a/kernel/include/kernel/GDT.h +++ b/kernel/include/kernel/GDT.h @@ -154,7 +154,7 @@ namespace Kernel #endif TaskStateSegment m_tss; const GDTR m_gdtr { - .size = m_gdt.size() * sizeof(SegmentDescriptor) - 1, + .size = static_cast(m_gdt.size() * sizeof(SegmentDescriptor) - 1), .address = reinterpret_cast(m_gdt.data()) }; }; diff --git a/kernel/include/kernel/IDT.h b/kernel/include/kernel/IDT.h index c66b223bbe..24dd302a3a 100644 --- a/kernel/include/kernel/IDT.h +++ b/kernel/include/kernel/IDT.h @@ -72,8 +72,8 @@ namespace Kernel private: BAN::Array m_idt; IDTR m_idtr { - .size = m_idt.size() * sizeof(GateDescriptor) - 1, - .offset = reinterpret_cast(m_idt.data()) + .size = static_cast(m_idt.size() * sizeof(GateDescriptor) - 1), + .offset = reinterpret_cast(m_idt.data()) }; }; diff --git a/kernel/include/kernel/Input/PS2/Mouse.h b/kernel/include/kernel/Input/PS2/Mouse.h index fb5eee460f..caba0369de 100644 --- a/kernel/include/kernel/Input/PS2/Mouse.h +++ b/kernel/include/kernel/Input/PS2/Mouse.h @@ -19,7 +19,7 @@ namespace Kernel::Input static BAN::ErrorOr create(PS2Controller&); virtual void send_initialize() override; - virtual void command_timedout(uint8_t* command_data, uint8_t command_size) final override {} + virtual void command_timedout(uint8_t* command_data, uint8_t command_size) final override { (void)command_data; (void)command_size; } virtual void handle_byte(uint8_t) final override; diff --git a/kernel/include/kernel/Interruptable.h b/kernel/include/kernel/Interruptable.h index 8a15665ef7..85f62471fb 100644 --- a/kernel/include/kernel/Interruptable.h +++ b/kernel/include/kernel/Interruptable.h @@ -14,7 +14,7 @@ namespace Kernel protected: Interruptable() = default; - ~Interruptable() {} + virtual ~Interruptable() {} private: int m_irq { -1 }; diff --git a/kernel/include/kernel/Networking/NetworkLayer.h b/kernel/include/kernel/Networking/NetworkLayer.h index dce853452f..68dfe92c37 100644 --- a/kernel/include/kernel/Networking/NetworkLayer.h +++ b/kernel/include/kernel/Networking/NetworkLayer.h @@ -35,18 +35,6 @@ namespace Kernel NetworkLayer() = default; }; - static uint16_t calculate_internet_checksum(BAN::ConstByteSpan packet, const PseudoHeader& pseudo_header) - { - uint32_t checksum = 0; - for (size_t i = 0; i < sizeof(pseudo_header) / sizeof(uint16_t); i++) - checksum += BAN::host_to_network_endian(reinterpret_cast(&pseudo_header)[i]); - for (size_t i = 0; i < packet.size() / sizeof(uint16_t); i++) - checksum += BAN::host_to_network_endian(reinterpret_cast(packet.data())[i]); - if (packet.size() % 2) - checksum += (uint16_t)packet[packet.size() - 1] << 8; - while (checksum >> 16) - checksum = (checksum >> 16) + (checksum & 0xFFFF); - return ~(uint16_t)checksum; - } + uint16_t calculate_internet_checksum(BAN::ConstByteSpan packet, const PseudoHeader& pseudo_header); } diff --git a/kernel/include/kernel/Networking/UNIX/Socket.h b/kernel/include/kernel/Networking/UNIX/Socket.h index 548b449aa2..3766c34dc7 100644 --- a/kernel/include/kernel/Networking/UNIX/Socket.h +++ b/kernel/include/kernel/Networking/UNIX/Socket.h @@ -38,7 +38,7 @@ namespace Kernel BAN::ErrorOr add_packet(BAN::ConstByteSpan); bool is_bound() const { return !m_bound_path.empty(); } - bool is_bound_to_unused() const { return m_bound_path == "X"sv; } + bool is_bound_to_unused() const { return m_bound_path == "X"_sv; } bool is_streaming() const; diff --git a/kernel/include/kernel/Panic.h b/kernel/include/kernel/Panic.h index d734e90aa1..ff70ceac83 100644 --- a/kernel/include/kernel/Panic.h +++ b/kernel/include/kernel/Panic.h @@ -25,6 +25,7 @@ namespace Kernel Debug::dump_stack_trace(); } asm volatile("ud2"); + __builtin_unreachable(); } } diff --git a/kernel/kernel/ACPI/ACPI.cpp b/kernel/kernel/ACPI/ACPI.cpp index 31c17740ac..6a1f1799d8 100644 --- a/kernel/kernel/ACPI/ACPI.cpp +++ b/kernel/kernel/ACPI/ACPI.cpp @@ -132,7 +132,7 @@ acpi_release_global_lock: if (!access_type.has_value()) return {}; - auto op_region = MUST(BAN::RefPtr::create(""sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); + auto op_region = MUST(BAN::RefPtr::create(""_sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); auto field_rules = AML::FieldRules { .access_type = access_type.value(), @@ -141,7 +141,7 @@ acpi_release_global_lock: .access_attrib = AML::FieldRules::AccessAttrib::Normal, .access_length = 0 }; - auto field_element = MUST(BAN::RefPtr::create(""sv, register_bit_offset, register_bit_width, field_rules)); + auto field_element = MUST(BAN::RefPtr::create(""_sv, register_bit_offset, register_bit_width, field_rules)); field_element->op_region = op_region; auto result = field_element->as_integer(); @@ -156,7 +156,7 @@ acpi_release_global_lock: if (!access_type.has_value()) return {}; - auto op_region = MUST(BAN::RefPtr::create(""sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); + auto op_region = MUST(BAN::RefPtr::create(""_sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); auto field_rules = AML::FieldRules { .access_type = access_type.value(), @@ -165,7 +165,7 @@ acpi_release_global_lock: .access_attrib = AML::FieldRules::AccessAttrib::Normal, .access_length = 0 }; - auto field_element = MUST(BAN::RefPtr::create(""sv, register_bit_offset, register_bit_width, field_rules)); + auto field_element = MUST(BAN::RefPtr::create(""_sv, register_bit_offset, register_bit_width, field_rules)); field_element->op_region = op_region; return field_element->store(MUST(BAN::RefPtr::create(value))); @@ -214,7 +214,7 @@ acpi_release_global_lock: { ASSERT(!s_global_lock); - const auto* fadt = static_cast(ACPI::get().get_header("FACP"sv, 0)); + const auto* fadt = static_cast(ACPI::get().get_header("FACP"_sv, 0)); ASSERT(fadt); uintptr_t facs_addr = fadt->firmware_ctrl; @@ -679,7 +679,7 @@ acpi_release_global_lock: return; auto name = path.sv().substring(path.size() - 4); - if (name.substring(0, 2) != "_L"sv && name.substring(0, 2) != "_E"sv) + if (name.substring(0, 2) != "_L"_sv && name.substring(0, 2) != "_E"_sv) return; auto index = hex_sv_to_int(name.substring(2)); diff --git a/kernel/kernel/ACPI/AML/Namespace.cpp b/kernel/kernel/ACPI/AML/Namespace.cpp index 30480ac316..031f47dfa1 100644 --- a/kernel/kernel/ACPI/AML/Namespace.cpp +++ b/kernel/kernel/ACPI/AML/Namespace.cpp @@ -41,7 +41,7 @@ namespace Kernel::ACPI LockGuard _(m_object_mutex); // Base must be non-empty absolute path - ASSERT(relative_base.prefix == "\\"sv || relative_base.path.empty()); + ASSERT(relative_base.prefix == "\\"_sv || relative_base.path.empty()); // Do absolute path lookup if (!relative_path.prefix.empty() || relative_path.path.size() != 1 || mode == FindMode::ForceAbsolute) @@ -50,7 +50,7 @@ namespace Kernel::ACPI MUST(absolute_path.push_back('\\')); // Resolve root and parent references - if (relative_path.prefix == "\\"sv) + if (relative_path.prefix == "\\"_sv) ; else { @@ -76,7 +76,7 @@ namespace Kernel::ACPI if (absolute_path.back() == '.') absolute_path.pop_back(); - if (!check_existence || absolute_path == "\\"sv || m_objects.contains(absolute_path)) + if (!check_existence || absolute_path == "\\"_sv || m_objects.contains(absolute_path)) return absolute_path; return {}; } @@ -125,7 +125,7 @@ namespace Kernel::ACPI if (!canonical_path.has_value()) return nullptr; - if (canonical_path->sv() == "\\"sv) + if (canonical_path->sv() == "\\"_sv) return this; auto it = m_objects.find(canonical_path.value()); @@ -191,28 +191,28 @@ namespace Kernel::ACPI BAN::RefPtr AML::Namespace::create_root_namespace() { ASSERT(!s_root_namespace); - s_root_namespace = MUST(BAN::RefPtr::create(NameSeg("\\"sv))); - s_root_namespace->scope = AML::NameString("\\"sv); + s_root_namespace = MUST(BAN::RefPtr::create(NameSeg("\\"_sv))); + s_root_namespace->scope = AML::NameString("\\"_sv); Integer::Constants::Zero = MUST(BAN::RefPtr::create(0, true)); Integer::Constants::One = MUST(BAN::RefPtr::create(1, true)); Integer::Constants::Ones = MUST(BAN::RefPtr::create(0xFFFFFFFFFFFFFFFF, true)); AML::ParseContext context; - context.scope = AML::NameString("\\"sv); + context.scope = AML::NameString("\\"_sv); // Add predefined namespaces #define ADD_PREDEFIED_NAMESPACE(NAME) \ ASSERT(s_root_namespace->add_named_object(context, AML::NameString("\\" NAME), MUST(BAN::RefPtr::create(NameSeg(NAME))))); - ADD_PREDEFIED_NAMESPACE("_GPE"sv); - ADD_PREDEFIED_NAMESPACE("_PR"sv); - ADD_PREDEFIED_NAMESPACE("_SB"sv); - ADD_PREDEFIED_NAMESPACE("_SI"sv); - ADD_PREDEFIED_NAMESPACE("_TZ"sv); + ADD_PREDEFIED_NAMESPACE("_GPE"_sv); + ADD_PREDEFIED_NAMESPACE("_PR"_sv); + ADD_PREDEFIED_NAMESPACE("_SB"_sv); + ADD_PREDEFIED_NAMESPACE("_SI"_sv); + ADD_PREDEFIED_NAMESPACE("_TZ"_sv); #undef ADD_PREDEFIED_NAMESPACE // Add \_OSI that returns true for Linux compatibility - auto osi = MUST(BAN::RefPtr::create(NameSeg("_OSI"sv), 1, false, 0)); + auto osi = MUST(BAN::RefPtr::create(NameSeg("_OSI"_sv), 1, false, 0)); osi->override_function = [](AML::ParseContext& context) -> BAN::RefPtr { ASSERT(context.method_args[0]); auto arg = context.method_args[0]->evaluate(); @@ -234,7 +234,7 @@ namespace Kernel::ACPI ASSERT(this == s_root_namespace.ptr()); AML::ParseContext context; - context.scope = AML::NameString("\\"sv); + context.scope = AML::NameString("\\"_sv); context.aml_data = BAN::ConstByteSpan(reinterpret_cast(&header), header.length).slice(sizeof(header)); while (context.aml_data.size() > 0) diff --git a/kernel/kernel/ACPI/AML/Scope.cpp b/kernel/kernel/ACPI/AML/Scope.cpp index 588b088218..ef1725c666 100644 --- a/kernel/kernel/ACPI/AML/Scope.cpp +++ b/kernel/kernel/ACPI/AML/Scope.cpp @@ -94,7 +94,7 @@ namespace Kernel::ACPI AML_DEBUG_PRINTLN("Initializing {}", scope->scope); #endif - if (auto reg = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_REG"sv), Namespace::FindMode::ForceAbsolute)) + if (auto reg = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_REG"_sv), Namespace::FindMode::ForceAbsolute)) { bool embedded_controller = false; Namespace::for_each_child(scope->scope, @@ -135,7 +135,7 @@ namespace Kernel::ACPI bool run_ini = true; bool init_children = true; - if (auto sta = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_STA"sv), Namespace::FindMode::ForceAbsolute)) + if (auto sta = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_STA"_sv), Namespace::FindMode::ForceAbsolute)) { auto result = evaluate_or_invoke(sta); if (!result.has_value()) @@ -150,7 +150,7 @@ namespace Kernel::ACPI if (run_ini) { - auto ini = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_INI"sv), Namespace::FindMode::ForceAbsolute); + auto ini = Namespace::root_namespace()->find_object(scope->scope, AML::NameString("_INI"_sv), Namespace::FindMode::ForceAbsolute); if (ini) { if (ini->type != AML::Node::Type::Method) diff --git a/kernel/kernel/APIC.cpp b/kernel/kernel/APIC.cpp index 80f76d4d9d..8830a6991c 100644 --- a/kernel/kernel/APIC.cpp +++ b/kernel/kernel/APIC.cpp @@ -132,7 +132,7 @@ namespace Kernel return nullptr; } - const MADT* madt = (const MADT*)ACPI::ACPI::get().get_header("APIC"sv, 0); + const MADT* madt = (const MADT*)ACPI::ACPI::get().get_header("APIC"_sv, 0); if (madt == nullptr) { dprintln("Could not find MADT header"); diff --git a/kernel/kernel/Credentials.cpp b/kernel/kernel/Credentials.cpp index 7e0e6d2827..b97e380745 100644 --- a/kernel/kernel/Credentials.cpp +++ b/kernel/kernel/Credentials.cpp @@ -21,7 +21,7 @@ namespace Kernel BAN::ErrorOr Credentials::find_username() const { - auto inode = TRY(VirtualFileSystem::get().file_from_absolute_path(*this, "/etc/passwd"sv, O_RDONLY)).inode; + auto inode = TRY(VirtualFileSystem::get().file_from_absolute_path(*this, "/etc/passwd"_sv, O_RDONLY)).inode; BAN::String line; off_t offset = 0; diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index 8bfb27dd37..21250f7435 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -436,8 +436,8 @@ done: auto inode = inode_or_error.release_value(); BAN::ScopeGuard cleanup([&] { inode->cleanup_from_fs(); }); - TRY(inode->link_inode_to_directory(*inode, "."sv)); - TRY(inode->link_inode_to_directory(*this, ".."sv)); + TRY(inode->link_inode_to_directory(*inode, "."_sv)); + TRY(inode->link_inode_to_directory(*this, ".."_sv)); TRY(link_inode_to_directory(*inode, name)); @@ -569,7 +569,7 @@ needs_new_block: if (entry.inode) { BAN::StringView entry_name(entry.name, entry.name_len); - if (entry_name != "."sv && entry_name != ".."sv) + if (entry_name != "."_sv && entry_name != ".."_sv) return false; } @@ -608,12 +608,12 @@ needs_new_block: { BAN::StringView entry_name(entry.name, entry.name_len); - if (entry_name == "."sv) + if (entry_name == "."_sv) { m_inode.links_count--; sync(); } - else if (entry_name == ".."sv) + else if (entry_name == ".."_sv) { auto parent = TRY(Ext2Inode::create(m_fs, entry.inode)); parent->m_inode.links_count--; diff --git a/kernel/kernel/FS/FAT/Inode.cpp b/kernel/kernel/FS/FAT/Inode.cpp index b409592e2a..7542a9a4c0 100644 --- a/kernel/kernel/FS/FAT/Inode.cpp +++ b/kernel/kernel/FS/FAT/Inode.cpp @@ -212,9 +212,10 @@ namespace Kernel return valid_entry_count; } - BAN::ErrorOr FATInode::read_impl(off_t offset, BAN::ByteSpan buffer) + BAN::ErrorOr FATInode::read_impl(off_t s_offset, BAN::ByteSpan buffer) { - ASSERT(offset >= 0); + ASSERT(s_offset >= 0); + uint32_t offset = s_offset; if (offset >= m_entry.file_size) return 0; diff --git a/kernel/kernel/FS/Inode.cpp b/kernel/kernel/FS/Inode.cpp index 2b6ef111c2..a8a8a620bb 100644 --- a/kernel/kernel/FS/Inode.cpp +++ b/kernel/kernel/FS/Inode.cpp @@ -103,7 +103,7 @@ namespace Kernel LockGuard _(m_mutex); if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); - if (name == "."sv || name == ".."sv) + if (name == "."_sv || name == ".."_sv) return BAN::Error::from_errno(EINVAL); return unlink_impl(name); } diff --git a/kernel/kernel/FS/ProcFS/Inode.cpp b/kernel/kernel/FS/ProcFS/Inode.cpp index c881341989..9d573b995a 100644 --- a/kernel/kernel/FS/ProcFS/Inode.cpp +++ b/kernel/kernel/FS/ProcFS/Inode.cpp @@ -12,9 +12,9 @@ namespace Kernel return BAN::Error::from_errno(ENOMEM); auto inode = BAN::RefPtr::adopt(inode_ptr); - TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_meminfo, fs, 0400, uid, gid)), "meminfo"sv)); - TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_cmdline, fs, 0400, uid, gid)), "cmdline"sv)); - TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_environ, fs, 0400, uid, gid)), "environ"sv)); + TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_meminfo, fs, 0400, uid, gid)), "meminfo"_sv)); + TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_cmdline, fs, 0400, uid, gid)), "cmdline"_sv)); + TRY(inode->link_inode(*MUST(ProcROInode::create_new(process, &Process::proc_environ, fs, 0400, uid, gid)), "environ"_sv)); return inode; } @@ -27,9 +27,9 @@ namespace Kernel void ProcPidInode::cleanup() { - (void)TmpDirectoryInode::unlink_impl("meminfo"sv); - (void)TmpDirectoryInode::unlink_impl("cmdline"sv); - (void)TmpDirectoryInode::unlink_impl("environ"sv); + (void)TmpDirectoryInode::unlink_impl("meminfo"_sv); + (void)TmpDirectoryInode::unlink_impl("cmdline"_sv); + (void)TmpDirectoryInode::unlink_impl("environ"_sv); } BAN::ErrorOr> ProcROInode::create_new(Process& process, size_t (Process::*callback)(off_t, BAN::ByteSpan) const, TmpFileSystem& fs, mode_t mode, uid_t uid, gid_t gid) diff --git a/kernel/kernel/FS/TmpFS/Inode.cpp b/kernel/kernel/FS/TmpFS/Inode.cpp index 3e6e3c99a3..4fff2bfe7c 100644 --- a/kernel/kernel/FS/TmpFS/Inode.cpp +++ b/kernel/kernel/FS/TmpFS/Inode.cpp @@ -342,8 +342,8 @@ namespace Kernel return BAN::Error::from_errno(ENOMEM); auto inode = BAN::RefPtr::adopt(inode_ptr); - TRY(inode->link_inode(*inode, "."sv)); - TRY(inode->link_inode(*inode, ".."sv)); + TRY(inode->link_inode(*inode, "."_sv)); + TRY(inode->link_inode(*inode, ".."_sv)); return inode; } @@ -358,8 +358,8 @@ namespace Kernel return BAN::Error::from_errno(ENOMEM); auto inode = BAN::RefPtr::adopt(inode_ptr); - TRY(inode->link_inode(*inode, "."sv)); - TRY(inode->link_inode(parent, ".."sv)); + TRY(inode->link_inode(*inode, "."_sv)); + TRY(inode->link_inode(parent, ".."_sv)); return inode; } @@ -381,9 +381,9 @@ namespace Kernel bool is_empty = true; for_each_valid_entry([&](TmpDirectoryEntry& entry) { - if (entry.name_sv() == "."sv) + if (entry.name_sv() == "."_sv) dot_ino = entry.ino; - else if (entry.name_sv() == ".."sv) + else if (entry.name_sv() == ".."_sv) dotdot_ino = entry.ino; else { diff --git a/kernel/kernel/FS/VirtualFileSystem.cpp b/kernel/kernel/FS/VirtualFileSystem.cpp index d8b223659e..8c1181f520 100644 --- a/kernel/kernel/FS/VirtualFileSystem.cpp +++ b/kernel/kernel/FS/VirtualFileSystem.cpp @@ -17,7 +17,7 @@ namespace Kernel ASSERT(!s_instance); s_instance = MUST(BAN::RefPtr::create()); - ASSERT(root_path.size() >= 5 && root_path.substring(0, 5) == "/dev/"sv);; + ASSERT(root_path.size() >= 5 && root_path.substring(0, 5) == "/dev/"_sv);; root_path = root_path.substring(5); auto root_inode = MUST(DevFileSystem::get().root_inode()->find_inode(root_path)); @@ -26,12 +26,12 @@ namespace Kernel s_instance->m_root_fs = MUST(FileSystem::from_block_device(static_cast(root_inode.ptr()))); Credentials root_creds { 0, 0, 0, 0 }; - MUST(s_instance->mount(root_creds, &DevFileSystem::get(), "/dev"sv)); + MUST(s_instance->mount(root_creds, &DevFileSystem::get(), "/dev"_sv)); - MUST(s_instance->mount(root_creds, &ProcFileSystem::get(), "/proc"sv)); + MUST(s_instance->mount(root_creds, &ProcFileSystem::get(), "/proc"_sv)); auto tmpfs = MUST(TmpFileSystem::create(1024, 0777, 0, 0)); - MUST(s_instance->mount(root_creds, tmpfs, "/tmp"sv)); + MUST(s_instance->mount(root_creds, tmpfs, "/tmp"_sv)); } VirtualFileSystem& VirtualFileSystem::get() @@ -109,16 +109,16 @@ namespace Kernel const auto& path_part = path_parts.back(); auto orig = inode; - if (path_part.empty() || path_part == "."sv) + if (path_part.empty() || path_part == "."_sv) { } - else if (path_part == ".."sv) + else if (path_part == ".."_sv) { if (auto* mount_point = mount_from_root_inode(inode)) - inode = TRY(mount_point->host.inode->find_inode(".."sv)); + inode = TRY(mount_point->host.inode->find_inode(".."_sv)); else - inode = TRY(inode->find_inode(".."sv)); + inode = TRY(inode->find_inode(".."_sv)); if (!canonical_path.empty()) { diff --git a/kernel/kernel/Input/PS2/Controller.cpp b/kernel/kernel/Input/PS2/Controller.cpp index 14cf3ab27b..e48ae9613a 100644 --- a/kernel/kernel/Input/PS2/Controller.cpp +++ b/kernel/kernel/Input/PS2/Controller.cpp @@ -244,7 +244,7 @@ namespace Kernel::Input // FIXME: Initialise USB Controllers // Determine if the PS/2 Controller Exists - auto* fadt = static_cast(ACPI::ACPI::get().get_header("FACP"sv, 0)); + auto* fadt = static_cast(ACPI::ACPI::get().get_header("FACP"_sv, 0)); if (fadt && fadt->revision > 1 && !(fadt->iapc_boot_arch & (1 << 1))) { dwarnln_if(DEBUG_PS2, "No PS/2 available"); diff --git a/kernel/kernel/Networking/NetworkLayer.cpp b/kernel/kernel/Networking/NetworkLayer.cpp new file mode 100644 index 0000000000..05bea4da91 --- /dev/null +++ b/kernel/kernel/Networking/NetworkLayer.cpp @@ -0,0 +1,20 @@ +#include + +namespace Kernel +{ + + uint16_t calculate_internet_checksum(BAN::ConstByteSpan packet, const PseudoHeader& pseudo_header) + { + uint32_t checksum = 0; + for (size_t i = 0; i < sizeof(pseudo_header) / sizeof(uint16_t); i++) + checksum += BAN::host_to_network_endian(reinterpret_cast(&pseudo_header)[i]); + for (size_t i = 0; i < packet.size() / sizeof(uint16_t); i++) + checksum += BAN::host_to_network_endian(reinterpret_cast(packet.data())[i]); + if (packet.size() % 2) + checksum += (uint16_t)packet[packet.size() - 1] << 8; + while (checksum >> 16) + checksum = (checksum >> 16) + (checksum & 0xFFFF); + return ~(uint16_t)checksum; + } + +} diff --git a/kernel/kernel/OpenFileDescriptorSet.cpp b/kernel/kernel/OpenFileDescriptorSet.cpp index ba1fc3390e..58fa666cb1 100644 --- a/kernel/kernel/OpenFileDescriptorSet.cpp +++ b/kernel/kernel/OpenFileDescriptorSet.cpp @@ -65,7 +65,7 @@ namespace Kernel int fd = TRY(get_free_fd()); // FIXME: path? - m_open_files[fd] = TRY(BAN::RefPtr::create(inode, ""sv, 0, flags)); + m_open_files[fd] = TRY(BAN::RefPtr::create(inode, ""_sv, 0, flags)); return fd; } @@ -141,7 +141,7 @@ namespace Kernel auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid())); int fd = TRY(get_free_fd()); - m_open_files[fd] = TRY(BAN::RefPtr::create(socket, "no-path"sv, 0, O_RDWR)); + m_open_files[fd] = TRY(BAN::RefPtr::create(socket, "no-path"_sv, 0, O_RDWR)); return fd; } @@ -150,8 +150,8 @@ namespace Kernel TRY(get_free_fd_pair(fds)); auto pipe = TRY(Pipe::create(m_credentials)); - m_open_files[fds[0]] = TRY(BAN::RefPtr::create(pipe, ""sv, 0, O_RDONLY)); - m_open_files[fds[1]] = TRY(BAN::RefPtr::create(pipe, ""sv, 0, O_WRONLY)); + m_open_files[fds[0]] = TRY(BAN::RefPtr::create(pipe, ""_sv, 0, O_RDONLY)); + m_open_files[fds[1]] = TRY(BAN::RefPtr::create(pipe, ""_sv, 0, O_WRONLY)); return {}; } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 6c09028479..508f3deb46 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -118,7 +118,7 @@ namespace Kernel TRY(process->m_cmdline.push_back({})); TRY(process->m_cmdline.back().append(path)); - process->m_loadable_elf = TRY(load_elf_for_exec(credentials, path, "/"sv, process->page_table())); + process->m_loadable_elf = TRY(load_elf_for_exec(credentials, path, "/"_sv, process->page_table())); if (!process->m_loadable_elf->is_address_space_free()) { dprintln("Could not load ELF address space"); @@ -1942,7 +1942,7 @@ namespace Kernel { LockGuard _(m_process_lock); - if (path.empty() || path == "."sv) + if (path.empty() || path == "."_sv) return m_working_directory; BAN::String absolute_path; diff --git a/kernel/kernel/Terminal/TTY.cpp b/kernel/kernel/Terminal/TTY.cpp index 23d58e14b1..b8d2633bd6 100644 --- a/kernel/kernel/Terminal/TTY.cpp +++ b/kernel/kernel/Terminal/TTY.cpp @@ -30,11 +30,11 @@ namespace Kernel s_tty = this; clear(); - auto inode_or_error = DevFileSystem::get().root_inode()->find_inode("tty"sv); + auto inode_or_error = DevFileSystem::get().root_inode()->find_inode("tty"_sv); if (inode_or_error.is_error()) { if (inode_or_error.error().get_error_code() == ENOENT) - DevFileSystem::get().add_inode("tty"sv, MUST(TmpSymlinkInode::create_new(DevFileSystem::get(), 0666, 0, 0, s_tty->name()))); + DevFileSystem::get().add_inode("tty"_sv, MUST(TmpSymlinkInode::create_new(DevFileSystem::get(), 0666, 0, 0, s_tty->name()))); else dwarnln("{}", inode_or_error.error()); return; @@ -82,7 +82,7 @@ namespace Kernel Process::create_kernel( [](void*) { - auto file_or_error = VirtualFileSystem::get().file_from_absolute_path({ 0, 0, 0, 0 }, "/dev/input0"sv, O_RDONLY); + auto file_or_error = VirtualFileSystem::get().file_from_absolute_path({ 0, 0, 0, 0 }, "/dev/input0"_sv, O_RDONLY); if (file_or_error.is_error()) { dprintln("no input device found"); diff --git a/kernel/kernel/Timer/HPET.cpp b/kernel/kernel/Timer/HPET.cpp index 6d27eaed71..226ca60be4 100644 --- a/kernel/kernel/Timer/HPET.cpp +++ b/kernel/kernel/Timer/HPET.cpp @@ -131,7 +131,7 @@ namespace Kernel BAN::ErrorOr HPET::initialize(bool force_pic) { - auto* header = static_cast(ACPI::ACPI::get().get_header("HPET"sv, 0)); + auto* header = static_cast(ACPI::ACPI::get().get_header("HPET"_sv, 0)); if (header == nullptr) return BAN::Error::from_errno(ENODEV); diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index 1d87fa3bdf..3d11dcc932 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -34,7 +34,7 @@ struct ParsedCommandLine { bool force_pic = false; bool disable_serial = false; - BAN::StringView console = "tty0"sv; + BAN::StringView console = "tty0"_sv; BAN::StringView root; }; @@ -215,7 +215,7 @@ static void init2(void*) TTY::initialize_devices(); - MUST(Process::create_userspace({ 0, 0, 0, 0 }, "/usr/bin/init"sv)); + MUST(Process::create_userspace({ 0, 0, 0, 0 }, "/usr/bin/init"_sv)); } extern "C" void ap_main() diff --git a/ports/doom/patches/0001-Add-support-for-banan-os.patch b/ports/doom/patches/0001-Add-support-for-banan-os.patch index 0d9904593e..041e21f17a 100644 --- a/ports/doom/patches/0001-Add-support-for-banan-os.patch +++ b/ports/doom/patches/0001-Add-support-for-banan-os.patch @@ -112,7 +112,7 @@ index 0000000..9161771 + +void DG_Init() +{ -+ s_window = MUST(LibGUI::Window::create(DOOMGENERIC_RESX, DOOMGENERIC_RESY, "DOOM"sv)); ++ s_window = MUST(LibGUI::Window::create(DOOMGENERIC_RESX, DOOMGENERIC_RESY, "DOOM"_sv)); + s_window->set_key_event_callback( + [](LibGUI::EventPacket::KeyEvent event) + { diff --git a/userspace/Shell/main.cpp b/userspace/Shell/main.cpp index 30abe0e538..b921198d71 100644 --- a/userspace/Shell/main.cpp +++ b/userspace/Shell/main.cpp @@ -36,7 +36,7 @@ BAN::Optional parse_dollar(BAN::StringView command, size_t& i) ASSERT(command[i] == '$'); if (++i >= command.size()) - return "$"sv; + return "$"_sv; if (command[i] == '?') { @@ -54,7 +54,7 @@ BAN::Optional parse_dollar(BAN::StringView command, size_t& i) if (const char* value = getenv(name.data())) return BAN::StringView(value); - return ""sv; + return ""_sv; } else if (command[i] == '{') { @@ -75,7 +75,7 @@ BAN::Optional parse_dollar(BAN::StringView command, size_t& i) if (const char* value = getenv(name.data())) return BAN::StringView(value); - return ""sv; + return ""_sv; } else if (command[i] == '[') { @@ -156,7 +156,7 @@ BAN::Optional parse_dollar(BAN::StringView command, size_t& i) return output; } - BAN::String temp = "$"sv; + BAN::String temp = "$"_sv; MUST(temp.push_back(command[i])); return temp; } @@ -288,16 +288,16 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in } BAN::ScopeGuard _([fout, should_close] { if (should_close) fclose(fout); }); - if (args.front() == "clear"sv) + if (args.front() == "clear"_sv) { fprintf(fout, "\e[H\e[2J"); fflush(fout); } - else if (args.front() == "exit"sv) + else if (args.front() == "exit"_sv) { clean_exit(); } - else if (args.front() == "export"sv) + else if (args.front() == "export"_sv) { bool first = false; for (const auto& arg : args) @@ -316,7 +316,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in ERROR_RETURN("setenv", 1); } } - else if (args.front() == "source"sv) + else if (args.front() == "source"_sv) { if (args.size() != 2) { @@ -325,13 +325,13 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in } return source_script(args[1]); } - else if (args.front() == "env"sv) + else if (args.front() == "env"_sv) { char** current = environ; while (*current) fprintf(fout, "%s\n", *current++); } - else if (args.front() == "start-gui"sv) + else if (args.front() == "start-gui"_sv) { pid_t pid = fork(); if (pid == 0) @@ -340,12 +340,12 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in execl("/bin/Terminal", "Terminal", NULL); waitpid(pid, nullptr, 0); } - else if (args.front() == "page-fault-test"sv) + else if (args.front() == "page-fault-test"_sv) { volatile int* ptr = nullptr; *ptr = 0; } - else if (args.front() == "kill-test"sv) + else if (args.front() == "kill-test"_sv) { pid_t pid = fork(); if (pid == 0) @@ -366,7 +366,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in return 1; } } - else if (args.front() == "signal-test"sv) + else if (args.front() == "signal-test"_sv) { pid_t pid = fork(); if (pid == 0) @@ -400,7 +400,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in return 1; } } - else if (args.front() == "printf-test"sv) + else if (args.front() == "printf-test"_sv) { fprintf(fout, " 0.0: %f\n", 0.0f); fprintf(fout, " 123.0: %f\n", 123.0f); @@ -409,7 +409,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in fprintf(fout, "+INF: %f\n", INFINITY); fprintf(fout, "-INF: %f\n", -INFINITY); } - else if (args.front() == "cd"sv) + else if (args.front() == "cd"_sv) { if (args.size() > 2) { @@ -432,7 +432,7 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in if (chdir(path.data()) == -1) ERROR_RETURN("chdir", 1); } - else if (args.front() == "time"sv) + else if (args.front() == "time"_sv) { args.remove(0); @@ -783,7 +783,7 @@ int source_shellrc() if (char* home = getenv("HOME")) { BAN::String path(home); - MUST(path.append("/.shellrc"sv)); + MUST(path.append("/.shellrc"_sv)); if (exists(path)) return source_script(path); } @@ -816,7 +816,7 @@ BAN::String get_prompt() { const char* raw_prompt = getenv("PS1"); if (raw_prompt == nullptr) - return "$ "sv; + return "$ "_sv; BAN::String prompt; for (int i = 0; raw_prompt[i]; i++) @@ -962,7 +962,7 @@ int main(int argc, char** argv) tcsetattr(0, TCSANOW, &new_termios); BAN::Vector buffers, history; - MUST(buffers.emplace_back(""sv)); + MUST(buffers.emplace_back(""_sv)); size_t index = 0; size_t col = 0; @@ -1073,7 +1073,7 @@ int main(int argc, char** argv) last_return = parse_and_execute_command(buffers[index]); MUST(history.push_back(buffers[index])); buffers = history; - MUST(buffers.emplace_back(""sv)); + MUST(buffers.emplace_back(""_sv)); } print_prompt(); index = buffers.size() - 1; diff --git a/userspace/Terminal/Terminal.cpp b/userspace/Terminal/Terminal.cpp index 44816be0ea..27690bd0c6 100644 --- a/userspace/Terminal/Terminal.cpp +++ b/userspace/Terminal/Terminal.cpp @@ -87,11 +87,11 @@ void Terminal::run() signal(SIGCHLD, [](int) { s_shell_exited = true; }); start_shell(); - m_window = MUST(LibGUI::Window::create(600, 400, "Terminal"sv)); + m_window = MUST(LibGUI::Window::create(600, 400, "Terminal"_sv)); m_window->fill(m_bg_color); m_window->invalidate(); - m_font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"sv)); + m_font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv)); m_window->set_key_event_callback([&](LibGUI::EventPacket::KeyEvent event) { on_key_event(event); }); diff --git a/userspace/WindowServer/WindowServer.h b/userspace/WindowServer/WindowServer.h index eba52abd9f..cf3c8f1bea 100644 --- a/userspace/WindowServer/WindowServer.h +++ b/userspace/WindowServer/WindowServer.h @@ -22,7 +22,7 @@ public: WindowServer(Framebuffer& framebuffer) : m_framebuffer(framebuffer) , m_cursor({ framebuffer.width / 2, framebuffer.height / 2 }) - , m_font(MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"sv))) + , m_font(MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv))) { invalidate(m_framebuffer.area()); } diff --git a/userspace/WindowServer/main.cpp b/userspace/WindowServer/main.cpp index b984e1d8b4..c111597d6d 100644 --- a/userspace/WindowServer/main.cpp +++ b/userspace/WindowServer/main.cpp @@ -80,7 +80,7 @@ Config parse_config() auto variable = parts[0]; auto value = parts[1]; - if (variable == "bg"sv) + if (variable == "bg"_sv) { auto image = LibImage::Image::load_from_file(value); if (image.is_error()) @@ -156,7 +156,7 @@ int main() atexit([]() { tty_ctrl(STDIN_FILENO, TTY_CMD_SET, TTY_FLAG_ENABLE_INPUT); }); MUST(LibInput::KeyboardLayout::initialize()); - MUST(LibInput::KeyboardLayout::get().load_from_file("/usr/share/keymaps/us.keymap"sv)); + MUST(LibInput::KeyboardLayout::get().load_from_file("/usr/share/keymaps/us.keymap"_sv)); int keyboard_fd = open("/dev/input0", O_RDONLY); if (keyboard_fd == -1) diff --git a/userspace/aoc2023/day19/main.cpp b/userspace/aoc2023/day19/main.cpp index d0c39d16ea..84f403a455 100644 --- a/userspace/aoc2023/day19/main.cpp +++ b/userspace/aoc2023/day19/main.cpp @@ -168,9 +168,9 @@ bool is_accepted(const Item& item, const BAN::String& name, const Workflows& wor { if (!satifies_rule(item, rule)) continue; - if (rule.target == "A"sv) + if (rule.target == "A"_sv) return true; - if (rule.target == "R"sv) + if (rule.target == "R"_sv) return false; return is_accepted(item, rule.target, workflows); } @@ -185,7 +185,7 @@ i64 puzzle1(FILE* fp) BAN::Vector accepted; for (const auto& item : items) - if (is_accepted(item, "in"sv, workflows)) + if (is_accepted(item, "in"_sv, workflows)) MUST(accepted.push_back(item)); i64 result = 0; @@ -243,7 +243,7 @@ i64 puzzle2(FILE* fp) values_sorted[2][ai], values_sorted[3][si] }}; - if (!is_accepted(item, "in"sv, workflows)) + if (!is_accepted(item, "in"_sv, workflows)) continue; i64 x_count = values_sorted[0][xi + 1] - values_sorted[0][xi]; diff --git a/userspace/aoc2023/day20/main.cpp b/userspace/aoc2023/day20/main.cpp index b1cee4520f..8638830411 100644 --- a/userspace/aoc2023/day20/main.cpp +++ b/userspace/aoc2023/day20/main.cpp @@ -137,7 +137,7 @@ i64 puzzle1(FILE* fp) for (size_t i = 0; i < 1000; i++) { - MUST(signal_queue.push({ "broadcaster"sv, ""sv, false })); + MUST(signal_queue.push({ "broadcaster"_sv, ""_sv, false })); while (!signal_queue.empty()) { auto signal = signal_queue.front(); diff --git a/userspace/aoc2023/day8/main.cpp b/userspace/aoc2023/day8/main.cpp index a4be917396..42d588c56d 100644 --- a/userspace/aoc2023/day8/main.cpp +++ b/userspace/aoc2023/day8/main.cpp @@ -45,8 +45,8 @@ i64 puzzle1(FILE* fp) } } - u32 current = coord_to_u32("AAA"sv); - u32 target = coord_to_u32("ZZZ"sv); + u32 current = coord_to_u32("AAA"_sv); + u32 target = coord_to_u32("ZZZ"_sv); i64 steps = 0; for (; current != target; steps++) diff --git a/userspace/libraries/LibC/include/sys/select.h b/userspace/libraries/LibC/include/sys/select.h index c09e545d2b..555103c1cd 100644 --- a/userspace/libraries/LibC/include/sys/select.h +++ b/userspace/libraries/LibC/include/sys/select.h @@ -44,7 +44,7 @@ typedef struct { #define FD_ZERO(setp) \ do { \ - for (int i = 0; i < FD_SETSIZE / __FD_MASK_SIZE; i++) \ + for (int i = 0; i < (int)FD_SETSIZE / (int)__FD_MASK_SIZE; i++) \ (setp)->__bits[i] = (__fd_mask)0; \ } while (0) diff --git a/userspace/libraries/LibC/include/sys/sysmacros.h b/userspace/libraries/LibC/include/sys/sysmacros.h index d72bd84356..3d5c40b40f 100644 --- a/userspace/libraries/LibC/include/sys/sysmacros.h +++ b/userspace/libraries/LibC/include/sys/sysmacros.h @@ -8,10 +8,10 @@ __BEGIN_DECLS #define __need_pid_t #include -#define makedev(maj, min) ((dev_t)(maj) << 32 | (dev_t)(min)) +#define makedev(maj, min) ((dev_t)(maj) << 16 | (dev_t)(min)) -#define major(dev) (((dev) >> 32) & 0xFFFFFFFF) -#define minor(dev) ( (dev) & 0xFFFFFFFF) +#define major(dev) (((dev) >> 16) & 0xFFFF) +#define minor(dev) ( (dev) & 0xFFFF) __END_DECLS diff --git a/userspace/libraries/LibC/include/sys/types.h b/userspace/libraries/LibC/include/sys/types.h index c01093e18d..bae8324562 100644 --- a/userspace/libraries/LibC/include/sys/types.h +++ b/userspace/libraries/LibC/include/sys/types.h @@ -74,7 +74,7 @@ __BEGIN_DECLS #if !defined(__dev_t_defined) && (defined(__need_all_types) || defined(__need_dev_t)) #define __dev_t_defined 1 - typedef unsigned long dev_t; + typedef unsigned int dev_t; #endif #undef __need_dev_t diff --git a/userspace/libraries/LibGUI/include/LibGUI/Window.h b/userspace/libraries/LibGUI/include/LibGUI/Window.h index 826b9d6ba5..1a21f39b30 100644 --- a/userspace/libraries/LibGUI/include/LibGUI/Window.h +++ b/userspace/libraries/LibGUI/include/LibGUI/Window.h @@ -15,7 +15,7 @@ namespace LibFont { class Font; } namespace LibGUI { - static constexpr BAN::StringView s_window_server_socket = "/tmp/window-server.socket"sv; + static constexpr BAN::StringView s_window_server_socket = "/tmp/window-server.socket"_sv; enum WindowPacketType : uint8_t { diff --git a/userspace/libraries/LibImage/PNG.cpp b/userspace/libraries/LibImage/PNG.cpp index 54486702a9..1118e44d1e 100644 --- a/userspace/libraries/LibImage/PNG.cpp +++ b/userspace/libraries/LibImage/PNG.cpp @@ -608,12 +608,12 @@ namespace LibImage return BAN::Error::from_errno(EINVAL); } - if (chunk.name == "IHDR"sv) + if (chunk.name == "IHDR"_sv) { dwarnln_if(DEBUG_PNG, "PNG stream has IDHR chunk defined multiple times"); return BAN::Error::from_errno(EINVAL); } - else if (chunk.name == "PLTE"sv) + else if (chunk.name == "PLTE"_sv) { if (chunk.data.size() == 0 || chunk.data.size() % 3) { @@ -639,15 +639,15 @@ namespace LibImage palette[i].a = 0xFF; } } - else if (chunk.name == "IDAT"sv) + else if (chunk.name == "IDAT"_sv) { TRY(zlib_stream.push_back(chunk.data)); } - else if (chunk.name == "IEND"sv) + else if (chunk.name == "IEND"_sv) { break; } - else if (chunk.name == "tEXt"sv) + else if (chunk.name == "tEXt"_sv) { auto data_sv = BAN::StringView(chunk.data.as_span().data(), chunk.data.size()); if (auto idx = data_sv.find('\0'); !idx.has_value()) diff --git a/userspace/libraries/LibImage/include/LibImage/Image.h b/userspace/libraries/LibImage/include/LibImage/Image.h index 418552036d..bb097ed009 100644 --- a/userspace/libraries/LibImage/include/LibImage/Image.h +++ b/userspace/libraries/LibImage/include/LibImage/Image.h @@ -63,9 +63,9 @@ namespace LibImage return false; if (height > static_cast(BAN::numeric_limits::max())) return false; - if (BAN::Math::will_multiplication_overflow(width, height)) + if (BAN::Math::will_multiplication_overflow(width, height)) return false; - if (BAN::Math::will_multiplication_overflow(width * height, sizeof(Color))) + if (BAN::Math::will_multiplication_overflow(width * height, sizeof(Color))) return false; return true; } diff --git a/userspace/libraries/LibInput/KeyboardLayout.cpp b/userspace/libraries/LibInput/KeyboardLayout.cpp index 724791e0d4..992ea07161 100644 --- a/userspace/libraries/LibInput/KeyboardLayout.cpp +++ b/userspace/libraries/LibInput/KeyboardLayout.cpp @@ -162,7 +162,7 @@ namespace LibInput if (parts.empty() || parts.front().front() == '#') continue; - if (parts.front() == "include"sv) + if (parts.front() == "include"_sv) { if (parts.size() != 2) { @@ -228,7 +228,7 @@ namespace LibInput return BAN::Error::from_errno(EINVAL); } - if (parts.front() == "mod"sv) + if (parts.front() == "mod"_sv) { if (parts.size() != 2) { @@ -236,9 +236,9 @@ namespace LibInput dprintln(" format: mod MODIFIER"); return BAN::Error::from_errno(EINVAL); } - if (parts[1] == "shift"sv) + if (parts[1] == "shift"_sv) shift_is_mod = true; - else if (parts[1] == "altgr"sv) + else if (parts[1] == "altgr"_sv) altgr_is_mod = true; else { @@ -282,9 +282,9 @@ namespace LibInput return BAN::Error::from_errno(EINVAL); } - if (shift_is_mod && pair.front() == "shift"sv) + if (shift_is_mod && pair.front() == "shift"_sv) new_layout->m_keycode_to_key_shift[*keycode] = *key; - else if (altgr_is_mod && pair.front() == "altgr"sv) + else if (altgr_is_mod && pair.front() == "altgr"_sv) new_layout->m_keycode_to_key_altgr[*keycode] = *key; else { @@ -314,159 +314,159 @@ namespace LibInput static BAN::ErrorOr initialize_name_to_key() { ASSERT(s_name_to_key.empty()); - TRY(s_name_to_key.insert("A_Ring"sv, Key::A_Ring)); - TRY(s_name_to_key.insert("A_Umlaut"sv, Key::A_Umlaut)); - TRY(s_name_to_key.insert("A"sv, Key::A)); - TRY(s_name_to_key.insert("Acute"sv, Key::Acute)); - TRY(s_name_to_key.insert("AltGr"sv, Key::AltGr)); - TRY(s_name_to_key.insert("Ampersand"sv, Key::Ampersand)); - TRY(s_name_to_key.insert("ArrowDown"sv, Key::ArrowDown)); - TRY(s_name_to_key.insert("ArrowLeft"sv, Key::ArrowLeft)); - TRY(s_name_to_key.insert("ArrowRight"sv, Key::ArrowRight)); - TRY(s_name_to_key.insert("ArrowUp"sv, Key::ArrowUp)); - TRY(s_name_to_key.insert("Asterix"sv, Key::Asterix)); - TRY(s_name_to_key.insert("AtSign"sv, Key::AtSign)); - TRY(s_name_to_key.insert("B"sv, Key::B)); - TRY(s_name_to_key.insert("BackSlash"sv, Key::BackSlash)); - TRY(s_name_to_key.insert("Backspace"sv, Key::Backspace)); - TRY(s_name_to_key.insert("BackTick"sv, Key::BackTick)); - TRY(s_name_to_key.insert("BrokenBar"sv, Key::BrokenBar)); - TRY(s_name_to_key.insert("C"sv, Key::C)); - TRY(s_name_to_key.insert("Calculator"sv, Key::Calculator)); - TRY(s_name_to_key.insert("CapsLock"sv, Key::CapsLock)); - TRY(s_name_to_key.insert("Caret"sv, Key::Caret)); - TRY(s_name_to_key.insert("Cedilla"sv, Key::Cedilla)); - TRY(s_name_to_key.insert("CloseCurlyBracket"sv, Key::CloseCurlyBracket)); - TRY(s_name_to_key.insert("CloseParenthesis"sv, Key::CloseParenthesis)); - TRY(s_name_to_key.insert("CloseSquareBracket"sv, Key::CloseSquareBracket)); - TRY(s_name_to_key.insert("Colon"sv, Key::Colon)); - TRY(s_name_to_key.insert("Comma"sv, Key::Comma)); - TRY(s_name_to_key.insert("Currency"sv, Key::Currency)); - TRY(s_name_to_key.insert("D"sv, Key::D)); - TRY(s_name_to_key.insert("Delete"sv, Key::Delete)); - TRY(s_name_to_key.insert("Dollar"sv, Key::Dollar)); - TRY(s_name_to_key.insert("DoubleQuote"sv, Key::DoubleQuote)); - TRY(s_name_to_key.insert("E"sv, Key::E)); - TRY(s_name_to_key.insert("End"sv, Key::End)); - TRY(s_name_to_key.insert("Enter"sv, Key::Enter)); - TRY(s_name_to_key.insert("Equals"sv, Key::Equals)); - TRY(s_name_to_key.insert("Escape"sv, Key::Escape)); - TRY(s_name_to_key.insert("Euro"sv, Key::Euro)); - TRY(s_name_to_key.insert("Exclamation"sv, Key::ExclamationMark)); - TRY(s_name_to_key.insert("ExclamationMark"sv, Key::ExclamationMark)); - TRY(s_name_to_key.insert("F"sv, Key::F)); - TRY(s_name_to_key.insert("F1"sv, Key::F1)); - TRY(s_name_to_key.insert("F10"sv, Key::F10)); - TRY(s_name_to_key.insert("F11"sv, Key::F11)); - TRY(s_name_to_key.insert("F12"sv, Key::F12)); - TRY(s_name_to_key.insert("F2"sv, Key::F2)); - TRY(s_name_to_key.insert("F3"sv, Key::F3)); - TRY(s_name_to_key.insert("F4"sv, Key::F4)); - TRY(s_name_to_key.insert("F5"sv, Key::F5)); - TRY(s_name_to_key.insert("F6"sv, Key::F6)); - TRY(s_name_to_key.insert("F7"sv, Key::F7)); - TRY(s_name_to_key.insert("F8"sv, Key::F8)); - TRY(s_name_to_key.insert("F9"sv, Key::F9)); - TRY(s_name_to_key.insert("G"sv, Key::G)); - TRY(s_name_to_key.insert("GreaterThan"sv, Key::GreaterThan)); - TRY(s_name_to_key.insert("H"sv, Key::H)); - TRY(s_name_to_key.insert("Half"sv, Key::Half)); - TRY(s_name_to_key.insert("Hashtag"sv, Key::Hashtag)); - TRY(s_name_to_key.insert("Home"sv, Key::Home)); - TRY(s_name_to_key.insert("Hyphen"sv, Key::Hyphen)); - TRY(s_name_to_key.insert("I"sv, Key::I)); - TRY(s_name_to_key.insert("Insert"sv, Key::Insert)); - TRY(s_name_to_key.insert("J"sv, Key::J)); - TRY(s_name_to_key.insert("K"sv, Key::K)); - TRY(s_name_to_key.insert("Key0"sv, Key::_0)); - TRY(s_name_to_key.insert("Key1"sv, Key::_1)); - TRY(s_name_to_key.insert("Key2"sv, Key::_2)); - TRY(s_name_to_key.insert("Key3"sv, Key::_3)); - TRY(s_name_to_key.insert("Key4"sv, Key::_4)); - TRY(s_name_to_key.insert("Key5"sv, Key::_5)); - TRY(s_name_to_key.insert("Key6"sv, Key::_6)); - TRY(s_name_to_key.insert("Key7"sv, Key::_7)); - TRY(s_name_to_key.insert("Key8"sv, Key::_8)); - TRY(s_name_to_key.insert("Key9"sv, Key::_9)); - TRY(s_name_to_key.insert("L"sv, Key::L)); - TRY(s_name_to_key.insert("LAlt"sv, Key::LeftAlt)); - TRY(s_name_to_key.insert("LControl"sv, Key::LeftCtrl)); - TRY(s_name_to_key.insert("LeftAlt"sv, Key::LeftAlt)); - TRY(s_name_to_key.insert("LeftControl"sv, Key::LeftCtrl)); - TRY(s_name_to_key.insert("LeftShift"sv, Key::LeftShift)); - TRY(s_name_to_key.insert("LessThan"sv, Key::LessThan)); - TRY(s_name_to_key.insert("LShift"sv, Key::LeftShift)); - TRY(s_name_to_key.insert("M"sv, Key::M)); - TRY(s_name_to_key.insert("MediaNext"sv, Key::MediaNext)); - TRY(s_name_to_key.insert("MediaPlayPause"sv, Key::MediaPlayPause)); - TRY(s_name_to_key.insert("MediaPrevious"sv, Key::MediaPrevious)); - TRY(s_name_to_key.insert("MediaStop"sv, Key::MediaStop)); - TRY(s_name_to_key.insert("N"sv, Key::N)); - TRY(s_name_to_key.insert("Negation"sv, Key::Negation)); - TRY(s_name_to_key.insert("None"sv, Key::None)); - TRY(s_name_to_key.insert("NumLock"sv, Key::NumLock)); - TRY(s_name_to_key.insert("Numpad0"sv, Key::Numpad0)); - TRY(s_name_to_key.insert("Numpad1"sv, Key::Numpad1)); - TRY(s_name_to_key.insert("Numpad2"sv, Key::Numpad2)); - TRY(s_name_to_key.insert("Numpad3"sv, Key::Numpad3)); - TRY(s_name_to_key.insert("Numpad4"sv, Key::Numpad4)); - TRY(s_name_to_key.insert("Numpad5"sv, Key::Numpad5)); - TRY(s_name_to_key.insert("Numpad6"sv, Key::Numpad6)); - TRY(s_name_to_key.insert("Numpad7"sv, Key::Numpad7)); - TRY(s_name_to_key.insert("Numpad8"sv, Key::Numpad8)); - TRY(s_name_to_key.insert("Numpad9"sv, Key::Numpad9)); - TRY(s_name_to_key.insert("NumpadDecimal"sv, Key::NumpadDecimal)); - TRY(s_name_to_key.insert("NumpadDivide"sv, Key::NumpadDivide)); - TRY(s_name_to_key.insert("NumpadEnter"sv, Key::NumpadEnter)); - TRY(s_name_to_key.insert("NumpadMinus"sv, Key::NumpadMinus)); - TRY(s_name_to_key.insert("NumpadMultiply"sv, Key::NumpadMultiply)); - TRY(s_name_to_key.insert("NumpadPlus"sv, Key::NumpadPlus)); - TRY(s_name_to_key.insert("O_Umlaut"sv, Key::O_Umlaut)); - TRY(s_name_to_key.insert("O"sv, Key::O)); - TRY(s_name_to_key.insert("OpenCurlyBracket"sv, Key::OpenCurlyBracket)); - TRY(s_name_to_key.insert("OpenParenthesis"sv, Key::OpenParenthesis)); - TRY(s_name_to_key.insert("OpenSquareBracket"sv, Key::OpenSquareBracket)); - TRY(s_name_to_key.insert("P"sv, Key::P)); - TRY(s_name_to_key.insert("PageDown"sv, Key::PageDown)); - TRY(s_name_to_key.insert("PageUp"sv, Key::PageUp)); - TRY(s_name_to_key.insert("Percent"sv, Key::Percent)); - TRY(s_name_to_key.insert("Period"sv, Key::Period)); - TRY(s_name_to_key.insert("Pipe"sv, Key::Pipe)); - TRY(s_name_to_key.insert("Plus"sv, Key::Plus)); - TRY(s_name_to_key.insert("Pound"sv, Key::Pound)); - TRY(s_name_to_key.insert("PrintScreen"sv, Key::PrintScreen)); - TRY(s_name_to_key.insert("Q"sv, Key::Q)); - TRY(s_name_to_key.insert("Question"sv, Key::QuestionMark)); - TRY(s_name_to_key.insert("QuestionMark"sv, Key::QuestionMark)); - TRY(s_name_to_key.insert("R"sv, Key::R)); - TRY(s_name_to_key.insert("RAlt"sv, Key::RightAlt)); - TRY(s_name_to_key.insert("RControl"sv, Key::RightCtrl)); - TRY(s_name_to_key.insert("RightAlt"sv, Key::RightAlt)); - TRY(s_name_to_key.insert("RightControl"sv, Key::RightCtrl)); - TRY(s_name_to_key.insert("RightShift"sv, Key::RightShift)); - TRY(s_name_to_key.insert("RShift"sv, Key::RightShift)); - TRY(s_name_to_key.insert("S"sv, Key::S)); - TRY(s_name_to_key.insert("ScrollLock"sv, Key::ScrollLock)); - TRY(s_name_to_key.insert("Section"sv, Key::Section)); - TRY(s_name_to_key.insert("Semicolon"sv, Key::Semicolon)); - TRY(s_name_to_key.insert("SingleQuote"sv, Key::SingleQuote)); - TRY(s_name_to_key.insert("Slash"sv, Key::Slash)); - TRY(s_name_to_key.insert("Space"sv, Key::Space)); - TRY(s_name_to_key.insert("Super"sv, Key::Super)); - TRY(s_name_to_key.insert("T"sv, Key::T)); - TRY(s_name_to_key.insert("Tab"sv, Key::Tab)); - TRY(s_name_to_key.insert("Tilde"sv, Key::Tilde)); - TRY(s_name_to_key.insert("TwoDots"sv, Key::TwoDots)); - TRY(s_name_to_key.insert("U"sv, Key::U)); - TRY(s_name_to_key.insert("Underscore"sv, Key::Underscore)); - TRY(s_name_to_key.insert("V"sv, Key::V)); - TRY(s_name_to_key.insert("VolumeDown"sv, Key::VolumeDown)); - TRY(s_name_to_key.insert("VolumeMute"sv, Key::VolumeMute)); - TRY(s_name_to_key.insert("VolumeUp"sv, Key::VolumeUp)); - TRY(s_name_to_key.insert("W"sv, Key::W)); - TRY(s_name_to_key.insert("X"sv, Key::X)); - TRY(s_name_to_key.insert("Y"sv, Key::Y)); - TRY(s_name_to_key.insert("Z"sv, Key::Z)); + TRY(s_name_to_key.insert("A_Ring"_sv, Key::A_Ring)); + TRY(s_name_to_key.insert("A_Umlaut"_sv, Key::A_Umlaut)); + TRY(s_name_to_key.insert("A"_sv, Key::A)); + TRY(s_name_to_key.insert("Acute"_sv, Key::Acute)); + TRY(s_name_to_key.insert("AltGr"_sv, Key::AltGr)); + TRY(s_name_to_key.insert("Ampersand"_sv, Key::Ampersand)); + TRY(s_name_to_key.insert("ArrowDown"_sv, Key::ArrowDown)); + TRY(s_name_to_key.insert("ArrowLeft"_sv, Key::ArrowLeft)); + TRY(s_name_to_key.insert("ArrowRight"_sv, Key::ArrowRight)); + TRY(s_name_to_key.insert("ArrowUp"_sv, Key::ArrowUp)); + TRY(s_name_to_key.insert("Asterix"_sv, Key::Asterix)); + TRY(s_name_to_key.insert("AtSign"_sv, Key::AtSign)); + TRY(s_name_to_key.insert("B"_sv, Key::B)); + TRY(s_name_to_key.insert("BackSlash"_sv, Key::BackSlash)); + TRY(s_name_to_key.insert("Backspace"_sv, Key::Backspace)); + TRY(s_name_to_key.insert("BackTick"_sv, Key::BackTick)); + TRY(s_name_to_key.insert("BrokenBar"_sv, Key::BrokenBar)); + TRY(s_name_to_key.insert("C"_sv, Key::C)); + TRY(s_name_to_key.insert("Calculator"_sv, Key::Calculator)); + TRY(s_name_to_key.insert("CapsLock"_sv, Key::CapsLock)); + TRY(s_name_to_key.insert("Caret"_sv, Key::Caret)); + TRY(s_name_to_key.insert("Cedilla"_sv, Key::Cedilla)); + TRY(s_name_to_key.insert("CloseCurlyBracket"_sv, Key::CloseCurlyBracket)); + TRY(s_name_to_key.insert("CloseParenthesis"_sv, Key::CloseParenthesis)); + TRY(s_name_to_key.insert("CloseSquareBracket"_sv, Key::CloseSquareBracket)); + TRY(s_name_to_key.insert("Colon"_sv, Key::Colon)); + TRY(s_name_to_key.insert("Comma"_sv, Key::Comma)); + TRY(s_name_to_key.insert("Currency"_sv, Key::Currency)); + TRY(s_name_to_key.insert("D"_sv, Key::D)); + TRY(s_name_to_key.insert("Delete"_sv, Key::Delete)); + TRY(s_name_to_key.insert("Dollar"_sv, Key::Dollar)); + TRY(s_name_to_key.insert("DoubleQuote"_sv, Key::DoubleQuote)); + TRY(s_name_to_key.insert("E"_sv, Key::E)); + TRY(s_name_to_key.insert("End"_sv, Key::End)); + TRY(s_name_to_key.insert("Enter"_sv, Key::Enter)); + TRY(s_name_to_key.insert("Equals"_sv, Key::Equals)); + TRY(s_name_to_key.insert("Escape"_sv, Key::Escape)); + TRY(s_name_to_key.insert("Euro"_sv, Key::Euro)); + TRY(s_name_to_key.insert("Exclamation"_sv, Key::ExclamationMark)); + TRY(s_name_to_key.insert("ExclamationMark"_sv, Key::ExclamationMark)); + TRY(s_name_to_key.insert("F"_sv, Key::F)); + TRY(s_name_to_key.insert("F1"_sv, Key::F1)); + TRY(s_name_to_key.insert("F10"_sv, Key::F10)); + TRY(s_name_to_key.insert("F11"_sv, Key::F11)); + TRY(s_name_to_key.insert("F12"_sv, Key::F12)); + TRY(s_name_to_key.insert("F2"_sv, Key::F2)); + TRY(s_name_to_key.insert("F3"_sv, Key::F3)); + TRY(s_name_to_key.insert("F4"_sv, Key::F4)); + TRY(s_name_to_key.insert("F5"_sv, Key::F5)); + TRY(s_name_to_key.insert("F6"_sv, Key::F6)); + TRY(s_name_to_key.insert("F7"_sv, Key::F7)); + TRY(s_name_to_key.insert("F8"_sv, Key::F8)); + TRY(s_name_to_key.insert("F9"_sv, Key::F9)); + TRY(s_name_to_key.insert("G"_sv, Key::G)); + TRY(s_name_to_key.insert("GreaterThan"_sv, Key::GreaterThan)); + TRY(s_name_to_key.insert("H"_sv, Key::H)); + TRY(s_name_to_key.insert("Half"_sv, Key::Half)); + TRY(s_name_to_key.insert("Hashtag"_sv, Key::Hashtag)); + TRY(s_name_to_key.insert("Home"_sv, Key::Home)); + TRY(s_name_to_key.insert("Hyphen"_sv, Key::Hyphen)); + TRY(s_name_to_key.insert("I"_sv, Key::I)); + TRY(s_name_to_key.insert("Insert"_sv, Key::Insert)); + TRY(s_name_to_key.insert("J"_sv, Key::J)); + TRY(s_name_to_key.insert("K"_sv, Key::K)); + TRY(s_name_to_key.insert("Key0"_sv, Key::_0)); + TRY(s_name_to_key.insert("Key1"_sv, Key::_1)); + TRY(s_name_to_key.insert("Key2"_sv, Key::_2)); + TRY(s_name_to_key.insert("Key3"_sv, Key::_3)); + TRY(s_name_to_key.insert("Key4"_sv, Key::_4)); + TRY(s_name_to_key.insert("Key5"_sv, Key::_5)); + TRY(s_name_to_key.insert("Key6"_sv, Key::_6)); + TRY(s_name_to_key.insert("Key7"_sv, Key::_7)); + TRY(s_name_to_key.insert("Key8"_sv, Key::_8)); + TRY(s_name_to_key.insert("Key9"_sv, Key::_9)); + TRY(s_name_to_key.insert("L"_sv, Key::L)); + TRY(s_name_to_key.insert("LAlt"_sv, Key::LeftAlt)); + TRY(s_name_to_key.insert("LControl"_sv, Key::LeftCtrl)); + TRY(s_name_to_key.insert("LeftAlt"_sv, Key::LeftAlt)); + TRY(s_name_to_key.insert("LeftControl"_sv, Key::LeftCtrl)); + TRY(s_name_to_key.insert("LeftShift"_sv, Key::LeftShift)); + TRY(s_name_to_key.insert("LessThan"_sv, Key::LessThan)); + TRY(s_name_to_key.insert("LShift"_sv, Key::LeftShift)); + TRY(s_name_to_key.insert("M"_sv, Key::M)); + TRY(s_name_to_key.insert("MediaNext"_sv, Key::MediaNext)); + TRY(s_name_to_key.insert("MediaPlayPause"_sv, Key::MediaPlayPause)); + TRY(s_name_to_key.insert("MediaPrevious"_sv, Key::MediaPrevious)); + TRY(s_name_to_key.insert("MediaStop"_sv, Key::MediaStop)); + TRY(s_name_to_key.insert("N"_sv, Key::N)); + TRY(s_name_to_key.insert("Negation"_sv, Key::Negation)); + TRY(s_name_to_key.insert("None"_sv, Key::None)); + TRY(s_name_to_key.insert("NumLock"_sv, Key::NumLock)); + TRY(s_name_to_key.insert("Numpad0"_sv, Key::Numpad0)); + TRY(s_name_to_key.insert("Numpad1"_sv, Key::Numpad1)); + TRY(s_name_to_key.insert("Numpad2"_sv, Key::Numpad2)); + TRY(s_name_to_key.insert("Numpad3"_sv, Key::Numpad3)); + TRY(s_name_to_key.insert("Numpad4"_sv, Key::Numpad4)); + TRY(s_name_to_key.insert("Numpad5"_sv, Key::Numpad5)); + TRY(s_name_to_key.insert("Numpad6"_sv, Key::Numpad6)); + TRY(s_name_to_key.insert("Numpad7"_sv, Key::Numpad7)); + TRY(s_name_to_key.insert("Numpad8"_sv, Key::Numpad8)); + TRY(s_name_to_key.insert("Numpad9"_sv, Key::Numpad9)); + TRY(s_name_to_key.insert("NumpadDecimal"_sv, Key::NumpadDecimal)); + TRY(s_name_to_key.insert("NumpadDivide"_sv, Key::NumpadDivide)); + TRY(s_name_to_key.insert("NumpadEnter"_sv, Key::NumpadEnter)); + TRY(s_name_to_key.insert("NumpadMinus"_sv, Key::NumpadMinus)); + TRY(s_name_to_key.insert("NumpadMultiply"_sv, Key::NumpadMultiply)); + TRY(s_name_to_key.insert("NumpadPlus"_sv, Key::NumpadPlus)); + TRY(s_name_to_key.insert("O_Umlaut"_sv, Key::O_Umlaut)); + TRY(s_name_to_key.insert("O"_sv, Key::O)); + TRY(s_name_to_key.insert("OpenCurlyBracket"_sv, Key::OpenCurlyBracket)); + TRY(s_name_to_key.insert("OpenParenthesis"_sv, Key::OpenParenthesis)); + TRY(s_name_to_key.insert("OpenSquareBracket"_sv, Key::OpenSquareBracket)); + TRY(s_name_to_key.insert("P"_sv, Key::P)); + TRY(s_name_to_key.insert("PageDown"_sv, Key::PageDown)); + TRY(s_name_to_key.insert("PageUp"_sv, Key::PageUp)); + TRY(s_name_to_key.insert("Percent"_sv, Key::Percent)); + TRY(s_name_to_key.insert("Period"_sv, Key::Period)); + TRY(s_name_to_key.insert("Pipe"_sv, Key::Pipe)); + TRY(s_name_to_key.insert("Plus"_sv, Key::Plus)); + TRY(s_name_to_key.insert("Pound"_sv, Key::Pound)); + TRY(s_name_to_key.insert("PrintScreen"_sv, Key::PrintScreen)); + TRY(s_name_to_key.insert("Q"_sv, Key::Q)); + TRY(s_name_to_key.insert("Question"_sv, Key::QuestionMark)); + TRY(s_name_to_key.insert("QuestionMark"_sv, Key::QuestionMark)); + TRY(s_name_to_key.insert("R"_sv, Key::R)); + TRY(s_name_to_key.insert("RAlt"_sv, Key::RightAlt)); + TRY(s_name_to_key.insert("RControl"_sv, Key::RightCtrl)); + TRY(s_name_to_key.insert("RightAlt"_sv, Key::RightAlt)); + TRY(s_name_to_key.insert("RightControl"_sv, Key::RightCtrl)); + TRY(s_name_to_key.insert("RightShift"_sv, Key::RightShift)); + TRY(s_name_to_key.insert("RShift"_sv, Key::RightShift)); + TRY(s_name_to_key.insert("S"_sv, Key::S)); + TRY(s_name_to_key.insert("ScrollLock"_sv, Key::ScrollLock)); + TRY(s_name_to_key.insert("Section"_sv, Key::Section)); + TRY(s_name_to_key.insert("Semicolon"_sv, Key::Semicolon)); + TRY(s_name_to_key.insert("SingleQuote"_sv, Key::SingleQuote)); + TRY(s_name_to_key.insert("Slash"_sv, Key::Slash)); + TRY(s_name_to_key.insert("Space"_sv, Key::Space)); + TRY(s_name_to_key.insert("Super"_sv, Key::Super)); + TRY(s_name_to_key.insert("T"_sv, Key::T)); + TRY(s_name_to_key.insert("Tab"_sv, Key::Tab)); + TRY(s_name_to_key.insert("Tilde"_sv, Key::Tilde)); + TRY(s_name_to_key.insert("TwoDots"_sv, Key::TwoDots)); + TRY(s_name_to_key.insert("U"_sv, Key::U)); + TRY(s_name_to_key.insert("Underscore"_sv, Key::Underscore)); + TRY(s_name_to_key.insert("V"_sv, Key::V)); + TRY(s_name_to_key.insert("VolumeDown"_sv, Key::VolumeDown)); + TRY(s_name_to_key.insert("VolumeMute"_sv, Key::VolumeMute)); + TRY(s_name_to_key.insert("VolumeUp"_sv, Key::VolumeUp)); + TRY(s_name_to_key.insert("W"_sv, Key::W)); + TRY(s_name_to_key.insert("X"_sv, Key::X)); + TRY(s_name_to_key.insert("Y"_sv, Key::Y)); + TRY(s_name_to_key.insert("Z"_sv, Key::Z)); return {}; } #pragma GCC diagnostic pop diff --git a/userspace/libraries/LibInput/include/LibInput/KeyEvent.h b/userspace/libraries/LibInput/include/LibInput/KeyEvent.h index f71333468b..654e3a625d 100644 --- a/userspace/libraries/LibInput/include/LibInput/KeyEvent.h +++ b/userspace/libraries/LibInput/include/LibInput/KeyEvent.h @@ -11,7 +11,7 @@ namespace LibInput bits 7:5 row (from top) */ - #define BANAN_CONSTEVAL_STATIC_ASSERT(cond) do { int dummy = 1 / (cond); } while (false) + #define BANAN_CONSTEVAL_STATIC_ASSERT(cond) do { int dummy = 1 / (cond); (void)dummy; } while (false) consteval uint8_t keycode_function(uint8_t index) { diff --git a/userspace/ls/main.cpp b/userspace/ls/main.cpp index 8398a06aa7..0a743bf2a1 100644 --- a/userspace/ls/main.cpp +++ b/userspace/ls/main.cpp @@ -297,7 +297,7 @@ int main(int argc, const char* argv[]) BAN::Vector files; if (i == argc) - MUST(files.emplace_back("."sv)); + MUST(files.emplace_back("."_sv)); else for (; i < argc; i++) MUST(files.emplace_back(BAN::StringView(argv[i]))); diff --git a/userspace/resolver/main.cpp b/userspace/resolver/main.cpp index ac4bfb7290..ff97962cd1 100644 --- a/userspace/resolver/main.cpp +++ b/userspace/resolver/main.cpp @@ -212,6 +212,9 @@ int main(int, char**) struct Client { + Client(int socket) + : socket(socket) + { } const int socket; bool close { false }; uint16_t query_id { 0 }; diff --git a/userspace/stat/main.cpp b/userspace/stat/main.cpp index ce6c40ba34..c089da1984 100644 --- a/userspace/stat/main.cpp +++ b/userspace/stat/main.cpp @@ -66,7 +66,7 @@ int main(int argc, char** argv) printf(" File: %s\n", argv[i]); printf(" Size: %-15ld Blocks: %-10ld IO Block: %-6ld %s\n", st.st_size, st.st_blocks, st.st_blksize, type); - printf("Device: %lu,%-5lu Inode: %-11llu Links: %-5lu Device type: %lu,%lu\n", major(st.st_dev), minor(st.st_dev), st.st_ino, st.st_nlink, major(st.st_rdev), minor(st.st_rdev)); + printf("Device: %u,%-5u Inode: %-11llu Links: %-5lu Device type: %u,%u\n", major(st.st_dev), minor(st.st_dev), st.st_ino, st.st_nlink, major(st.st_rdev), minor(st.st_rdev)); printf("Access: (%04o/%s) Uid: %5d Gid: %5d\n", st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX), access, st.st_uid, st.st_gid); printf("Access: "); print_timestamp(st.st_atim); printf("\n"); printf("Modify: "); print_timestamp(st.st_mtim); printf("\n");