Adding macros to enchance return and failure checks.
@@ -1138,6 +1138,22 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
return false; \
} \
} while (0, 0)
+#define RETURN_IF(condition) \
+ do { \
+ if (condition) { \
+ return; \
+ } \
+ } while (0, 0)
+#define RETURN_RESULT_IF(condition, result) \
+ do { \
+ if (condition) { \
+ return result; \
+ } \
+ } while (0, 0)
+
+#define RETURN_FALSE_IF_FAILED(hr) RETURN_FALSE_IF(FAILED(hr));
+#define RETURN_RESULT_IF_NULL(ptr, result) RETURN_RESULT_IF((ptr == nullptr), result);
+#define RETURN_RESULT_IF_FAILED(hr, result) RETURN_RESULT_IF(FAILED(hr), result)
//*****************************************************************************
// Macros for logging failures (ignore or pass-through)
@@ -1932,8 +1948,7 @@ private:
}
template <typename param_t>
- RefAndObject(param_t&& param1)
- : m_refCount(1), m_object(wistd::forward<param_t>(param1)) {
+ RefAndObject(param_t&& param1) : m_refCount(1), m_object(wistd::forward<param_t>(param1)) {
}
};
@@ -5082,8 +5097,7 @@ void _rethrowNormalizedCaughtExceptionObjC(__R_FN_PARAMS_FULL, _In_opt_ PCWSTR m
}
// Misspelling is intentional
-WI_HEADER_INITITALIZATION_FUNCTION(InitializeObjCExceptions,
- [] {
+WI_HEADER_INITITALIZATION_FUNCTION(InitializeObjCExceptions, [] {
g_resultFromUncaughtExceptionObjC = _resultFromUncaughtExceptionObjC;
g_rethrowAsNSException = _rethrowAsNSException;
g_objcThrowFailureInfo = _objcThrowFailureInfo;
