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