1ea497e4dSopenharmony_ci/* 2ea497e4dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3ea497e4dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4ea497e4dSopenharmony_ci * you may not use this file except in compliance with the License. 5ea497e4dSopenharmony_ci * You may obtain a copy of the License at 6ea497e4dSopenharmony_ci * 7ea497e4dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8ea497e4dSopenharmony_ci * 9ea497e4dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10ea497e4dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11ea497e4dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12ea497e4dSopenharmony_ci * See the License for the specific language governing permissions and 13ea497e4dSopenharmony_ci * limitations under the License. 14ea497e4dSopenharmony_ci */ 15ea497e4dSopenharmony_ci 16ea497e4dSopenharmony_ci#ifndef IAM_CHECK_H 17ea497e4dSopenharmony_ci#define IAM_CHECK_H 18ea497e4dSopenharmony_ci 19ea497e4dSopenharmony_ci#include "iam_logger.h" 20ea497e4dSopenharmony_ci 21ea497e4dSopenharmony_cinamespace OHOS { 22ea497e4dSopenharmony_cinamespace UserIam { 23ea497e4dSopenharmony_cinamespace Common { 24ea497e4dSopenharmony_ci// these macros are used to check condition that should never fail 25ea497e4dSopenharmony_ci#define IF_FALSE_LOGE_AND_RETURN(cond) \ 26ea497e4dSopenharmony_ci do { \ 27ea497e4dSopenharmony_ci if (!(cond)) { \ 28ea497e4dSopenharmony_ci IAM_LOGE("(" #cond ") check fail, return"); \ 29ea497e4dSopenharmony_ci return; \ 30ea497e4dSopenharmony_ci } \ 31ea497e4dSopenharmony_ci } while (0) 32ea497e4dSopenharmony_ci 33ea497e4dSopenharmony_ci#define IF_FALSE_LOGE_AND_RETURN_VAL(cond, retVal) \ 34ea497e4dSopenharmony_ci do { \ 35ea497e4dSopenharmony_ci if (!(cond)) { \ 36ea497e4dSopenharmony_ci IAM_LOGE("(" #cond ") check fail, return"); \ 37ea497e4dSopenharmony_ci return (retVal); \ 38ea497e4dSopenharmony_ci } \ 39ea497e4dSopenharmony_ci } while (0) 40ea497e4dSopenharmony_ci} // namespace Common 41ea497e4dSopenharmony_ci} // namespace UserIam 42ea497e4dSopenharmony_ci} // namespace OHOS 43ea497e4dSopenharmony_ci 44ea497e4dSopenharmony_ci#endif // IAM_CHECK_H 45