1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

Kernel: Mark UserOrKernelBuffer and it's getters as [[nodicard]]

`UserOrKernelBuffer` objects should always be observed when created, in
turn there is no reason to call a getter without observing the result.
Doing either of these indicates an error in the code. Mark these methods
as [[nodiscard]] to find these cases.
This commit is contained in:
Brian Gianforcaro 2021-02-14 15:22:28 -08:00 committed by Andreas Kling
parent 01a66efe9d
commit a75d7958cc

View file

@ -36,7 +36,7 @@
namespace Kernel {
class UserOrKernelBuffer {
class [[nodiscard]] UserOrKernelBuffer {
public:
UserOrKernelBuffer() = delete;
@ -61,10 +61,10 @@ public:
return UserOrKernelBuffer(const_cast<u8*>((const u8*)userspace.unsafe_userspace_ptr()));
}
bool is_kernel_buffer() const;
const void* user_or_kernel_ptr() const { return m_buffer; }
[[nodiscard]] bool is_kernel_buffer() const;
[[nodiscard]] const void* user_or_kernel_ptr() const { return m_buffer; }
UserOrKernelBuffer offset(ssize_t offset) const
[[nodiscard]] UserOrKernelBuffer offset(ssize_t offset) const
{
if (!m_buffer)
return *this;
@ -74,7 +74,7 @@ public:
return offset_buffer;
}
String copy_into_string(size_t size) const;
[[nodiscard]] String copy_into_string(size_t size) const;
[[nodiscard]] bool write(const void* src, size_t offset, size_t len);
[[nodiscard]] bool write(const void* src, size_t len)
{