All: Fix a lot of compiler warnings from header files

While reworking build system, header files started to report warnings.
This commit is contained in:
Bananymous 2024-06-18 20:32:43 +03:00
parent 526d4369ce
commit 318ce5dec8
59 changed files with 339 additions and 326 deletions

View File

@ -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 namespace BAN::Formatter
{ {

View File

@ -66,6 +66,7 @@ set(KERNEL_SOURCES
kernel/Networking/E1000/E1000E.cpp kernel/Networking/E1000/E1000E.cpp
kernel/Networking/IPv4Layer.cpp kernel/Networking/IPv4Layer.cpp
kernel/Networking/NetworkInterface.cpp kernel/Networking/NetworkInterface.cpp
kernel/Networking/NetworkLayer.cpp
kernel/Networking/NetworkManager.cpp kernel/Networking/NetworkManager.cpp
kernel/Networking/NetworkSocket.cpp kernel/Networking/NetworkSocket.cpp
kernel/Networking/TCPSocket.cpp kernel/Networking/TCPSocket.cpp

View File

@ -48,7 +48,7 @@ namespace Kernel::ACPI::AML
AML_ERROR("IndexOp index is out of buffer bounds"); AML_ERROR("IndexOp index is out of buffer bounds");
return ParseResult::Failure; return ParseResult::Failure;
} }
auto buffer_field = MUST(BAN::RefPtr<BufferField>::create(NameSeg(""sv), buffer, index.value() * 8, 8)); auto buffer_field = MUST(BAN::RefPtr<BufferField>::create(NameSeg(""_sv), buffer, index.value() * 8, 8));
result = MUST(BAN::RefPtr<AML::Reference>::create(buffer_field)); result = MUST(BAN::RefPtr<AML::Reference>::create(buffer_field));
break; break;
} }

View File

@ -21,8 +21,8 @@ namespace Kernel::ACPI::AML
static BAN::RefPtr<Integer> Ones; static BAN::RefPtr<Integer> Ones;
}; };
const bool constant;
uint64_t value; uint64_t value;
const bool constant;
Integer(uint64_t value, bool constant = false) Integer(uint64_t value, bool constant = false)
: Node(Node::Type::Integer) : Node(Node::Type::Integer)

View File

@ -45,7 +45,7 @@ namespace Kernel::ACPI::AML
[[nodiscard]] BAN::Optional<uint64_t> as_integer(); [[nodiscard]] BAN::Optional<uint64_t> as_integer();
[[nodiscard]] virtual BAN::RefPtr<AML::Node> evaluate() { AML_TODO("evaluate, type {}", static_cast<uint8_t>(type)); return nullptr; } [[nodiscard]] virtual BAN::RefPtr<AML::Node> evaluate() { AML_TODO("evaluate, type {}", static_cast<uint8_t>(type)); return nullptr; }
[[nodiscard]] virtual bool store(BAN::RefPtr<AML::Node> source) { AML_TODO("store, type {}", static_cast<uint8_t>(type)); return false; } [[nodiscard]] virtual bool store(BAN::RefPtr<AML::Node>) { AML_TODO("store, type {}", static_cast<uint8_t>(type)); return false; }
virtual void debug_print(int indent) const = 0; virtual void debug_print(int indent) const = 0;
}; };

View File

@ -41,20 +41,20 @@ namespace Kernel::ACPI::AML
switch (object->type) switch (object->type)
{ {
case AML::Node::Type::Device: case AML::Node::Type::Device:
object_type_sv = "Device"sv; object_type_sv = "Device"_sv;
object_name_sv = static_cast<AML::Device*>(object.ptr())->name.sv(); object_name_sv = static_cast<AML::Device*>(object.ptr())->name.sv();
break; break;
case AML::Node::Type::Processor: case AML::Node::Type::Processor:
object_type_sv = "Processor"sv; object_type_sv = "Processor"_sv;
object_name_sv = static_cast<AML::Processor*>(object.ptr())->name.sv(); object_name_sv = static_cast<AML::Processor*>(object.ptr())->name.sv();
break; break;
case AML::Node::Type::ThermalZone: case AML::Node::Type::ThermalZone:
object_type_sv = "ThermalZone"sv; object_type_sv = "ThermalZone"_sv;
object_name_sv = static_cast<AML::ThermalZone*>(object.ptr())->name.sv(); object_name_sv = static_cast<AML::ThermalZone*>(object.ptr())->name.sv();
break; break;
default: default:
object_type_sv = "Unknown"sv; object_type_sv = "Unknown"_sv;
object_name_sv = "????"sv; object_name_sv = "????"_sv;
break; break;
} }

View File

@ -60,7 +60,6 @@ namespace Kernel::ACPI::AML
PackageElement(BAN::RefPtr<AML::Package> parent) PackageElement(BAN::RefPtr<AML::Package> parent)
: Node(Node::Type::PackageElement) : Node(Node::Type::PackageElement)
, parent(parent) , parent(parent)
, unresolved_name(unresolved_name)
{ {
resolved = false; resolved = false;
initialized = false; initialized = false;

View File

@ -82,18 +82,18 @@ namespace Kernel::ACPI::AML
BAN::StringView region_space_name; BAN::StringView region_space_name;
switch (region_space) switch (region_space)
{ {
case RegionSpace::SystemMemory: region_space_name = "SystemMemory"sv; break; case RegionSpace::SystemMemory: region_space_name = "SystemMemory"_sv; break;
case RegionSpace::SystemIO: region_space_name = "SystemIO"sv; break; case RegionSpace::SystemIO: region_space_name = "SystemIO"_sv; break;
case RegionSpace::PCIConfig: region_space_name = "PCIConfig"sv; break; case RegionSpace::PCIConfig: region_space_name = "PCIConfig"_sv; break;
case RegionSpace::EmbeddedController: region_space_name = "EmbeddedController"sv; break; case RegionSpace::EmbeddedController: region_space_name = "EmbeddedController"_sv; break;
case RegionSpace::SMBus: region_space_name = "SMBus"sv; break; case RegionSpace::SMBus: region_space_name = "SMBus"_sv; break;
case RegionSpace::SystemCMOS: region_space_name = "SystemCMOS"sv; break; case RegionSpace::SystemCMOS: region_space_name = "SystemCMOS"_sv; break;
case RegionSpace::PCIBarTarget: region_space_name = "PCIBarTarget"sv; break; case RegionSpace::PCIBarTarget: region_space_name = "PCIBarTarget"_sv; break;
case RegionSpace::IPMI: region_space_name = "IPMI"sv; break; case RegionSpace::IPMI: region_space_name = "IPMI"_sv; break;
case RegionSpace::GeneralPurposeIO: region_space_name = "GeneralPurposeIO"sv; break; case RegionSpace::GeneralPurposeIO: region_space_name = "GeneralPurposeIO"_sv; break;
case RegionSpace::GenericSerialBus: region_space_name = "GenericSerialBus"sv; break; case RegionSpace::GenericSerialBus: region_space_name = "GenericSerialBus"_sv; break;
case RegionSpace::PlatformCommunicationChannel: region_space_name = "PlatformCommunicationChannel"sv; break; case RegionSpace::PlatformCommunicationChannel: region_space_name = "PlatformCommunicationChannel"_sv; break;
default: region_space_name = "Unknown"sv; break; default: region_space_name = "Unknown"_sv; break;
} }
AML_DEBUG_PRINT_INDENT(indent); AML_DEBUG_PRINT_INDENT(indent);
AML_DEBUG_PRINT("OperationRegion("); AML_DEBUG_PRINT("OperationRegion(");

View File

@ -10,7 +10,7 @@ namespace Kernel
virtual dev_t rdev() const override { return m_rdev; } 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: protected:
DebugDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) DebugDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev)

View File

@ -16,7 +16,7 @@ namespace Kernel
virtual bool is_partition() const { return false; } virtual bool is_partition() const { return false; }
virtual bool is_storage_device() const { return false; } virtual bool is_storage_device() const { return false; }
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t) { return BAN::Error::from_errno(EINVAL); } virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> 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; virtual dev_t rdev() const override = 0;

View File

@ -12,7 +12,7 @@ namespace Kernel
virtual dev_t rdev() const override { return m_rdev; } 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: protected:
NullDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) NullDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev)

View File

@ -10,7 +10,7 @@ namespace Kernel
virtual dev_t rdev() const override { return m_rdev; } 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: protected:
ZeroDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev) ZeroDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev)

View File

@ -53,12 +53,12 @@ namespace Kernel
uint32_t first_fat_sector() const { return m_bpb.reserved_sector_count; } uint32_t first_fat_sector() const { return m_bpb.reserved_sector_count; }
private: private:
const FAT::BPB m_bpb;
const Type m_type;
BAN::RefPtr<BlockDevice> m_block_device; BAN::RefPtr<BlockDevice> m_block_device;
BAN::RefPtr<FATInode> m_root_inode; BAN::RefPtr<FATInode> m_root_inode;
const FAT::BPB m_bpb;
const Type m_type;
BAN::HashMap<ino_t, BAN::WeakPtr<FATInode>> m_inode_cache; BAN::HashMap<ino_t, BAN::WeakPtr<FATInode>> m_inode_cache;
BAN::Vector<uint8_t> m_fat_two_sector_buffer; BAN::Vector<uint8_t> m_fat_two_sector_buffer;

View File

@ -155,7 +155,7 @@ namespace Kernel
virtual bool can_write_impl() const = 0; virtual bool can_write_impl() const = 0;
virtual bool has_error_impl() const = 0; virtual bool has_error_impl() const = 0;
virtual BAN::ErrorOr<long> ioctl_impl(int request, void* arg) { return BAN::Error::from_errno(ENOTSUP); } virtual BAN::ErrorOr<long> ioctl_impl(int, void*) { return BAN::Error::from_errno(ENOTSUP); }
protected: protected:
mutable PriorityMutex m_mutex; mutable PriorityMutex m_mutex;

View File

@ -14,9 +14,9 @@ namespace Kernel
mode_t mode { 0 }; mode_t mode { 0 };
uid_t uid { 0 }; uid_t uid { 0 };
gid_t gid { 0 }; gid_t gid { 0 };
timespec atime { 0 }; timespec atime { 0, 0 };
timespec ctime { 0 }; timespec ctime { 0, 0 };
timespec mtime { 0 }; timespec mtime { 0, 0 };
nlink_t nlink { 0 }; nlink_t nlink { 0 };
size_t size { 0 }; size_t size { 0 };
blkcnt_t blocks { 0 }; blkcnt_t blocks { 0 };

View File

@ -154,7 +154,7 @@ namespace Kernel
#endif #endif
TaskStateSegment m_tss; TaskStateSegment m_tss;
const GDTR m_gdtr { const GDTR m_gdtr {
.size = m_gdt.size() * sizeof(SegmentDescriptor) - 1, .size = static_cast<uint16_t>(m_gdt.size() * sizeof(SegmentDescriptor) - 1),
.address = reinterpret_cast<uintptr_t>(m_gdt.data()) .address = reinterpret_cast<uintptr_t>(m_gdt.data())
}; };
}; };

View File

@ -72,8 +72,8 @@ namespace Kernel
private: private:
BAN::Array<GateDescriptor, 0x100> m_idt; BAN::Array<GateDescriptor, 0x100> m_idt;
IDTR m_idtr { IDTR m_idtr {
.size = m_idt.size() * sizeof(GateDescriptor) - 1, .size = static_cast<uint16_t>(m_idt.size() * sizeof(GateDescriptor) - 1),
.offset = reinterpret_cast<uint64_t>(m_idt.data()) .offset = reinterpret_cast<uintptr_t>(m_idt.data())
}; };
}; };

View File

@ -19,7 +19,7 @@ namespace Kernel::Input
static BAN::ErrorOr<PS2Mouse*> create(PS2Controller&); static BAN::ErrorOr<PS2Mouse*> create(PS2Controller&);
virtual void send_initialize() override; 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; virtual void handle_byte(uint8_t) final override;

View File

@ -14,7 +14,7 @@ namespace Kernel
protected: protected:
Interruptable() = default; Interruptable() = default;
~Interruptable() {} virtual ~Interruptable() {}
private: private:
int m_irq { -1 }; int m_irq { -1 };

View File

@ -35,18 +35,6 @@ namespace Kernel
NetworkLayer() = default; NetworkLayer() = default;
}; };
static uint16_t calculate_internet_checksum(BAN::ConstByteSpan packet, const PseudoHeader& pseudo_header) 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<const uint16_t*>(&pseudo_header)[i]);
for (size_t i = 0; i < packet.size() / sizeof(uint16_t); i++)
checksum += BAN::host_to_network_endian(reinterpret_cast<const uint16_t*>(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;
}
} }

View File

@ -38,7 +38,7 @@ namespace Kernel
BAN::ErrorOr<void> add_packet(BAN::ConstByteSpan); BAN::ErrorOr<void> add_packet(BAN::ConstByteSpan);
bool is_bound() const { return !m_bound_path.empty(); } 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; bool is_streaming() const;

View File

@ -25,6 +25,7 @@ namespace Kernel
Debug::dump_stack_trace(); Debug::dump_stack_trace();
} }
asm volatile("ud2"); asm volatile("ud2");
__builtin_unreachable();
} }
} }

View File

@ -132,7 +132,7 @@ acpi_release_global_lock:
if (!access_type.has_value()) if (!access_type.has_value())
return {}; return {};
auto op_region = MUST(BAN::RefPtr<AML::OpRegion>::create(""sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); auto op_region = MUST(BAN::RefPtr<AML::OpRegion>::create(""_sv, address_space_id, (uint64_t)address, 0xFFFFFFFF));
auto field_rules = AML::FieldRules { auto field_rules = AML::FieldRules {
.access_type = access_type.value(), .access_type = access_type.value(),
@ -141,7 +141,7 @@ acpi_release_global_lock:
.access_attrib = AML::FieldRules::AccessAttrib::Normal, .access_attrib = AML::FieldRules::AccessAttrib::Normal,
.access_length = 0 .access_length = 0
}; };
auto field_element = MUST(BAN::RefPtr<AML::FieldElement>::create(""sv, register_bit_offset, register_bit_width, field_rules)); auto field_element = MUST(BAN::RefPtr<AML::FieldElement>::create(""_sv, register_bit_offset, register_bit_width, field_rules));
field_element->op_region = op_region; field_element->op_region = op_region;
auto result = field_element->as_integer(); auto result = field_element->as_integer();
@ -156,7 +156,7 @@ acpi_release_global_lock:
if (!access_type.has_value()) if (!access_type.has_value())
return {}; return {};
auto op_region = MUST(BAN::RefPtr<AML::OpRegion>::create(""sv, address_space_id, (uint64_t)address, 0xFFFFFFFF)); auto op_region = MUST(BAN::RefPtr<AML::OpRegion>::create(""_sv, address_space_id, (uint64_t)address, 0xFFFFFFFF));
auto field_rules = AML::FieldRules { auto field_rules = AML::FieldRules {
.access_type = access_type.value(), .access_type = access_type.value(),
@ -165,7 +165,7 @@ acpi_release_global_lock:
.access_attrib = AML::FieldRules::AccessAttrib::Normal, .access_attrib = AML::FieldRules::AccessAttrib::Normal,
.access_length = 0 .access_length = 0
}; };
auto field_element = MUST(BAN::RefPtr<AML::FieldElement>::create(""sv, register_bit_offset, register_bit_width, field_rules)); auto field_element = MUST(BAN::RefPtr<AML::FieldElement>::create(""_sv, register_bit_offset, register_bit_width, field_rules));
field_element->op_region = op_region; field_element->op_region = op_region;
return field_element->store(MUST(BAN::RefPtr<AML::Integer>::create(value))); return field_element->store(MUST(BAN::RefPtr<AML::Integer>::create(value)));
@ -214,7 +214,7 @@ acpi_release_global_lock:
{ {
ASSERT(!s_global_lock); ASSERT(!s_global_lock);
const auto* fadt = static_cast<const FADT*>(ACPI::get().get_header("FACP"sv, 0)); const auto* fadt = static_cast<const FADT*>(ACPI::get().get_header("FACP"_sv, 0));
ASSERT(fadt); ASSERT(fadt);
uintptr_t facs_addr = fadt->firmware_ctrl; uintptr_t facs_addr = fadt->firmware_ctrl;
@ -679,7 +679,7 @@ acpi_release_global_lock:
return; return;
auto name = path.sv().substring(path.size() - 4); 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; return;
auto index = hex_sv_to_int(name.substring(2)); auto index = hex_sv_to_int(name.substring(2));

View File

@ -41,7 +41,7 @@ namespace Kernel::ACPI
LockGuard _(m_object_mutex); LockGuard _(m_object_mutex);
// Base must be non-empty absolute path // 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 // Do absolute path lookup
if (!relative_path.prefix.empty() || relative_path.path.size() != 1 || mode == FindMode::ForceAbsolute) 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('\\')); MUST(absolute_path.push_back('\\'));
// Resolve root and parent references // Resolve root and parent references
if (relative_path.prefix == "\\"sv) if (relative_path.prefix == "\\"_sv)
; ;
else else
{ {
@ -76,7 +76,7 @@ namespace Kernel::ACPI
if (absolute_path.back() == '.') if (absolute_path.back() == '.')
absolute_path.pop_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 absolute_path;
return {}; return {};
} }
@ -125,7 +125,7 @@ namespace Kernel::ACPI
if (!canonical_path.has_value()) if (!canonical_path.has_value())
return nullptr; return nullptr;
if (canonical_path->sv() == "\\"sv) if (canonical_path->sv() == "\\"_sv)
return this; return this;
auto it = m_objects.find(canonical_path.value()); auto it = m_objects.find(canonical_path.value());
@ -191,28 +191,28 @@ namespace Kernel::ACPI
BAN::RefPtr<AML::Namespace> AML::Namespace::create_root_namespace() BAN::RefPtr<AML::Namespace> AML::Namespace::create_root_namespace()
{ {
ASSERT(!s_root_namespace); ASSERT(!s_root_namespace);
s_root_namespace = MUST(BAN::RefPtr<Namespace>::create(NameSeg("\\"sv))); s_root_namespace = MUST(BAN::RefPtr<Namespace>::create(NameSeg("\\"_sv)));
s_root_namespace->scope = AML::NameString("\\"sv); s_root_namespace->scope = AML::NameString("\\"_sv);
Integer::Constants::Zero = MUST(BAN::RefPtr<Integer>::create(0, true)); Integer::Constants::Zero = MUST(BAN::RefPtr<Integer>::create(0, true));
Integer::Constants::One = MUST(BAN::RefPtr<Integer>::create(1, true)); Integer::Constants::One = MUST(BAN::RefPtr<Integer>::create(1, true));
Integer::Constants::Ones = MUST(BAN::RefPtr<Integer>::create(0xFFFFFFFFFFFFFFFF, true)); Integer::Constants::Ones = MUST(BAN::RefPtr<Integer>::create(0xFFFFFFFFFFFFFFFF, true));
AML::ParseContext context; AML::ParseContext context;
context.scope = AML::NameString("\\"sv); context.scope = AML::NameString("\\"_sv);
// Add predefined namespaces // Add predefined namespaces
#define ADD_PREDEFIED_NAMESPACE(NAME) \ #define ADD_PREDEFIED_NAMESPACE(NAME) \
ASSERT(s_root_namespace->add_named_object(context, AML::NameString("\\" NAME), MUST(BAN::RefPtr<AML::Device>::create(NameSeg(NAME))))); ASSERT(s_root_namespace->add_named_object(context, AML::NameString("\\" NAME), MUST(BAN::RefPtr<AML::Device>::create(NameSeg(NAME)))));
ADD_PREDEFIED_NAMESPACE("_GPE"sv); ADD_PREDEFIED_NAMESPACE("_GPE"_sv);
ADD_PREDEFIED_NAMESPACE("_PR"sv); ADD_PREDEFIED_NAMESPACE("_PR"_sv);
ADD_PREDEFIED_NAMESPACE("_SB"sv); ADD_PREDEFIED_NAMESPACE("_SB"_sv);
ADD_PREDEFIED_NAMESPACE("_SI"sv); ADD_PREDEFIED_NAMESPACE("_SI"_sv);
ADD_PREDEFIED_NAMESPACE("_TZ"sv); ADD_PREDEFIED_NAMESPACE("_TZ"_sv);
#undef ADD_PREDEFIED_NAMESPACE #undef ADD_PREDEFIED_NAMESPACE
// Add \_OSI that returns true for Linux compatibility // Add \_OSI that returns true for Linux compatibility
auto osi = MUST(BAN::RefPtr<AML::Method>::create(NameSeg("_OSI"sv), 1, false, 0)); auto osi = MUST(BAN::RefPtr<AML::Method>::create(NameSeg("_OSI"_sv), 1, false, 0));
osi->override_function = [](AML::ParseContext& context) -> BAN::RefPtr<AML::Node> { osi->override_function = [](AML::ParseContext& context) -> BAN::RefPtr<AML::Node> {
ASSERT(context.method_args[0]); ASSERT(context.method_args[0]);
auto arg = context.method_args[0]->evaluate(); auto arg = context.method_args[0]->evaluate();
@ -234,7 +234,7 @@ namespace Kernel::ACPI
ASSERT(this == s_root_namespace.ptr()); ASSERT(this == s_root_namespace.ptr());
AML::ParseContext context; AML::ParseContext context;
context.scope = AML::NameString("\\"sv); context.scope = AML::NameString("\\"_sv);
context.aml_data = BAN::ConstByteSpan(reinterpret_cast<const uint8_t*>(&header), header.length).slice(sizeof(header)); context.aml_data = BAN::ConstByteSpan(reinterpret_cast<const uint8_t*>(&header), header.length).slice(sizeof(header));
while (context.aml_data.size() > 0) while (context.aml_data.size() > 0)

View File

@ -94,7 +94,7 @@ namespace Kernel::ACPI
AML_DEBUG_PRINTLN("Initializing {}", scope->scope); AML_DEBUG_PRINTLN("Initializing {}", scope->scope);
#endif #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; bool embedded_controller = false;
Namespace::for_each_child(scope->scope, Namespace::for_each_child(scope->scope,
@ -135,7 +135,7 @@ namespace Kernel::ACPI
bool run_ini = true; bool run_ini = true;
bool init_children = 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); auto result = evaluate_or_invoke(sta);
if (!result.has_value()) if (!result.has_value())
@ -150,7 +150,7 @@ namespace Kernel::ACPI
if (run_ini) 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)
{ {
if (ini->type != AML::Node::Type::Method) if (ini->type != AML::Node::Type::Method)

View File

@ -132,7 +132,7 @@ namespace Kernel
return nullptr; 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) if (madt == nullptr)
{ {
dprintln("Could not find MADT header"); dprintln("Could not find MADT header");

View File

@ -21,7 +21,7 @@ namespace Kernel
BAN::ErrorOr<BAN::String> Credentials::find_username() const BAN::ErrorOr<BAN::String> 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; BAN::String line;
off_t offset = 0; off_t offset = 0;

View File

@ -436,8 +436,8 @@ done:
auto inode = inode_or_error.release_value(); auto inode = inode_or_error.release_value();
BAN::ScopeGuard cleanup([&] { inode->cleanup_from_fs(); }); BAN::ScopeGuard cleanup([&] { inode->cleanup_from_fs(); });
TRY(inode->link_inode_to_directory(*inode, "."sv)); TRY(inode->link_inode_to_directory(*inode, "."_sv));
TRY(inode->link_inode_to_directory(*this, ".."sv)); TRY(inode->link_inode_to_directory(*this, ".."_sv));
TRY(link_inode_to_directory(*inode, name)); TRY(link_inode_to_directory(*inode, name));
@ -569,7 +569,7 @@ needs_new_block:
if (entry.inode) if (entry.inode)
{ {
BAN::StringView entry_name(entry.name, entry.name_len); 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; return false;
} }
@ -608,12 +608,12 @@ needs_new_block:
{ {
BAN::StringView entry_name(entry.name, entry.name_len); BAN::StringView entry_name(entry.name, entry.name_len);
if (entry_name == "."sv) if (entry_name == "."_sv)
{ {
m_inode.links_count--; m_inode.links_count--;
sync(); sync();
} }
else if (entry_name == ".."sv) else if (entry_name == ".."_sv)
{ {
auto parent = TRY(Ext2Inode::create(m_fs, entry.inode)); auto parent = TRY(Ext2Inode::create(m_fs, entry.inode));
parent->m_inode.links_count--; parent->m_inode.links_count--;

View File

@ -212,9 +212,10 @@ namespace Kernel
return valid_entry_count; return valid_entry_count;
} }
BAN::ErrorOr<size_t> FATInode::read_impl(off_t offset, BAN::ByteSpan buffer) BAN::ErrorOr<size_t> 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) if (offset >= m_entry.file_size)
return 0; return 0;

View File

@ -103,7 +103,7 @@ namespace Kernel
LockGuard _(m_mutex); LockGuard _(m_mutex);
if (!mode().ifdir()) if (!mode().ifdir())
return BAN::Error::from_errno(ENOTDIR); return BAN::Error::from_errno(ENOTDIR);
if (name == "."sv || name == ".."sv) if (name == "."_sv || name == ".."_sv)
return BAN::Error::from_errno(EINVAL); return BAN::Error::from_errno(EINVAL);
return unlink_impl(name); return unlink_impl(name);
} }

View File

@ -12,9 +12,9 @@ namespace Kernel
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
auto inode = BAN::RefPtr<ProcPidInode>::adopt(inode_ptr); auto inode = BAN::RefPtr<ProcPidInode>::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_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_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_environ, fs, 0400, uid, gid)), "environ"_sv));
return inode; return inode;
} }
@ -27,9 +27,9 @@ namespace Kernel
void ProcPidInode::cleanup() void ProcPidInode::cleanup()
{ {
(void)TmpDirectoryInode::unlink_impl("meminfo"sv); (void)TmpDirectoryInode::unlink_impl("meminfo"_sv);
(void)TmpDirectoryInode::unlink_impl("cmdline"sv); (void)TmpDirectoryInode::unlink_impl("cmdline"_sv);
(void)TmpDirectoryInode::unlink_impl("environ"sv); (void)TmpDirectoryInode::unlink_impl("environ"_sv);
} }
BAN::ErrorOr<BAN::RefPtr<ProcROInode>> 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) BAN::ErrorOr<BAN::RefPtr<ProcROInode>> 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)

View File

@ -342,8 +342,8 @@ namespace Kernel
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
auto inode = BAN::RefPtr<TmpDirectoryInode>::adopt(inode_ptr); auto inode = BAN::RefPtr<TmpDirectoryInode>::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; return inode;
} }
@ -358,8 +358,8 @@ namespace Kernel
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
auto inode = BAN::RefPtr<TmpDirectoryInode>::adopt(inode_ptr); auto inode = BAN::RefPtr<TmpDirectoryInode>::adopt(inode_ptr);
TRY(inode->link_inode(*inode, "."sv)); TRY(inode->link_inode(*inode, "."_sv));
TRY(inode->link_inode(parent, ".."sv)); TRY(inode->link_inode(parent, ".."_sv));
return inode; return inode;
} }
@ -381,9 +381,9 @@ namespace Kernel
bool is_empty = true; bool is_empty = true;
for_each_valid_entry([&](TmpDirectoryEntry& entry) { for_each_valid_entry([&](TmpDirectoryEntry& entry) {
if (entry.name_sv() == "."sv) if (entry.name_sv() == "."_sv)
dot_ino = entry.ino; dot_ino = entry.ino;
else if (entry.name_sv() == ".."sv) else if (entry.name_sv() == ".."_sv)
dotdot_ino = entry.ino; dotdot_ino = entry.ino;
else else
{ {

View File

@ -17,7 +17,7 @@ namespace Kernel
ASSERT(!s_instance); ASSERT(!s_instance);
s_instance = MUST(BAN::RefPtr<VirtualFileSystem>::create()); s_instance = MUST(BAN::RefPtr<VirtualFileSystem>::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); root_path = root_path.substring(5);
auto root_inode = MUST(DevFileSystem::get().root_inode()->find_inode(root_path)); 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<BlockDevice*>(root_inode.ptr()))); s_instance->m_root_fs = MUST(FileSystem::from_block_device(static_cast<BlockDevice*>(root_inode.ptr())));
Credentials root_creds { 0, 0, 0, 0 }; 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)); 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() VirtualFileSystem& VirtualFileSystem::get()
@ -109,16 +109,16 @@ namespace Kernel
const auto& path_part = path_parts.back(); const auto& path_part = path_parts.back();
auto orig = inode; 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)) 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 else
inode = TRY(inode->find_inode(".."sv)); inode = TRY(inode->find_inode(".."_sv));
if (!canonical_path.empty()) if (!canonical_path.empty())
{ {

View File

@ -244,7 +244,7 @@ namespace Kernel::Input
// FIXME: Initialise USB Controllers // FIXME: Initialise USB Controllers
// Determine if the PS/2 Controller Exists // Determine if the PS/2 Controller Exists
auto* fadt = static_cast<const ACPI::FADT*>(ACPI::ACPI::get().get_header("FACP"sv, 0)); auto* fadt = static_cast<const ACPI::FADT*>(ACPI::ACPI::get().get_header("FACP"_sv, 0));
if (fadt && fadt->revision > 1 && !(fadt->iapc_boot_arch & (1 << 1))) if (fadt && fadt->revision > 1 && !(fadt->iapc_boot_arch & (1 << 1)))
{ {
dwarnln_if(DEBUG_PS2, "No PS/2 available"); dwarnln_if(DEBUG_PS2, "No PS/2 available");

View File

@ -0,0 +1,20 @@
#include <kernel/Networking/NetworkLayer.h>
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<const uint16_t*>(&pseudo_header)[i]);
for (size_t i = 0; i < packet.size() / sizeof(uint16_t); i++)
checksum += BAN::host_to_network_endian(reinterpret_cast<const uint16_t*>(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;
}
}

View File

@ -65,7 +65,7 @@ namespace Kernel
int fd = TRY(get_free_fd()); int fd = TRY(get_free_fd());
// FIXME: path? // FIXME: path?
m_open_files[fd] = TRY(BAN::RefPtr<OpenFileDescription>::create(inode, ""sv, 0, flags)); m_open_files[fd] = TRY(BAN::RefPtr<OpenFileDescription>::create(inode, ""_sv, 0, flags));
return fd; 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())); auto socket = TRY(NetworkManager::get().create_socket(sock_domain, sock_type, 0777, m_credentials.euid(), m_credentials.egid()));
int fd = TRY(get_free_fd()); int fd = TRY(get_free_fd());
m_open_files[fd] = TRY(BAN::RefPtr<OpenFileDescription>::create(socket, "no-path"sv, 0, O_RDWR)); m_open_files[fd] = TRY(BAN::RefPtr<OpenFileDescription>::create(socket, "no-path"_sv, 0, O_RDWR));
return fd; return fd;
} }
@ -150,8 +150,8 @@ namespace Kernel
TRY(get_free_fd_pair(fds)); TRY(get_free_fd_pair(fds));
auto pipe = TRY(Pipe::create(m_credentials)); auto pipe = TRY(Pipe::create(m_credentials));
m_open_files[fds[0]] = TRY(BAN::RefPtr<OpenFileDescription>::create(pipe, ""sv, 0, O_RDONLY)); m_open_files[fds[0]] = TRY(BAN::RefPtr<OpenFileDescription>::create(pipe, ""_sv, 0, O_RDONLY));
m_open_files[fds[1]] = TRY(BAN::RefPtr<OpenFileDescription>::create(pipe, ""sv, 0, O_WRONLY)); m_open_files[fds[1]] = TRY(BAN::RefPtr<OpenFileDescription>::create(pipe, ""_sv, 0, O_WRONLY));
return {}; return {};
} }

View File

@ -118,7 +118,7 @@ namespace Kernel
TRY(process->m_cmdline.push_back({})); TRY(process->m_cmdline.push_back({}));
TRY(process->m_cmdline.back().append(path)); 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()) if (!process->m_loadable_elf->is_address_space_free())
{ {
dprintln("Could not load ELF address space"); dprintln("Could not load ELF address space");
@ -1942,7 +1942,7 @@ namespace Kernel
{ {
LockGuard _(m_process_lock); LockGuard _(m_process_lock);
if (path.empty() || path == "."sv) if (path.empty() || path == "."_sv)
return m_working_directory; return m_working_directory;
BAN::String absolute_path; BAN::String absolute_path;

View File

@ -30,11 +30,11 @@ namespace Kernel
s_tty = this; s_tty = this;
clear(); 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.is_error())
{ {
if (inode_or_error.error().get_error_code() == ENOENT) 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 else
dwarnln("{}", inode_or_error.error()); dwarnln("{}", inode_or_error.error());
return; return;
@ -82,7 +82,7 @@ namespace Kernel
Process::create_kernel( Process::create_kernel(
[](void*) [](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()) if (file_or_error.is_error())
{ {
dprintln("no input device found"); dprintln("no input device found");

View File

@ -131,7 +131,7 @@ namespace Kernel
BAN::ErrorOr<void> HPET::initialize(bool force_pic) BAN::ErrorOr<void> HPET::initialize(bool force_pic)
{ {
auto* header = static_cast<const ACPI::HPET*>(ACPI::ACPI::get().get_header("HPET"sv, 0)); auto* header = static_cast<const ACPI::HPET*>(ACPI::ACPI::get().get_header("HPET"_sv, 0));
if (header == nullptr) if (header == nullptr)
return BAN::Error::from_errno(ENODEV); return BAN::Error::from_errno(ENODEV);

View File

@ -34,7 +34,7 @@ struct ParsedCommandLine
{ {
bool force_pic = false; bool force_pic = false;
bool disable_serial = false; bool disable_serial = false;
BAN::StringView console = "tty0"sv; BAN::StringView console = "tty0"_sv;
BAN::StringView root; BAN::StringView root;
}; };
@ -215,7 +215,7 @@ static void init2(void*)
TTY::initialize_devices(); 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() extern "C" void ap_main()

View File

@ -112,7 +112,7 @@ index 0000000..9161771
+ +
+void DG_Init() +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( + s_window->set_key_event_callback(
+ [](LibGUI::EventPacket::KeyEvent event) + [](LibGUI::EventPacket::KeyEvent event)
+ { + {

View File

@ -36,7 +36,7 @@ BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
ASSERT(command[i] == '$'); ASSERT(command[i] == '$');
if (++i >= command.size()) if (++i >= command.size())
return "$"sv; return "$"_sv;
if (command[i] == '?') if (command[i] == '?')
{ {
@ -54,7 +54,7 @@ BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
if (const char* value = getenv(name.data())) if (const char* value = getenv(name.data()))
return BAN::StringView(value); return BAN::StringView(value);
return ""sv; return ""_sv;
} }
else if (command[i] == '{') else if (command[i] == '{')
{ {
@ -75,7 +75,7 @@ BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
if (const char* value = getenv(name.data())) if (const char* value = getenv(name.data()))
return BAN::StringView(value); return BAN::StringView(value);
return ""sv; return ""_sv;
} }
else if (command[i] == '[') else if (command[i] == '[')
{ {
@ -156,7 +156,7 @@ BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
return output; return output;
} }
BAN::String temp = "$"sv; BAN::String temp = "$"_sv;
MUST(temp.push_back(command[i])); MUST(temp.push_back(command[i]));
return temp; return temp;
} }
@ -288,16 +288,16 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
} }
BAN::ScopeGuard _([fout, should_close] { if (should_close) fclose(fout); }); 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"); fprintf(fout, "\e[H\e[2J");
fflush(fout); fflush(fout);
} }
else if (args.front() == "exit"sv) else if (args.front() == "exit"_sv)
{ {
clean_exit(); clean_exit();
} }
else if (args.front() == "export"sv) else if (args.front() == "export"_sv)
{ {
bool first = false; bool first = false;
for (const auto& arg : args) for (const auto& arg : args)
@ -316,7 +316,7 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
ERROR_RETURN("setenv", 1); ERROR_RETURN("setenv", 1);
} }
} }
else if (args.front() == "source"sv) else if (args.front() == "source"_sv)
{ {
if (args.size() != 2) if (args.size() != 2)
{ {
@ -325,13 +325,13 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
} }
return source_script(args[1]); return source_script(args[1]);
} }
else if (args.front() == "env"sv) else if (args.front() == "env"_sv)
{ {
char** current = environ; char** current = environ;
while (*current) while (*current)
fprintf(fout, "%s\n", *current++); fprintf(fout, "%s\n", *current++);
} }
else if (args.front() == "start-gui"sv) else if (args.front() == "start-gui"_sv)
{ {
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) if (pid == 0)
@ -340,12 +340,12 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
execl("/bin/Terminal", "Terminal", NULL); execl("/bin/Terminal", "Terminal", NULL);
waitpid(pid, nullptr, 0); waitpid(pid, nullptr, 0);
} }
else if (args.front() == "page-fault-test"sv) else if (args.front() == "page-fault-test"_sv)
{ {
volatile int* ptr = nullptr; volatile int* ptr = nullptr;
*ptr = 0; *ptr = 0;
} }
else if (args.front() == "kill-test"sv) else if (args.front() == "kill-test"_sv)
{ {
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) if (pid == 0)
@ -366,7 +366,7 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
return 1; return 1;
} }
} }
else if (args.front() == "signal-test"sv) else if (args.front() == "signal-test"_sv)
{ {
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) if (pid == 0)
@ -400,7 +400,7 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
return 1; 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, " 0.0: %f\n", 0.0f);
fprintf(fout, " 123.0: %f\n", 123.0f); fprintf(fout, " 123.0: %f\n", 123.0f);
@ -409,7 +409,7 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
fprintf(fout, "+INF: %f\n", INFINITY); fprintf(fout, "+INF: %f\n", INFINITY);
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) if (args.size() > 2)
{ {
@ -432,7 +432,7 @@ BAN::Optional<int> execute_builtin(BAN::Vector<BAN::String>& args, int fd_in, in
if (chdir(path.data()) == -1) if (chdir(path.data()) == -1)
ERROR_RETURN("chdir", 1); ERROR_RETURN("chdir", 1);
} }
else if (args.front() == "time"sv) else if (args.front() == "time"_sv)
{ {
args.remove(0); args.remove(0);
@ -783,7 +783,7 @@ int source_shellrc()
if (char* home = getenv("HOME")) if (char* home = getenv("HOME"))
{ {
BAN::String path(home); BAN::String path(home);
MUST(path.append("/.shellrc"sv)); MUST(path.append("/.shellrc"_sv));
if (exists(path)) if (exists(path))
return source_script(path); return source_script(path);
} }
@ -816,7 +816,7 @@ BAN::String get_prompt()
{ {
const char* raw_prompt = getenv("PS1"); const char* raw_prompt = getenv("PS1");
if (raw_prompt == nullptr) if (raw_prompt == nullptr)
return "$ "sv; return "$ "_sv;
BAN::String prompt; BAN::String prompt;
for (int i = 0; raw_prompt[i]; i++) for (int i = 0; raw_prompt[i]; i++)
@ -962,7 +962,7 @@ int main(int argc, char** argv)
tcsetattr(0, TCSANOW, &new_termios); tcsetattr(0, TCSANOW, &new_termios);
BAN::Vector<BAN::String> buffers, history; BAN::Vector<BAN::String> buffers, history;
MUST(buffers.emplace_back(""sv)); MUST(buffers.emplace_back(""_sv));
size_t index = 0; size_t index = 0;
size_t col = 0; size_t col = 0;
@ -1073,7 +1073,7 @@ int main(int argc, char** argv)
last_return = parse_and_execute_command(buffers[index]); last_return = parse_and_execute_command(buffers[index]);
MUST(history.push_back(buffers[index])); MUST(history.push_back(buffers[index]));
buffers = history; buffers = history;
MUST(buffers.emplace_back(""sv)); MUST(buffers.emplace_back(""_sv));
} }
print_prompt(); print_prompt();
index = buffers.size() - 1; index = buffers.size() - 1;

View File

@ -87,11 +87,11 @@ void Terminal::run()
signal(SIGCHLD, [](int) { s_shell_exited = true; }); signal(SIGCHLD, [](int) { s_shell_exited = true; });
start_shell(); 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->fill(m_bg_color);
m_window->invalidate(); 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); }); m_window->set_key_event_callback([&](LibGUI::EventPacket::KeyEvent event) { on_key_event(event); });

View File

@ -22,7 +22,7 @@ public:
WindowServer(Framebuffer& framebuffer) WindowServer(Framebuffer& framebuffer)
: m_framebuffer(framebuffer) : m_framebuffer(framebuffer)
, m_cursor({ framebuffer.width / 2, framebuffer.height / 2 }) , 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()); invalidate(m_framebuffer.area());
} }

View File

@ -80,7 +80,7 @@ Config parse_config()
auto variable = parts[0]; auto variable = parts[0];
auto value = parts[1]; auto value = parts[1];
if (variable == "bg"sv) if (variable == "bg"_sv)
{ {
auto image = LibImage::Image::load_from_file(value); auto image = LibImage::Image::load_from_file(value);
if (image.is_error()) if (image.is_error())
@ -156,7 +156,7 @@ int main()
atexit([]() { tty_ctrl(STDIN_FILENO, TTY_CMD_SET, TTY_FLAG_ENABLE_INPUT); }); atexit([]() { tty_ctrl(STDIN_FILENO, TTY_CMD_SET, TTY_FLAG_ENABLE_INPUT); });
MUST(LibInput::KeyboardLayout::initialize()); 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); int keyboard_fd = open("/dev/input0", O_RDONLY);
if (keyboard_fd == -1) if (keyboard_fd == -1)

View File

@ -168,9 +168,9 @@ bool is_accepted(const Item& item, const BAN::String& name, const Workflows& wor
{ {
if (!satifies_rule(item, rule)) if (!satifies_rule(item, rule))
continue; continue;
if (rule.target == "A"sv) if (rule.target == "A"_sv)
return true; return true;
if (rule.target == "R"sv) if (rule.target == "R"_sv)
return false; return false;
return is_accepted(item, rule.target, workflows); return is_accepted(item, rule.target, workflows);
} }
@ -185,7 +185,7 @@ i64 puzzle1(FILE* fp)
BAN::Vector<Item> accepted; BAN::Vector<Item> accepted;
for (const auto& item : items) for (const auto& item : items)
if (is_accepted(item, "in"sv, workflows)) if (is_accepted(item, "in"_sv, workflows))
MUST(accepted.push_back(item)); MUST(accepted.push_back(item));
i64 result = 0; i64 result = 0;
@ -243,7 +243,7 @@ i64 puzzle2(FILE* fp)
values_sorted[2][ai], values_sorted[2][ai],
values_sorted[3][si] values_sorted[3][si]
}}; }};
if (!is_accepted(item, "in"sv, workflows)) if (!is_accepted(item, "in"_sv, workflows))
continue; continue;
i64 x_count = values_sorted[0][xi + 1] - values_sorted[0][xi]; i64 x_count = values_sorted[0][xi + 1] - values_sorted[0][xi];

View File

@ -137,7 +137,7 @@ i64 puzzle1(FILE* fp)
for (size_t i = 0; i < 1000; i++) 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()) while (!signal_queue.empty())
{ {
auto signal = signal_queue.front(); auto signal = signal_queue.front();

View File

@ -45,8 +45,8 @@ i64 puzzle1(FILE* fp)
} }
} }
u32 current = coord_to_u32("AAA"sv); u32 current = coord_to_u32("AAA"_sv);
u32 target = coord_to_u32("ZZZ"sv); u32 target = coord_to_u32("ZZZ"_sv);
i64 steps = 0; i64 steps = 0;
for (; current != target; steps++) for (; current != target; steps++)

View File

@ -44,7 +44,7 @@ typedef struct {
#define FD_ZERO(setp) \ #define FD_ZERO(setp) \
do { \ 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; \ (setp)->__bits[i] = (__fd_mask)0; \
} while (0) } while (0)

View File

@ -8,10 +8,10 @@ __BEGIN_DECLS
#define __need_pid_t #define __need_pid_t
#include <sys/types.h> #include <sys/types.h>
#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 major(dev) (((dev) >> 16) & 0xFFFF)
#define minor(dev) ( (dev) & 0xFFFFFFFF) #define minor(dev) ( (dev) & 0xFFFF)
__END_DECLS __END_DECLS

View File

@ -74,7 +74,7 @@ __BEGIN_DECLS
#if !defined(__dev_t_defined) && (defined(__need_all_types) || defined(__need_dev_t)) #if !defined(__dev_t_defined) && (defined(__need_all_types) || defined(__need_dev_t))
#define __dev_t_defined 1 #define __dev_t_defined 1
typedef unsigned long dev_t; typedef unsigned int dev_t;
#endif #endif
#undef __need_dev_t #undef __need_dev_t

View File

@ -15,7 +15,7 @@ namespace LibFont { class Font; }
namespace LibGUI 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 enum WindowPacketType : uint8_t
{ {

View File

@ -608,12 +608,12 @@ namespace LibImage
return BAN::Error::from_errno(EINVAL); 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"); dwarnln_if(DEBUG_PNG, "PNG stream has IDHR chunk defined multiple times");
return BAN::Error::from_errno(EINVAL); 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) if (chunk.data.size() == 0 || chunk.data.size() % 3)
{ {
@ -639,15 +639,15 @@ namespace LibImage
palette[i].a = 0xFF; palette[i].a = 0xFF;
} }
} }
else if (chunk.name == "IDAT"sv) else if (chunk.name == "IDAT"_sv)
{ {
TRY(zlib_stream.push_back(chunk.data)); TRY(zlib_stream.push_back(chunk.data));
} }
else if (chunk.name == "IEND"sv) else if (chunk.name == "IEND"_sv)
{ {
break; break;
} }
else if (chunk.name == "tEXt"sv) else if (chunk.name == "tEXt"_sv)
{ {
auto data_sv = BAN::StringView(chunk.data.as_span<const char>().data(), chunk.data.size()); auto data_sv = BAN::StringView(chunk.data.as_span<const char>().data(), chunk.data.size());
if (auto idx = data_sv.find('\0'); !idx.has_value()) if (auto idx = data_sv.find('\0'); !idx.has_value())

View File

@ -63,9 +63,9 @@ namespace LibImage
return false; return false;
if (height > static_cast<uint64_t>(BAN::numeric_limits<int64_t>::max())) if (height > static_cast<uint64_t>(BAN::numeric_limits<int64_t>::max()))
return false; return false;
if (BAN::Math::will_multiplication_overflow(width, height)) if (BAN::Math::will_multiplication_overflow<uint64_t>(width, height))
return false; return false;
if (BAN::Math::will_multiplication_overflow(width * height, sizeof(Color))) if (BAN::Math::will_multiplication_overflow<uint64_t>(width * height, sizeof(Color)))
return false; return false;
return true; return true;
} }

View File

@ -162,7 +162,7 @@ namespace LibInput
if (parts.empty() || parts.front().front() == '#') if (parts.empty() || parts.front().front() == '#')
continue; continue;
if (parts.front() == "include"sv) if (parts.front() == "include"_sv)
{ {
if (parts.size() != 2) if (parts.size() != 2)
{ {
@ -228,7 +228,7 @@ namespace LibInput
return BAN::Error::from_errno(EINVAL); return BAN::Error::from_errno(EINVAL);
} }
if (parts.front() == "mod"sv) if (parts.front() == "mod"_sv)
{ {
if (parts.size() != 2) if (parts.size() != 2)
{ {
@ -236,9 +236,9 @@ namespace LibInput
dprintln(" format: mod MODIFIER"); dprintln(" format: mod MODIFIER");
return BAN::Error::from_errno(EINVAL); return BAN::Error::from_errno(EINVAL);
} }
if (parts[1] == "shift"sv) if (parts[1] == "shift"_sv)
shift_is_mod = true; shift_is_mod = true;
else if (parts[1] == "altgr"sv) else if (parts[1] == "altgr"_sv)
altgr_is_mod = true; altgr_is_mod = true;
else else
{ {
@ -282,9 +282,9 @@ namespace LibInput
return BAN::Error::from_errno(EINVAL); 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; 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; new_layout->m_keycode_to_key_altgr[*keycode] = *key;
else else
{ {
@ -314,159 +314,159 @@ namespace LibInput
static BAN::ErrorOr<void> initialize_name_to_key() static BAN::ErrorOr<void> initialize_name_to_key()
{ {
ASSERT(s_name_to_key.empty()); 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_Ring"_sv, Key::A_Ring));
TRY(s_name_to_key.insert("A_Umlaut"sv, Key::A_Umlaut)); 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("A"_sv, Key::A));
TRY(s_name_to_key.insert("Acute"sv, Key::Acute)); 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("AltGr"_sv, Key::AltGr));
TRY(s_name_to_key.insert("Ampersand"sv, Key::Ampersand)); 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("ArrowDown"_sv, Key::ArrowDown));
TRY(s_name_to_key.insert("ArrowLeft"sv, Key::ArrowLeft)); 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("ArrowRight"_sv, Key::ArrowRight));
TRY(s_name_to_key.insert("ArrowUp"sv, Key::ArrowUp)); 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("Asterix"_sv, Key::Asterix));
TRY(s_name_to_key.insert("AtSign"sv, Key::AtSign)); 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("B"_sv, Key::B));
TRY(s_name_to_key.insert("BackSlash"sv, Key::BackSlash)); 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("Backspace"_sv, Key::Backspace));
TRY(s_name_to_key.insert("BackTick"sv, Key::BackTick)); 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("BrokenBar"_sv, Key::BrokenBar));
TRY(s_name_to_key.insert("C"sv, Key::C)); 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("Calculator"_sv, Key::Calculator));
TRY(s_name_to_key.insert("CapsLock"sv, Key::CapsLock)); 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("Caret"_sv, Key::Caret));
TRY(s_name_to_key.insert("Cedilla"sv, Key::Cedilla)); 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("CloseCurlyBracket"_sv, Key::CloseCurlyBracket));
TRY(s_name_to_key.insert("CloseParenthesis"sv, Key::CloseParenthesis)); 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("CloseSquareBracket"_sv, Key::CloseSquareBracket));
TRY(s_name_to_key.insert("Colon"sv, Key::Colon)); 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("Comma"_sv, Key::Comma));
TRY(s_name_to_key.insert("Currency"sv, Key::Currency)); 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("D"_sv, Key::D));
TRY(s_name_to_key.insert("Delete"sv, Key::Delete)); 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("Dollar"_sv, Key::Dollar));
TRY(s_name_to_key.insert("DoubleQuote"sv, Key::DoubleQuote)); 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("E"_sv, Key::E));
TRY(s_name_to_key.insert("End"sv, Key::End)); 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("Enter"_sv, Key::Enter));
TRY(s_name_to_key.insert("Equals"sv, Key::Equals)); 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("Escape"_sv, Key::Escape));
TRY(s_name_to_key.insert("Euro"sv, Key::Euro)); 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("Exclamation"_sv, Key::ExclamationMark));
TRY(s_name_to_key.insert("ExclamationMark"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("F"_sv, Key::F));
TRY(s_name_to_key.insert("F1"sv, Key::F1)); 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("F10"_sv, Key::F10));
TRY(s_name_to_key.insert("F11"sv, Key::F11)); 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("F12"_sv, Key::F12));
TRY(s_name_to_key.insert("F2"sv, Key::F2)); 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("F3"_sv, Key::F3));
TRY(s_name_to_key.insert("F4"sv, Key::F4)); 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("F5"_sv, Key::F5));
TRY(s_name_to_key.insert("F6"sv, Key::F6)); 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("F7"_sv, Key::F7));
TRY(s_name_to_key.insert("F8"sv, Key::F8)); 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("F9"_sv, Key::F9));
TRY(s_name_to_key.insert("G"sv, Key::G)); 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("GreaterThan"_sv, Key::GreaterThan));
TRY(s_name_to_key.insert("H"sv, Key::H)); 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("Half"_sv, Key::Half));
TRY(s_name_to_key.insert("Hashtag"sv, Key::Hashtag)); 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("Home"_sv, Key::Home));
TRY(s_name_to_key.insert("Hyphen"sv, Key::Hyphen)); 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("I"_sv, Key::I));
TRY(s_name_to_key.insert("Insert"sv, Key::Insert)); 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("J"_sv, Key::J));
TRY(s_name_to_key.insert("K"sv, Key::K)); 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("Key0"_sv, Key::_0));
TRY(s_name_to_key.insert("Key1"sv, Key::_1)); 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("Key2"_sv, Key::_2));
TRY(s_name_to_key.insert("Key3"sv, Key::_3)); 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("Key4"_sv, Key::_4));
TRY(s_name_to_key.insert("Key5"sv, Key::_5)); 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("Key6"_sv, Key::_6));
TRY(s_name_to_key.insert("Key7"sv, Key::_7)); 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("Key8"_sv, Key::_8));
TRY(s_name_to_key.insert("Key9"sv, Key::_9)); 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("L"_sv, Key::L));
TRY(s_name_to_key.insert("LAlt"sv, Key::LeftAlt)); 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("LControl"_sv, Key::LeftCtrl));
TRY(s_name_to_key.insert("LeftAlt"sv, Key::LeftAlt)); 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("LeftControl"_sv, Key::LeftCtrl));
TRY(s_name_to_key.insert("LeftShift"sv, Key::LeftShift)); 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("LessThan"_sv, Key::LessThan));
TRY(s_name_to_key.insert("LShift"sv, Key::LeftShift)); 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("M"_sv, Key::M));
TRY(s_name_to_key.insert("MediaNext"sv, Key::MediaNext)); 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("MediaPlayPause"_sv, Key::MediaPlayPause));
TRY(s_name_to_key.insert("MediaPrevious"sv, Key::MediaPrevious)); 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("MediaStop"_sv, Key::MediaStop));
TRY(s_name_to_key.insert("N"sv, Key::N)); 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("Negation"_sv, Key::Negation));
TRY(s_name_to_key.insert("None"sv, Key::None)); 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("NumLock"_sv, Key::NumLock));
TRY(s_name_to_key.insert("Numpad0"sv, Key::Numpad0)); 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("Numpad1"_sv, Key::Numpad1));
TRY(s_name_to_key.insert("Numpad2"sv, Key::Numpad2)); 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("Numpad3"_sv, Key::Numpad3));
TRY(s_name_to_key.insert("Numpad4"sv, Key::Numpad4)); 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("Numpad5"_sv, Key::Numpad5));
TRY(s_name_to_key.insert("Numpad6"sv, Key::Numpad6)); 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("Numpad7"_sv, Key::Numpad7));
TRY(s_name_to_key.insert("Numpad8"sv, Key::Numpad8)); 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("Numpad9"_sv, Key::Numpad9));
TRY(s_name_to_key.insert("NumpadDecimal"sv, Key::NumpadDecimal)); 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("NumpadDivide"_sv, Key::NumpadDivide));
TRY(s_name_to_key.insert("NumpadEnter"sv, Key::NumpadEnter)); 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("NumpadMinus"_sv, Key::NumpadMinus));
TRY(s_name_to_key.insert("NumpadMultiply"sv, Key::NumpadMultiply)); 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("NumpadPlus"_sv, Key::NumpadPlus));
TRY(s_name_to_key.insert("O_Umlaut"sv, Key::O_Umlaut)); 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("O"_sv, Key::O));
TRY(s_name_to_key.insert("OpenCurlyBracket"sv, Key::OpenCurlyBracket)); 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("OpenParenthesis"_sv, Key::OpenParenthesis));
TRY(s_name_to_key.insert("OpenSquareBracket"sv, Key::OpenSquareBracket)); 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("P"_sv, Key::P));
TRY(s_name_to_key.insert("PageDown"sv, Key::PageDown)); 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("PageUp"_sv, Key::PageUp));
TRY(s_name_to_key.insert("Percent"sv, Key::Percent)); 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("Period"_sv, Key::Period));
TRY(s_name_to_key.insert("Pipe"sv, Key::Pipe)); 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("Plus"_sv, Key::Plus));
TRY(s_name_to_key.insert("Pound"sv, Key::Pound)); 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("PrintScreen"_sv, Key::PrintScreen));
TRY(s_name_to_key.insert("Q"sv, Key::Q)); 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("Question"_sv, Key::QuestionMark));
TRY(s_name_to_key.insert("QuestionMark"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("R"_sv, Key::R));
TRY(s_name_to_key.insert("RAlt"sv, Key::RightAlt)); 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("RControl"_sv, Key::RightCtrl));
TRY(s_name_to_key.insert("RightAlt"sv, Key::RightAlt)); 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("RightControl"_sv, Key::RightCtrl));
TRY(s_name_to_key.insert("RightShift"sv, Key::RightShift)); 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("RShift"_sv, Key::RightShift));
TRY(s_name_to_key.insert("S"sv, Key::S)); 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("ScrollLock"_sv, Key::ScrollLock));
TRY(s_name_to_key.insert("Section"sv, Key::Section)); 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("Semicolon"_sv, Key::Semicolon));
TRY(s_name_to_key.insert("SingleQuote"sv, Key::SingleQuote)); 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("Slash"_sv, Key::Slash));
TRY(s_name_to_key.insert("Space"sv, Key::Space)); 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("Super"_sv, Key::Super));
TRY(s_name_to_key.insert("T"sv, Key::T)); 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("Tab"_sv, Key::Tab));
TRY(s_name_to_key.insert("Tilde"sv, Key::Tilde)); 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("TwoDots"_sv, Key::TwoDots));
TRY(s_name_to_key.insert("U"sv, Key::U)); 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("Underscore"_sv, Key::Underscore));
TRY(s_name_to_key.insert("V"sv, Key::V)); 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("VolumeDown"_sv, Key::VolumeDown));
TRY(s_name_to_key.insert("VolumeMute"sv, Key::VolumeMute)); 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("VolumeUp"_sv, Key::VolumeUp));
TRY(s_name_to_key.insert("W"sv, Key::W)); 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("X"_sv, Key::X));
TRY(s_name_to_key.insert("Y"sv, Key::Y)); 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("Z"_sv, Key::Z));
return {}; return {};
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View File

@ -11,7 +11,7 @@ namespace LibInput
bits 7:5 row (from top) 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) consteval uint8_t keycode_function(uint8_t index)
{ {

View File

@ -297,7 +297,7 @@ int main(int argc, const char* argv[])
BAN::Vector<BAN::String> files; BAN::Vector<BAN::String> files;
if (i == argc) if (i == argc)
MUST(files.emplace_back("."sv)); MUST(files.emplace_back("."_sv));
else for (; i < argc; i++) else for (; i < argc; i++)
MUST(files.emplace_back(BAN::StringView(argv[i]))); MUST(files.emplace_back(BAN::StringView(argv[i])));

View File

@ -212,6 +212,9 @@ int main(int, char**)
struct Client struct Client
{ {
Client(int socket)
: socket(socket)
{ }
const int socket; const int socket;
bool close { false }; bool close { false };
uint16_t query_id { 0 }; uint16_t query_id { 0 };

View File

@ -66,7 +66,7 @@ int main(int argc, char** argv)
printf(" File: %s\n", argv[i]); 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(" 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: (%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("Access: "); print_timestamp(st.st_atim); printf("\n");
printf("Modify: "); print_timestamp(st.st_mtim); printf("\n"); printf("Modify: "); print_timestamp(st.st_mtim); printf("\n");