From 9fb0de1cfe6d29b4466eeb18d11607fb00830144 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 12 Jul 2023 10:28:55 -0400 Subject: [PATCH] AK: Mark Error nodiscard ...instead of manually marking all methods returning Error nodiscard. No real behavior change. --- AK/Error.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AK/Error.h b/AK/Error.h index 33ee2d0924..351d285349 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -19,12 +19,12 @@ namespace AK { -class Error { +class [[nodiscard]] Error { public: ALWAYS_INLINE Error(Error&&) = default; ALWAYS_INLINE Error& operator=(Error&&) = default; - [[nodiscard]] static Error from_errno(int code) + static Error from_errno(int code) { VERIFY(code != 0); return Error(code); @@ -34,14 +34,14 @@ public: // the error message and return the errno code. // For calling this method from userspace programs, we will simply return from // the Error::from_string_view method! - [[nodiscard]] static Error from_string_view_or_print_error_and_return_errno(StringView string_literal, int code); + static Error from_string_view_or_print_error_and_return_errno(StringView string_literal, int code); #ifndef KERNEL - [[nodiscard]] static Error from_syscall(StringView syscall_name, int rc) + static Error from_syscall(StringView syscall_name, int rc) { return Error(syscall_name, rc); } - [[nodiscard]] static Error from_string_view(StringView string_literal) { return Error(string_literal); } + static Error from_string_view(StringView string_literal) { return Error(string_literal); } template T> static Error from_string_view(T) @@ -54,7 +54,7 @@ public: #endif - [[nodiscard]] static Error copy(Error const& error) + static Error copy(Error const& error) { return Error(error); } @@ -67,7 +67,7 @@ public: // If you need to return a static string based on a dynamic condition (like // picking an error from an array), then prefer `from_string_view` instead. template - [[nodiscard]] ALWAYS_INLINE static Error from_string_literal(char const (&string_literal)[N]) + ALWAYS_INLINE static Error from_string_literal(char const (&string_literal)[N]) { return from_string_view(StringView { string_literal, N - 1 }); }