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:
2024-06-18 20:32:43 +03:00
parent 526d4369ce
commit 318ce5dec8
59 changed files with 339 additions and 326 deletions

View File

@@ -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<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));
break;
}

View File

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

View File

@@ -45,7 +45,7 @@ namespace Kernel::ACPI::AML
[[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 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;
};

View File

@@ -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<AML::Device*>(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<AML::Processor*>(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<AML::ThermalZone*>(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;
}

View File

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

View File

@@ -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(");

View File

@@ -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)

View File

@@ -16,7 +16,7 @@ namespace Kernel
virtual bool is_partition() 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;

View File

@@ -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)

View File

@@ -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)

View File

@@ -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<BlockDevice> m_block_device;
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::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 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:
mutable PriorityMutex m_mutex;

View File

@@ -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 };

View File

@@ -154,7 +154,7 @@ namespace Kernel
#endif
TaskStateSegment m_tss;
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())
};
};

View File

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

View File

@@ -19,7 +19,7 @@ namespace Kernel::Input
static BAN::ErrorOr<PS2Mouse*> 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;

View File

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

View File

@@ -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<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;
}
uint16_t calculate_internet_checksum(BAN::ConstByteSpan packet, const PseudoHeader& pseudo_header);
}

View File

@@ -38,7 +38,7 @@ namespace Kernel
BAN::ErrorOr<void> 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;

View File

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