Skip to content

Commit

Permalink
Some improvements to RETURN_RESULT_* macros (#1862)
Browse files Browse the repository at this point in the history
* Some improvements to RETURN_RESULT_* macros

* some nit picking
  • Loading branch information
msft-Jeyaram authored Jan 28, 2017
1 parent cd24b4c commit 2b659f3
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions Frameworks/include/wil/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,27 +1144,16 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
return; \
} \
} while (0, 0)

#define RETURN_RESULT_IF_NULL(input, result) \
do { \
if (!input) { \
return result; \
} \
#define RETURN_RESULT_IF(condition, result) \
do { \
if (condition) { \
return result; \
} \
} while (0, 0)

#define RETURN_RESULT_IF_FAILED(input, result) \
do { \
if (FAILED(input)) { \
return result; \
} \
} while (0, 0)
#define RETURN_RESULT_IF(input, result) \
do { \
if (FAILED(input)) { \
return result; \
} \
} while (0, 0)
#define RETURN_FALSE_IF_FAILED(input) RETURN_FALSE_IF(FAILED(input));
#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)
//*****************************************************************************
Expand Down

0 comments on commit 2b659f3

Please sign in to comment.