summaryrefslogtreecommitdiff
path: root/Kernel/UserOrKernelBuffer.h
diff options
context:
space:
mode:
authorBrian Gianforcaro <b.gianfo@gmail.com>2021-02-14 15:22:28 -0800
committerAndreas Kling <kling@serenityos.org>2021-02-15 09:34:52 +0100
commita75d7958cc35afaad4b928f4957347f0bfc75105 (patch)
treebd85ad7c371c31ee11d1f55b707c76d3bb05a6ef /Kernel/UserOrKernelBuffer.h
parent01a66efe9d607d0a47d81e49c862b6ac1adcf950 (diff)
downloadserenity-a75d7958cc35afaad4b928f4957347f0bfc75105.zip
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.
Diffstat (limited to 'Kernel/UserOrKernelBuffer.h')
-rw-r--r--Kernel/UserOrKernelBuffer.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/UserOrKernelBuffer.h b/Kernel/UserOrKernelBuffer.h
index a6280f0254..9bbbfc21aa 100644
--- a/Kernel/UserOrKernelBuffer.h
+++ b/Kernel/UserOrKernelBuffer.h
@@ -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)
{