From 178d566278f580ed5625d2d34831b4d263ee09af Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 5 Dec 2025 18:33:01 +0100 Subject: multiboot2: silence some warnings --- libs/multiboot2/include/multiboot2/impl/data.hpp | 12 +++--- libs/multiboot2/include/multiboot2/impl/ids.hpp | 8 ++-- .../include/multiboot2/impl/iterator.hpp | 2 + libs/multiboot2/include/multiboot2/impl/tag.hpp | 21 ++++++----- libs/multiboot2/include/multiboot2/information.hpp | 44 +++++++++++----------- 5 files changed, 48 insertions(+), 39 deletions(-) (limited to 'libs') 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 @@ -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 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 @@ -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(std::bit_cast(this) + full_size()); + return std::bit_cast(std::bit_cast(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(header + 1)} + , Data{*std::bit_cast(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 - auto has() const noexcept -> bool + [[nodiscard]] auto has() const noexcept -> bool { return get().has_value(); } - auto maybe_basic_memory() const noexcept -> std::optional + [[nodiscard]] auto maybe_basic_memory() const noexcept -> std::optional { return get(); } - 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 + [[nodiscard]] auto maybe_bios_boot_device() const noexcept -> std::optional { return get(); } - 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 + [[nodiscard]] auto maybe_command_line() const noexcept -> std::optional { return get(); } - auto command_line() const -> command_line + [[nodiscard]] auto command_line() const -> command_line { return maybe_command_line().value(); } template - auto maybe_elf_symbols() const noexcept -> std::optional> + [[nodiscard]] auto maybe_elf_symbols() const noexcept -> std::optional> { return get>().and_then( [](auto x) -> std::optional> { @@ -185,34 +185,34 @@ namespace multiboot2 } template - auto elf_symbols() const -> elf_symbols + [[nodiscard]] auto elf_symbols() const -> elf_symbols { return maybe_elf_symbols().value(); } - auto maybe_loader_name() const noexcept -> std::optional + [[nodiscard]] auto maybe_loader_name() const noexcept -> std::optional { return get(); } - 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 + [[nodiscard]] auto maybe_memory_map() const noexcept -> std::optional { return get(); } - auto memory_map() const -> memory_map + [[nodiscard]] auto memory_map() const -> memory_map { return maybe_memory_map().value(); } private: template - constexpr auto get() const noexcept -> std::optional + [[nodiscard]] constexpr auto get() const noexcept -> std::optional { 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 -- cgit v1.2.3