1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef FSCRYPT_LOG 16 #define FSCRYPT_LOG 17 18 #include <errno.h> 19 20 #include "init_log.h" 21 22 #define FSCRYPT_LOG_FILE "fscrypt.log" 23 #define FSCRYPT_LABEL "FSCRYPT" 24 #define FSCRYPT_LOGI(fmt, ...) INIT_LOGI(fmt, ##__VA_ARGS__) 25 #define FSCRYPT_LOGE(fmt, ...) INIT_LOGE(fmt, ##__VA_ARGS__) 26 #define FSCRYPT_LOGV(fmt, ...) INIT_LOGV(fmt, ##__VA_ARGS__) 27 28 #define FSCRYPT_ERROR_CHECK(ret, statement, format, ...) \ 29 do { \ 30 if (!(ret)) { \ 31 FSCRYPT_LOGE(format, ##__VA_ARGS__); \ 32 statement; \ 33 } \ 34 } while (0) 35 36 #define FSCRYPT_CHECK(ret, statement) \ 37 do { \ 38 if (!(ret)) { \ 39 statement; \ 40 } \ 41 } while (0) 42 43 #define FSCRYPT_CHECK_RETURN_VALUE(ret, result) \ 44 do { \ 45 if (!(ret)) { \ 46 return result; \ 47 } \ 48 } while (0) 49 50 #endif