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. :^)
This commit is contained in:
Sam Atkins 2023-03-17 16:10:56 +00:00 committed by Andrew Kaster
parent 6bcde0dcf4
commit c140b67be3
Notes: sideshowbarker 2024-07-17 08:13:43 +09:00

View file

@ -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.