From 8e0f6b0319ff8646699763c982cf3eebb5f66673 Mon Sep 17 00:00:00 2001 From: DH Date: Fri, 10 Nov 2023 20:55:28 +0300 Subject: [PATCH] [orbis-kernel] add ORBIS_RET_ON_ERROR macro utility --- orbis-kernel/include/orbis/error/ErrorCode.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/orbis-kernel/include/orbis/error/ErrorCode.hpp b/orbis-kernel/include/orbis/error/ErrorCode.hpp index d5254bc45..04be1bfa0 100644 --- a/orbis-kernel/include/orbis/error/ErrorCode.hpp +++ b/orbis-kernel/include/orbis/error/ErrorCode.hpp @@ -109,3 +109,10 @@ enum class ErrorCode : int { CAPMODE = 94, // Not permitted in capability mode }; } // namespace orbis + +#define ORBIS_RET_ON_ERROR(...) \ + do { \ + if (auto errc___ = (__VA_ARGS__); errc___ != ::orbis::ErrorCode{}) { \ + return errc___; \ + } \ + } while (false)