From c140b67be328ad1e90b03c59bd61c4ce76257381 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 17 Mar 2023 16:10:56 +0000 Subject: [PATCH] AK: Verify that we don't call Error::from_errno(0) We shouldn't ever make an Error if there wasn't actually an error. :^) --- AK/Error.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AK/Error.h b/AK/Error.h index 1405f07a3f..33ee2d0924 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -24,7 +24,11 @@ public: ALWAYS_INLINE Error(Error&&) = default; ALWAYS_INLINE Error& operator=(Error&&) = default; - [[nodiscard]] static Error from_errno(int code) { return Error(code); } + [[nodiscard]] static Error from_errno(int code) + { + VERIFY(code != 0); + return Error(code); + } // NOTE: For calling this method from within kernel code, we will simply print // the error message and return the errno code.