!174 ipc/rpc codex fixed

Merge pull request !174 from liubb_0516/master
This commit is contained in:
openharmony_ci 2022-03-11 02:19:50 +00:00 committed by Gitee
commit 65495a3eb0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 20 additions and 13 deletions

View File

@ -28,7 +28,11 @@ public:
~BrokerCreator() = default;
sptr<IRemoteBroker> operator () (const sptr<IRemoteObject> &object)
{
return static_cast<IRemoteBroker *>(new T(object));
T *proxy = new (std::nothrow) T(object);
if (proxy != nullptr) {
return static_cast<IRemoteBroker *>(proxy);
}
return nullptr;
};
};

View File

@ -17,7 +17,7 @@
void RpcStartTrace(const char *value)
{
void(value);
(void)value;
return;
}

View File

@ -27,7 +27,7 @@
namespace OHOS {
constexpr int SOCKET_DEFAULT_BUFF_SIZE = 4 * 1024;
constexpr int SOCKET_MAX_BUFF_SIZE = 1024 * 1024;
constexpr int SOCKET_BUFF_RESERVED_SIZE = 256;
constexpr uint32_t SOCKET_BUFF_RESERVED_SIZE = 256;
constexpr size_t MAX_RAWDATA_SIZE = 128 * 1024 * 1024; // 128M
constexpr uint32_t SOCKET_BUFF_SIZE_USER_S = 4 * 1024;

View File

@ -103,7 +103,7 @@ int32_t DBinderCallbackStub::ProcessProto(uint32_t code, MessageParcel &data, Me
DBINDER_LOGE("no databus thread and invoker");
return RPC_DATABUS_INVOKER_ERR;
}
uint32_t err = dbinderInvoker->SendRequest(handle_, DBINDER_TRANS_COMMAUTH, authData, authReply, authOption);
int err = dbinderInvoker->SendRequest(handle_, DBINDER_TRANS_COMMAUTH, authData, authReply, authOption);
if (err != ERR_NONE) {
DBINDER_LOGE("send auth info to remote fail");
return BINDER_CALLBACK_AUTHCOMM_ERR;

View File

@ -365,8 +365,8 @@ void IPCObjectProxy::SendObituary()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
MarkObjectDied();
int recipientCount = recipients_.size();
for (int i = 0; i < recipientCount; i++) {
size_t recipientCount = recipients_.size();
for (size_t i = 0; i < recipientCount; i++) {
sptr<DeathRecipient> recipient = recipients_[i];
ZLOGW(LABEL, "%s: handle = %{public}u call OnRemoteDied", __func__, handle_);
if (recipient != nullptr) {

View File

@ -75,8 +75,7 @@ IPCProcessSkeleton::IPCProcessSkeleton()
std::random_device randDevice;
std::default_random_engine baseRand { randDevice() };
std::uniform_int_distribution<> range(1, DBINDER_HANDLE_BASE * DBINDER_HANDLE_RANG);
uint32_t temp = range(baseRand);
randNum_ = static_cast<uint64_t>(temp);
randNum_ = static_cast<uint64_t>(range(baseRand));
#endif
}
@ -143,7 +142,10 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
}
}
auto proxy = new IPCObjectProxy(handle, descriptor);
auto proxy = new (std::nothrow) IPCObjectProxy(handle, descriptor);
if (proxy == nullptr) {
return nullptr;
}
proxy->AttemptAcquire(this); // AttemptAcquire always returns true as life time is extended
remoteObject = reinterpret_cast<IRemoteObject *>(proxy);
if (!AttachObjectInner(remoteObject)) {
@ -316,8 +318,9 @@ uint32_t IPCProcessSkeleton::ConvertChannelID2Int(int64_t databusChannelId)
if (databusChannelId < 0) {
return 0;
}
uint32_t channelType = static_cast<uint32_t>((databusChannelId >> 8) & 0X00000000FF000000ULL);
uint32_t channelID = static_cast<uint32_t>(databusChannelId & 0X0000000000FFFFFFULL);
uint64_t databusChannel = static_cast<uint64_t>(databusChannelId);
uint32_t channelType = static_cast<uint32_t>((databusChannel >> 8) & 0X00000000FF000000ULL);
uint32_t channelID = static_cast<uint32_t>(databusChannel & 0X0000000000FFFFFFULL);
return (channelType | channelID);
}

View File

@ -300,8 +300,8 @@ bool DBinderService::SendEntryToRemote(const sptr<DBinderServiceStub> stub, uint
message->binderObject = stub->GetBinderObject();
message->stub = reinterpret_cast<binder_uintptr_t>(stub.GetRefPtr());
message->deviceIdInfo.afType = DATABBUS_TYPE;
message->pid = IPCSkeleton::GetCallingPid();
message->uid = (uint32_t)IPCSkeleton::GetCallingUid();
message->pid = static_cast<uint32_t>(IPCSkeleton::GetCallingPid());
message->uid = static_cast<uint32_t>(IPCSkeleton::GetCallingUid());
if (memcpy_s(message->deviceIdInfo.fromDeviceId, DEVICEID_LENGTH, localDevID.data(), localDevID.length()) != 0 ||
memcpy_s(message->deviceIdInfo.toDeviceId, DEVICEID_LENGTH, deviceID.data(), deviceID.length()) != 0) {
DBINDER_LOGE("fail to copy memory");