• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include "ipc_internal_utils.h"
17 
18 #include "ipc_debug.h"
19 #include "ipc_inner_object.h"
20 #include "log_tags.h"
21 
22 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, OHOS::LOG_ID_IPC_CAPI, "IPCInternalUtils" };
23 
IsIPCParcelValid(const OHIPCParcel * parcel,const char * promot)24 bool IsIPCParcelValid(const OHIPCParcel *parcel, const char *promot)
25 {
26     if (parcel == nullptr || parcel->msgParcel == nullptr) {
27         ZLOGE(LOG_LABEL, "%{public}s: parcel is null!", promot);
28         return false;
29     }
30     return true;
31 }
32 
IsIPCRemoteProxyValid(const OHIPCRemoteProxy * proxy,const char * promot)33 bool IsIPCRemoteProxyValid(const OHIPCRemoteProxy *proxy, const char *promot)
34 {
35     if (proxy == nullptr || proxy->remote == nullptr) {
36         ZLOGE(LOG_LABEL, "%{public}s: proxy object is invalid!", promot);
37         return false;
38     }
39     return true;
40 }
41 
IsMemoryParamsValid(char ** str,int32_t * len,OH_IPC_MemAllocator allocator,const char * promot)42 bool IsMemoryParamsValid(char **str, int32_t *len, OH_IPC_MemAllocator allocator, const char *promot)
43 {
44     if (str == nullptr || len == nullptr || allocator == nullptr) {
45         ZLOGE(LOG_LABEL, "%{public}s: mem param is invalid!", promot);
46         return false;
47     }
48     return true;
49 }
50