diff options
| -rw-r--r-- | .vscode/settings.json | 8 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/data.hpp | 12 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/ids.hpp | 8 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/iterator.hpp | 2 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/impl/tag.hpp | 21 | ||||
| -rw-r--r-- | libs/multiboot2/include/multiboot2/information.hpp | 44 |
6 files changed, 53 insertions, 42 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 4f3f047..72a3903 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,17 +22,19 @@ ] }, "cSpell.words": [ + "acpi", "crtc", "efer", - "INTERPROCEDURAL", + "interprocedural", "invlpg", + "iwyu", "kapi", "kstd", "multiboot", - "NOLINTNEXTLINE", + "nolintnextline", "rdmsr", "rvalues", - "TeachOS", + "teachos", "wrmsr" ] }
\ No newline at end of file diff --git a/libs/multiboot2/include/multiboot2/impl/data.hpp b/libs/multiboot2/include/multiboot2/impl/data.hpp index 3cda162..733ce3a 100644 --- a/libs/multiboot2/include/multiboot2/impl/data.hpp +++ b/libs/multiboot2/include/multiboot2/impl/data.hpp @@ -1,6 +1,8 @@ #ifndef MULTIBOOT2_IMPL_DATA_HPP #define MULTIBOOT2_IMPL_DATA_HPP +// IWYU pragma: private + #include "multiboot2/impl/ids.hpp" #include <cstdint> @@ -23,14 +25,14 @@ namespace multiboot2::impl * * The maximum possible value for this field is 640 KiB. */ - std::uint32_t const lower_KiB; + std::uint32_t lower_KiB; /** * @brief Amount of upper memory (above 1MiB) available to the system. * * The maximum possible value for this field is the address of the first upper memory hole minus 1MiB. */ - std::uint32_t const upper_KiB; + std::uint32_t upper_KiB; }; /** @@ -94,7 +96,7 @@ namespace multiboot2::impl /** * @brief Check if the memory described by this region is available for use. */ - constexpr auto available() const noexcept + [[nodiscard]] constexpr auto available() const noexcept { return type == memory_type::AVAILABLE; } @@ -120,12 +122,12 @@ namespace multiboot2::impl /** * @brief Size of each entry present in the map */ - std::uint32_t const entry_size; + std::uint32_t entry_size; /** * @brief Version of each entry present in the map */ - std::uint32_t const entry_version; + std::uint32_t entry_version; }; } // namespace multiboot2::impl diff --git a/libs/multiboot2/include/multiboot2/impl/ids.hpp b/libs/multiboot2/include/multiboot2/impl/ids.hpp index 3a7215e..98bc1f2 100644 --- a/libs/multiboot2/include/multiboot2/impl/ids.hpp +++ b/libs/multiboot2/include/multiboot2/impl/ids.hpp @@ -1,6 +1,8 @@ #ifndef MULTIBOOT2_IMPL_IDS_HPP #define MULTIBOOT2_IMPL_IDS_HPP +// IWYU pragma: private + #include <cstdint> namespace multiboot2::impl @@ -24,14 +26,14 @@ namespace multiboot2::impl APM_INFO, ///< Advanced Power Management information. EFI32, ///< EFI 32 bit system table pointer. EFI64, ///< EFI 64 bit system table pointer. - SMBIOS, ///< Contains copy of all Sytem Management BIOS tables. + SMBIOS, ///< Contains copy of all System Management BIOS tables. ACPI_OLD, ///< Contains copy of RSDP as defined per ACPI1.0 specification. ACPI_NEW, ///< Contains copy of RSDP as defined per ACPI2.0 or later specification. NETWORK, ///< Contains network information specified specified as DHCP. EFI_MEMORY_MAP, ///< Contains EFI memory map. - EFI_BS_NOT_TERMINATED, ///< Indicated ExitBootServies wasn't called. + EFI_BS_NOT_TERMINATED, ///< Indicates ExitBootServices wasn't called. EFI32_IMAGE_HANDLE, ///< EFI 32 bit image handle pointer. - EFI64_IMAGE_HANDLE, ///< EFI 64 bit imae handle pointer. + EFI64_IMAGE_HANDLE, ///< EFI 64 bit image handle pointer. LOAD_BASE_ADDRESS ///< Contains image load base physical address. }; diff --git a/libs/multiboot2/include/multiboot2/impl/iterator.hpp b/libs/multiboot2/include/multiboot2/impl/iterator.hpp index f8955cb..5651f22 100644 --- a/libs/multiboot2/include/multiboot2/impl/iterator.hpp +++ b/libs/multiboot2/include/multiboot2/impl/iterator.hpp @@ -1,6 +1,8 @@ #ifndef MULTIBOOT2_IMPL_INFORMATION_ITERATOR_HPP #define MULTIBOOT2_IMPL_INFORMATION_ITERATOR_HPP +// IWYU pragma: private + #include "multiboot2/impl/ids.hpp" #include "multiboot2/impl/tag.hpp" diff --git a/libs/multiboot2/include/multiboot2/impl/tag.hpp b/libs/multiboot2/include/multiboot2/impl/tag.hpp index a6e2678..3d0cea5 100644 --- a/libs/multiboot2/include/multiboot2/impl/tag.hpp +++ b/libs/multiboot2/include/multiboot2/impl/tag.hpp @@ -1,6 +1,8 @@ #ifndef MULTIBOOT2_IMPL_TAG_HPP #define MULTIBOOT2_IMPL_TAG_HPP +// IWYU pragma: private + #include "multiboot2/impl/ids.hpp" #include <bit> @@ -25,29 +27,30 @@ namespace multiboot2::impl : tag_header{*data} {} - auto full_size() const noexcept -> std::size_t + [[nodiscard]] auto full_size() const noexcept -> std::size_t { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) return (m_size + 7) & (~7); } - auto information_id() const noexcept -> impl::information_id const & + [[nodiscard]] auto information_id() const noexcept -> impl::information_id const & { return m_id; } - auto next() const noexcept -> tag_header const * + [[nodiscard]] auto next() const noexcept -> tag_header const * { - return std::bit_cast<tag_header const *>(std::bit_cast<std::byte const *>(this) + full_size()); + return std::bit_cast<tag_header const *>(std::bit_cast<std::uintptr_t>(this) + full_size()); } - auto unaligned_size() const noexcept -> std::uint32_t + [[nodiscard]] auto unaligned_size() const noexcept -> std::uint32_t { return m_size; } - protected: - impl::information_id const m_id; - std::uint32_t const m_size; + private: + impl::information_id m_id; + std::uint32_t m_size; }; /** @@ -64,7 +67,7 @@ namespace multiboot2::impl explicit tag(tag_header const * header) requires(sizeof(tag) > sizeof(tag_header)) : tag_header{header} - , Data{*std::bit_cast<Data const *>(header + 1)} + , Data{*std::bit_cast<Data const *>(header + 1)} // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) {} explicit tag(tag_header const * header) diff --git a/libs/multiboot2/include/multiboot2/information.hpp b/libs/multiboot2/include/multiboot2/information.hpp index 25f034d..2d60a6d 100644 --- a/libs/multiboot2/include/multiboot2/information.hpp +++ b/libs/multiboot2/include/multiboot2/information.hpp @@ -45,7 +45,7 @@ namespace multiboot2 /** * @brief The command line string */ - auto string() const noexcept -> range_type + [[nodiscard]] auto string() const noexcept -> range_type { return {data(), size()}; } @@ -84,7 +84,7 @@ namespace multiboot2 /** * @brief The name of the bootloader */ - auto string() const noexcept -> std::string_view + [[nodiscard]] auto string() const noexcept -> std::string_view { return {data(), size()}; } @@ -100,7 +100,7 @@ namespace multiboot2 /** * @brief The available memory regions */ - auto regions() const noexcept -> range_type + [[nodiscard]] auto regions() const noexcept -> range_type { return {data(), size()}; } @@ -113,19 +113,19 @@ namespace multiboot2 using pointer = impl::information_iterator::pointer; using reference = impl::information_iterator::reference; - auto size_bytes() const noexcept -> std::size_t + [[nodiscard]] auto size_bytes() const noexcept -> std::size_t { return m_size; } // Range access - auto begin() const noexcept -> iterator + [[nodiscard]] auto begin() const noexcept -> iterator { return iterator{&m_tags}; } - auto end() const noexcept -> iterator + [[nodiscard]] auto end() const noexcept -> iterator { return iterator{}; } @@ -133,43 +133,43 @@ namespace multiboot2 // Tag access template<typename Tag> - auto has() const noexcept -> bool + [[nodiscard]] auto has() const noexcept -> bool { return get<Tag>().has_value(); } - auto maybe_basic_memory() const noexcept -> std::optional<basic_memory> + [[nodiscard]] auto maybe_basic_memory() const noexcept -> std::optional<basic_memory> { return get<multiboot2::basic_memory>(); } - auto basic_memory() const -> basic_memory + [[nodiscard]] auto basic_memory() const -> basic_memory { return maybe_basic_memory().value(); } - auto maybe_bios_boot_device() const noexcept -> std::optional<bios_boot_device> + [[nodiscard]] auto maybe_bios_boot_device() const noexcept -> std::optional<bios_boot_device> { return get<multiboot2::bios_boot_device>(); } - auto bios_boot_device() const -> bios_boot_device + [[nodiscard]] auto bios_boot_device() const -> bios_boot_device { return maybe_bios_boot_device().value(); } - auto maybe_command_line() const noexcept -> std::optional<command_line> + [[nodiscard]] auto maybe_command_line() const noexcept -> std::optional<command_line> { return get<multiboot2::command_line>(); } - auto command_line() const -> command_line + [[nodiscard]] auto command_line() const -> command_line { return maybe_command_line().value(); } template<elf::format Format> - auto maybe_elf_symbols() const noexcept -> std::optional<elf_symbols<Format>> + [[nodiscard]] auto maybe_elf_symbols() const noexcept -> std::optional<elf_symbols<Format>> { return get<multiboot2::elf_symbols<Format>>().and_then( [](auto x) -> std::optional<multiboot2::elf_symbols<Format>> { @@ -185,34 +185,34 @@ namespace multiboot2 } template<elf::format Format> - auto elf_symbols() const -> elf_symbols<Format> + [[nodiscard]] auto elf_symbols() const -> elf_symbols<Format> { return maybe_elf_symbols<Format>().value(); } - auto maybe_loader_name() const noexcept -> std::optional<loader_name> + [[nodiscard]] auto maybe_loader_name() const noexcept -> std::optional<loader_name> { return get<multiboot2::loader_name>(); } - auto loader_name() const -> loader_name + [[nodiscard]] auto loader_name() const -> loader_name { return maybe_loader_name().value(); } - auto maybe_memory_map() const noexcept -> std::optional<memory_map> + [[nodiscard]] auto maybe_memory_map() const noexcept -> std::optional<memory_map> { return get<multiboot2::memory_map>(); } - auto memory_map() const -> memory_map + [[nodiscard]] auto memory_map() const -> memory_map { return maybe_memory_map().value(); } private: template<typename Tag> - constexpr auto get() const noexcept -> std::optional<Tag> + [[nodiscard]] constexpr auto get() const noexcept -> std::optional<Tag> { if (auto found = std::ranges::find_if(*this, [](auto tag) { return tag.information_id() == Tag::id; }); found != end()) @@ -222,9 +222,9 @@ namespace multiboot2 return std::nullopt; } - [[maybe_unused]] uint32_t const m_size{}; + uint32_t m_size{}; uint32_t : 32; - impl::tag_header const m_tags{}; + impl::tag_header m_tags{}; }; } // namespace multiboot2 |
