From 8150bda151e376048e4a8a38d861fca43406595e Mon Sep 17 00:00:00 2001 From: TronZhang Date: Thu, 4 Aug 2022 14:50:29 +0800 Subject: [PATCH] fix error log for nullcheck --- mindspore/core/utils/log_adapter.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mindspore/core/utils/log_adapter.h b/mindspore/core/utils/log_adapter.h index 2bc03f3f3cb..911b4c96182 100644 --- a/mindspore/core/utils/log_adapter.h +++ b/mindspore/core/utils/log_adapter.h @@ -311,25 +311,25 @@ inline bool IS_OUTPUT_ON(enum MsLogLevel level) noexcept(true) { #define MS_EXCEPTION(type) MSLOG_THROW(type) } // namespace mindspore -#define MS_EXCEPTION_IF_NULL(ptr) \ +#define MS_EXCEPTION_IF_NULL(ptr) \ + do { \ + if ((ptr) == nullptr) { \ + MS_LOG(EXCEPTION) << "The pointer[" << #ptr << "] is null."; \ + } \ + } while (0) + +#define MS_EXCEPTION_IF_CHECK_FAIL(condition, error_info) \ do { \ - if ((ptr) == nullptr) { \ - MS_LOG(EXCEPTION) << ": The pointer[" << #ptr << "] is null."; \ + if (!(condition)) { \ + MS_LOG(EXCEPTION) << "Failure info [" << (error_info) << "]."; \ } \ } while (0) -#define MS_EXCEPTION_IF_CHECK_FAIL(condition, error_info) \ - do { \ - if (!(condition)) { \ - MS_LOG(EXCEPTION) << ": Failure info [" << (error_info) << "]."; \ - } \ - } while (0) - -#define MS_EXCEPTION_IF_ZERO(name, value) \ - do { \ - if ((value) == 0) { \ - MS_LOG(EXCEPTION) << ": The " << (name) << " is zero."; \ - } \ +#define MS_EXCEPTION_IF_ZERO(name, value) \ + do { \ + if ((value) == 0) { \ + MS_LOG(EXCEPTION) << "The " << (name) << " is zero."; \ + } \ } while (0) #define MS_ERROR_IF_NULL(ptr) \