From 79ef6855eb38edd03b51d2f5a2f614cdd7b9fcf1 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 3 Sep 2026 13:38:00 +0200 Subject: chore: add missing [[nodiscard]] attributes --- kapi/kapi/devices/facet_registry.hpp | 9 +++++---- kapi/kapi/devices/power.hpp | 2 +- kernel/kernel/devices/block_device_utils.hpp | 8 ++++---- kernel/kernel/filesystems/devfs/inode.hpp | 3 ++- kernel/kernel/filesystems/ext2/inode.hpp | 3 ++- kernel/kernel/filesystems/rootfs/inode.hpp | 3 ++- kernel/kernel/vfs/inode.hpp | 3 ++- kernel/kernel/vfs/mount.hpp | 5 +++-- kernel/kernel/vfs/open_file_descriptor.hpp | 10 ++++++---- kernel/kernel/vfs/open_file_table.hpp | 4 ++-- 10 files changed, 29 insertions(+), 21 deletions(-) diff --git a/kapi/kapi/devices/facet_registry.hpp b/kapi/kapi/devices/facet_registry.hpp index 7006c026..3c405923 100644 --- a/kapi/kapi/devices/facet_registry.hpp +++ b/kapi/kapi/devices/facet_registry.hpp @@ -150,7 +150,7 @@ namespace kapi::devices //! @param device The device to publish the facet for. //! @param name A stable name for the device. template - auto publish(kstd::shared_ptr device, kstd::string name) -> kstd::result + [[nodiscard]] auto publish(kstd::shared_ptr device, kstd::string name) -> kstd::result { if (!device) { @@ -172,7 +172,8 @@ namespace kapi::devices //! @param name A stable name for the device. //! @param facet The implementation of the facet for the device. template - auto publish(kstd::shared_ptr device, kstd::string name, FacetType * facet) -> kstd::result + [[nodiscard]] auto publish(kstd::shared_ptr device, kstd::string name, FacetType * facet) + -> kstd::result { return do_publish(device, std::move(name), FacetType::id, facet); } @@ -254,8 +255,8 @@ namespace kapi::devices //! @param name A stable name for the device. //! @param id The id of the facet to be published for the device. //! @param facet The facet of the device. - auto do_publish(kstd::shared_ptr device, kstd::string name, kapi::capabilities::facet_id id, void * facet) - -> kstd::result; + [[nodiscard]] auto do_publish(kstd::shared_ptr device, kstd::string name, kapi::capabilities::facet_id id, + void * facet) -> kstd::result; //! Notify all subscribed observers about a new facet having been published for a device. //! diff --git a/kapi/kapi/devices/power.hpp b/kapi/kapi/devices/power.hpp index 44837a65..a87ebc78 100644 --- a/kapi/kapi/devices/power.hpp +++ b/kapi/kapi/devices/power.hpp @@ -21,7 +21,7 @@ namespace kapi::devices //! //! @param root The root of the tree to suspend. //! @return nothing on success, the first error to occur otherwise. - auto suspend_tree(bus & root) -> kstd::result; + [[nodiscard]] auto suspend_tree(bus & root) -> kstd::result; //! Resume a device (sub-)tree rooted in a given bus. //! diff --git a/kernel/kernel/devices/block_device_utils.hpp b/kernel/kernel/devices/block_device_utils.hpp index 1fb7cd9d..d6a6724c 100644 --- a/kernel/kernel/devices/block_device_utils.hpp +++ b/kernel/kernel/devices/block_device_utils.hpp @@ -30,8 +30,8 @@ namespace kernel::devices::block_device_utils //! @param buffer The buffer to read data into. //! @param offset The offset on the block device to start reading from. //! @return The number of bytes actually read, which may be less than the requested size. - auto read(kapi::filesystem::block_special_file & device, std::span buffer, kstd::bytes offset) - -> kstd::result; + [[nodiscard]] auto read(kapi::filesystem::block_special_file & device, std::span buffer, + kstd::bytes offset) -> kstd::result; //! @brief Write data from a buffer to a given block device. //! @@ -39,8 +39,8 @@ namespace kernel::devices::block_device_utils //! @param buffer The buffer to write data from. //! @param offset The offset on the block device to start writing to. //! @return The number of bytes actually written, which may be less than the requested size. - auto write(kapi::filesystem::block_special_file & device, std::span buffer, kstd::bytes offset) - -> kstd::result; + [[nodiscard]] auto write(kapi::filesystem::block_special_file & device, std::span buffer, + kstd::bytes offset) -> kstd::result; } // namespace kernel::devices::block_device_utils #endif \ No newline at end of file diff --git a/kernel/kernel/filesystems/devfs/inode.hpp b/kernel/kernel/filesystems/devfs/inode.hpp index c19671df..9a01d777 100644 --- a/kernel/kernel/filesystems/devfs/inode.hpp +++ b/kernel/kernel/filesystems/devfs/inode.hpp @@ -22,7 +22,8 @@ namespace kernel::filesystems::devfs [[nodiscard]] auto read(std::span buffer, kstd::bytes offset) const -> kstd::result override; - auto write(std::span buffer, kstd::bytes offset) -> kstd::result override; + [[nodiscard]] auto write(std::span buffer, kstd::bytes offset) + -> kstd::result override; [[nodiscard]] auto is_directory() const -> bool override; diff --git a/kernel/kernel/filesystems/ext2/inode.hpp b/kernel/kernel/filesystems/ext2/inode.hpp index 9a3561f7..206d2a48 100644 --- a/kernel/kernel/filesystems/ext2/inode.hpp +++ b/kernel/kernel/filesystems/ext2/inode.hpp @@ -64,7 +64,8 @@ namespace kernel::filesystems::ext2 [[nodiscard]] auto read(std::span buffer, kstd::bytes offset) const -> kstd::result override; - auto write(std::span buffer, kstd::bytes offset) -> kstd::result override; + [[nodiscard]] auto write(std::span buffer, kstd::bytes offset) + -> kstd::result override; //! @} diff --git a/kernel/kernel/filesystems/rootfs/inode.hpp b/kernel/kernel/filesystems/rootfs/inode.hpp index 10e6a4e1..2bd5863f 100644 --- a/kernel/kernel/filesystems/rootfs/inode.hpp +++ b/kernel/kernel/filesystems/rootfs/inode.hpp @@ -23,7 +23,8 @@ namespace kernel::filesystems::rootfs [[nodiscard]] auto read(std::span buffer, kstd::bytes offset) const -> kstd::result override; - auto write(std::span buffer, kstd::bytes offset) -> kstd::result override; + [[nodiscard]] auto write(std::span buffer, kstd::bytes offset) + -> kstd::result override; [[nodiscard]] auto is_directory() const -> bool override; diff --git a/kernel/kernel/vfs/inode.hpp b/kernel/kernel/vfs/inode.hpp index 63e73315..37fed901 100644 --- a/kernel/kernel/vfs/inode.hpp +++ b/kernel/kernel/vfs/inode.hpp @@ -55,7 +55,8 @@ namespace kernel::vfs //! @param buffer Source buffer. //! @param offset Write offset in bytes. //! @return The number of bytes written on success, an error otherwise. - virtual auto write(std::span buffer, kstd::bytes offset) -> kstd::result = 0; + [[nodiscard]] virtual auto write(std::span buffer, kstd::bytes offset) + -> kstd::result = 0; //! @} diff --git a/kernel/kernel/vfs/mount.hpp b/kernel/kernel/vfs/mount.hpp index dc49212c..4b303297 100644 --- a/kernel/kernel/vfs/mount.hpp +++ b/kernel/kernel/vfs/mount.hpp @@ -43,8 +43,9 @@ namespace kernel::vfs //! @param parent_mount The parent mount which contains the mount_dentry. //! @param source_mount The mount that the filesystem originates from. //! @param backing_inode The backing inode for the filesystem, if any. - auto static create(dentry_ptr const & mount_dentry, filesystem_ptr const & fs, mount_ptr const & parent_mount, - mount_ptr const & source_mount, inode_ptr const & backing_inode) -> kstd::result; + [[nodiscard]] auto static create(dentry_ptr const & mount_dentry, filesystem_ptr const & fs, + mount_ptr const & parent_mount, mount_ptr const & source_mount, + inode_ptr const & backing_inode) -> kstd::result; //! Get the directory entry where the filesystem is mounted. [[nodiscard]] auto mount_dentry() const -> dentry_ptr const &; diff --git a/kernel/kernel/vfs/open_file_descriptor.hpp b/kernel/kernel/vfs/open_file_descriptor.hpp index 587105b8..5cac23e8 100644 --- a/kernel/kernel/vfs/open_file_descriptor.hpp +++ b/kernel/kernel/vfs/open_file_descriptor.hpp @@ -32,26 +32,28 @@ namespace kernel::vfs //! //! @param buffer The buffer to read data into. //! @return The number of bytes read on success, an error otherwise. - virtual auto read(std::span buffer) -> kstd::result; + [[nodiscard]] virtual auto read(std::span buffer) -> kstd::result; //! Write data to the open file descriptor from a buffer. //! //! @param buffer The buffer to write data from. //! @return The number of bytes written on success, an error otherwise. - virtual auto write(std::span buffer) -> kstd::result; + [[nodiscard]] virtual auto write(std::span buffer) -> kstd::result; //! Move the read/write offset of the file. //! //! @param offset The offset to apply relative to the given origin. //! @param origin The origin of the offset. //! @return the new offset on success, an error otherwise. - virtual auto seek(kstd::offset offset, kapi::filesystem::seek_origin origin) -> kstd::result; + [[nodiscard]] virtual auto seek(kstd::offset offset, kapi::filesystem::seek_origin origin) + -> kstd::result; //! Read directory entries from the file. //! //! @param entries A buffer to read the entries into. //! @return The number of read entries on success, an error otherwise. - virtual auto read_directory(std::span entries) -> kstd::result; + [[nodiscard]] virtual auto read_directory(std::span entries) + -> kstd::result; //! Get a reference to the directory entry associated with this open file descriptor. //! diff --git a/kernel/kernel/vfs/open_file_table.hpp b/kernel/kernel/vfs/open_file_table.hpp index 8d6a2341..e7e57f6b 100644 --- a/kernel/kernel/vfs/open_file_table.hpp +++ b/kernel/kernel/vfs/open_file_table.hpp @@ -33,7 +33,7 @@ namespace kernel::vfs //! //! @param fd The file descriptor to add. //! @return The file descriptor index assigned to the file on success, an error otherwise. - auto add_file(kstd::shared_ptr const & fd) -> kstd::result; + [[nodiscard]] auto add_file(kstd::shared_ptr const & fd) -> kstd::result; //! Get a file from the open file table. //! @@ -45,7 +45,7 @@ namespace kernel::vfs //! //! @param fd The file descriptor index to remove. //! @return Nothin on success, an error otherwise. - auto remove_file(std::size_t fd) -> kstd::result; + [[nodiscard]] auto remove_file(std::size_t fd) -> kstd::result; private: open_file_table() = default; -- cgit v1.2.3