• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 
16 #ifndef DEVICESTATUS_DEFINE_H
17 #define DEVICESTATUS_DEFINE_H
18 
19 #include "devicestatus_errors.h"
20 #include "fi_log.h"
21 #include "include/util.h"
22 
23 namespace OHOS {
24 namespace Msdp {
25 namespace DeviceStatus {
26 #define FI_PKG_NAME "ohos.msdp.fusioninteraction"
27 #define COOPERATE_PERMISSION "ohos.permission.COOPERATE_MANAGER"
28 
29 #ifndef RET_OK
30     #define RET_OK (0)
31 #endif
32 
33 #ifndef RET_ERR
34     #define RET_ERR (-1)
35 #endif
36 
37 #define CHKPL(cond) \
38     do { \
39         if ((cond) == nullptr) { \
40             FI_HILOGW("CHKPL(%{public}s) is null, do nothing", #cond); \
41         } \
42     } while (0)
43 
44 #define CHKPV(cond) \
45     do { \
46         if ((cond) == nullptr) { \
47             FI_HILOGE("CHKPV(%{public}s) is null", #cond); \
48             return; \
49         } \
50     } while (0)
51 
52 #define CHKPF(cond) \
53     do { \
54         if ((cond) == nullptr) { \
55             FI_HILOGE("CHKPF(%{public}s) is null", #cond); \
56             return false; \
57         } \
58     } while (0)
59 
60 #define CHKPS(cond) \
61     do { \
62         if ((cond) == nullptr) { \
63             FI_HILOGE("CHKPS(%{public}s) is null", #cond); \
64             return {}; \
65         } \
66     } while (0)
67 
68 #define CHKPC(cond) \
69     { \
70         if ((cond) == nullptr) { \
71             FI_HILOGW("CHKPC(%{public}s) is null, skip then continue", #cond); \
72             continue; \
73         } \
74     }
75 
76 #define CHKPB(cond) \
77     { \
78         if ((cond) == nullptr) { \
79             FI_HILOGW("CHKPB(%{public}s) is null, skip then break", #cond); \
80             break; \
81         } \
82     }
83 
84 #define CHKPR(cond, r) \
85     do { \
86         if ((cond) == nullptr) { \
87             FI_HILOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \
88             return r; \
89         } \
90     } while (0)
91 
92 #define CHKPP(cond) \
93     do { \
94         if ((cond) == nullptr) { \
95             FI_HILOGE("CHKPP(%{public}s) is null, return value is null", #cond); \
96             return nullptr; \
97         } \
98     } while (0)
99 
100 #define CHKPO(cond) \
101     do { \
102         if ((cond) == nullptr) { \
103             FI_HILOGW("%{public}s, (%{public}d), CHKPO(%{public}s) is null, return object is null", \
104                 __FILE__, __LINE__, #cond); \
105             return {}; \
106         } \
107     } while (0)
108 
109 #define CHK_PID_AND_TID() \
110     do { \
111         FI_HILOGD("%{public}s, (%{public}d), pid:%{public}d, threadId:%{public}" PRIu64, \
112             __FILE__, __LINE__, GetPid(), GetThisThreadId()); \
113     } while (0)
114 } // namespace DeviceStatus
115 } // namespace Msdp
116 } // namespace OHOS
117 #endif // DEVICESTATUS_DEFINE_H
118