fix:Rectification softbus_err

Signed-off-by: wangwang16 <wangwang16@huawei.com>
This commit is contained in:
wangwang16 2024-10-26 09:58:14 +08:00
parent 2d6f0ec20b
commit 07bc8f2ad1
13 changed files with 31 additions and 34 deletions

View File

@ -41,12 +41,12 @@ int32_t ServerCreateSessionServer(IpcIo *req, IpcIo *reply)
const char *pkgName = (const char*)ReadString(req, &size);
if (pkgName == NULL) {
TRANS_LOGE(TRANS_CTRL, "ServerCreateSessionServer pkgName is null");
return SOFTBUS_ERR;
return SOFTBUS_NO_INIT;
}
const char *sessionName = (const char *)ReadString(req, &size);
if (sessionName == NULL) {
TRANS_LOGE(TRANS_CTRL, "sessionName pkgName is null");
return SOFTBUS_ERR;
return SOFTBUS_NO_INIT;
}
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
@ -71,12 +71,12 @@ int32_t ServerRemoveSessionServer(IpcIo *req, IpcIo *reply)
const char *pkgName = (const char*)ReadString(req, &size);
if (pkgName == NULL) {
TRANS_LOGE(TRANS_CTRL, "ServerRemoveSessionServer pkgName is null");
return SOFTBUS_ERR;
return SOFTBUS_NO_INIT;
}
const char *sessionName = (const char *)ReadString(req, &size);
if (sessionName == NULL) {
TRANS_LOGE(TRANS_CTRL, "ServerRemoveSessionServer sessionName is null");
return SOFTBUS_ERR;
return SOFTBUS_NO_INIT;
}
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
@ -234,7 +234,7 @@ int32_t ServerOpenSession(IpcIo *req, IpcIo *reply)
WriteUint32(reply, sizeof(TransSerializer));
bool value = WriteBuffer(reply, (void *)&transSerializer, sizeof(TransSerializer));
if (!value) {
return SOFTBUS_ERR;
return SOFTBUS_MALLOC_ERR;
}
return ret;
}
@ -244,7 +244,7 @@ int32_t ServerOpenSession(IpcIo *req, IpcIo *reply)
WriteUint32(reply, sizeof(TransSerializer));
bool value = WriteBuffer(reply, (void *)&transSerializer, sizeof(TransSerializer));
if (!value) {
return SOFTBUS_ERR;
return SOFTBUS_MALLOC_ERR;
}
return ret;
}
@ -263,8 +263,8 @@ int32_t ServerOpenAuthSession(IpcIo *req, IpcIo *reply)
ConnectionAddr *addr = (ConnectionAddr *)ReadRawData(req, sizeof(ConnectionAddr));
if (!LnnConvertAddrToOption(addr, &connOpt)) {
TRANS_LOGE(TRANS_CTRL, "LnnConvertAddrToOption fail");
WriteInt32(reply, SOFTBUS_ERR);
return SOFTBUS_ERR;
WriteInt32(reply, SOFTBUS_NO_INIT);
return SOFTBUS_NO_INIT;
}
ret = CheckOpenSessionPremission(sessionName, sessionName);
if (ret != SOFTBUS_OK) {

View File

@ -72,7 +72,7 @@ int32_t SoftBusServer::SoftbusRegisterService(const char *clientPkgName, const s
sptr<IRemoteObject::DeathRecipient> abilityDeath = new (std::nothrow) SoftBusDeathRecipient();
if (abilityDeath == nullptr) {
COMM_LOGE(COMM_SVC, "DeathRecipient object is nullptr");
return SOFTBUS_TRANS_DEATH_RECIPIENT_IS_NULL;
return SOFTBUS_TRANS_DEATH_RECIPIENT_INVALID;
}
bool ret = object->AddDeathRecipient(abilityDeath);
if (!ret) {

View File

@ -35,7 +35,6 @@ typedef struct {
* @param[in] channelId indicates that channel is open.
* @param[in] uuid indicates the pointer to the uuid.
* @param[in] isServer indicates server side or client side.
* @return <b>SOFTBUS_ERR</b> the processing failed after the callback.
* @return <b>SOFTBUS_OK</b> the processing success after the callback.
*/
int (*onChannelOpened)(int32_t channelId, const char *uuid, unsigned char isServer);
@ -104,7 +103,6 @@ int TransSendNetworkingMessage(int32_t channelId, const char *data, uint32_t dat
* this interface is current only called once when the sync info manager.
* @see {@link INetworkingListener}
* @param[in] listener indicates regiestered function callback.
* @return <b>SOFTBUS_ERR</b> Failed to add listener to channel listener manager.
* @return <b>SOFTBUS_OK</b> Success to register channel listener, return other internal errorcodes otherwise.
*/
int TransRegisterNetworkingChannelListener(const char *sessionName, const INetworkingListener *listener);

View File

@ -86,7 +86,7 @@ static void GetProxyChannelInfo(int32_t channelId, const AppInfo *appInfo, bool
static int32_t NotifyNormalChannelOpened(int32_t channelId, const AppInfo *appInfo, bool isServer)
{
ChannelInfo info = {0};
int32_t ret = SOFTBUS_ERR;
int32_t ret;
char buf[NETWORK_ID_BUF_LEN] = {0};
GetProxyChannelInfo(channelId, appInfo, isServer, &info);

View File

@ -560,7 +560,7 @@ static void OpenNetWorkingChannel(int32_t requestId, ITransProxyPipelineCallback
g_manager.channels->cnt -= 1;
SoftBusFree(target);
(void)SoftBusMutexUnlock(&g_manager.channels->lock);
callback->onChannelOpenFailed(requestId, SOFTBUS_ERR);
callback->onChannelOpenFailed(requestId, INVALID_CHANNEL_ID);
return;
}
target->channelId = channelId;

View File

@ -777,7 +777,7 @@ int32_t TransProxyOpenConnChannel(const AppInfo *appInfo, const ConnectOption *c
TRANS_LOGE(TRANS_CTRL, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = SOFTBUS_ERR;
int32_t ret;
ProxyConnInfo conn;
int32_t chanNewId = GenerateChannelId(false);
if (chanNewId <= INVALID_CHANNEL_ID) {

View File

@ -68,7 +68,6 @@ extern "C" {
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
* @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
* @since 1.0
* @version 1.0
@ -84,7 +83,6 @@ int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
* @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
* @since 1.0
* @version 1.0
@ -99,7 +97,6 @@ int32_t GetSessionHandle(int32_t sessionId, int *handle);
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
* @since 1.0
* @version 1.0
*/

View File

@ -369,18 +369,18 @@ enum SoftBusErrNo {
SOFTBUS_TRANS_CREATE_SOCKET_SERVER_FAILED,
SOFTBUS_TRANS_BUSINESSID_COUNT_FAILED,
SOFTBUS_TRANS_ON_CONNECT_REQUEST_IS_NULL,
SOFTBUS_TRANS_ON_SOCKET_OPENED_IS_NULL,
SOFTBUS_TRANS_ON_SOCKET_REQUEST_IS_NULL,
SOFTBUS_TRANS_ON_SOCKET_CLOSED_IS_NULL,
SOFTBUS_TRANS_ON_DATA_RECEIVED_IS_NULL,
SOFTBUS_TRANS_ON_PREDATA_REQUEST_IS_NULL,
SOFTBUS_TRANS_ON_SERVICE_REQUEST_IS_NULL,
SOFTBUS_TRANS_ON_SESSION_REQUEST_IS_NULL,
SOFTBUS_TRANS_ON_SESSION_OPENED_IS_NULL,
SOFTBUS_TRANS_ON_SESSION_CLOSED_IS_NULL,
SOFTBUS_TRANS_ON_SOCKET_OPENED_INVALID,
SOFTBUS_TRANS_ON_SOCKET_REQUEST_INVALID,
SOFTBUS_TRANS_ON_SOCKET_CLOSED_INVALID,
SOFTBUS_TRANS_ON_DATA_RECEIVED_INVALID,
SOFTBUS_TRANS_ON_PREDATA_REQUEST_INVALID,
SOFTBUS_TRANS_ON_SERVICE_REQUEST_INVALID,
SOFTBUS_TRANS_ON_SESSION_REQUEST_INVALID,
SOFTBUS_TRANS_ON_SESSION_OPENED_INVALID,
SOFTBUS_TRANS_ON_SESSION_CLOSED_INVALID,
SOFTBUS_TRANS_CREATE_LISTENER_MODULE_FAILED,
SOFTBUS_TRANS_FILE_SCHEMA_LISTENER_FAILED,
SOFTBUS_TRANS_DEATH_RECIPIENT_IS_NULL,
SOFTBUS_TRANS_DEATH_RECIPIENT_INVALID,
SOFTBUS_TRANS_ADD_DEATH_RECIPIENT_FAILED,
SOFTBUS_TRANS_ON_CHANNEL_REQ_CALLBACK_FAILED,
SOFTBUS_TRANS_ON_SERVICE_REQ_CALLBACK_FAILED,

View File

@ -42,7 +42,7 @@ int32_t ClientOnChannelOpened(IpcIo *data, IpcIo *reply)
if (channel.groupId == NULL || channel.sessionKey == NULL || channel.peerSessionName == NULL ||
channel.peerDeviceId == NULL) {
TRANS_LOGE(TRANS_CTRL, "pointer null error.");
return SOFTBUS_ERR;
return SOFTBUS_NO_INIT;
}
if (channel.channelType == CHANNEL_TYPE_TCP_DIRECT) {
channel.myIp = (char *)ReadString(data, &size);
@ -57,7 +57,7 @@ int32_t ClientOnChannelOpened(IpcIo *data, IpcIo *reply)
if (channel.isServer) {
int32_t udpPort = TransOnChannelOpened(sessionName, &channel);
WriteInt32(reply, udpPort);
return SOFTBUS_ERR;
return SOFTBUS_TRANS_CHANNEL_OPEN_FAILED;
}
ReadInt32(data, &(channel.peerPort));
channel.peerIp = (char *)ReadString(data, &size);

View File

@ -140,7 +140,7 @@ static int32_t ServerProxyInit(void)
OHOS::sptr<OHOS::IRemoteObject::DeathRecipient>(new (std::nothrow) OHOS::SoftBusClientDeathRecipient());
if (g_clientDeath == nullptr) {
COMM_LOGE(COMM_SDK, "DeathRecipient object is nullptr");
return SOFTBUS_TRANS_DEATH_RECIPIENT_IS_NULL;
return SOFTBUS_TRANS_DEATH_RECIPIENT_INVALID;
}
if (!g_serverProxy->AddDeathRecipient(g_clientDeath)) {
COMM_LOGE(COMM_SDK, "AddDeathRecipient failed");

View File

@ -159,7 +159,9 @@ int32_t ClientAddNewSession(const char *sessionName, SessionInfo *session);
/**
* @brief Add session.
* @return if session already added, return SOFTBUS_TRANS_SESSION_REPEATED, else return SOFTBUS_OK or SOFTBUS_ERR.
* @return if the operation is successful, return SOFTBUS_OK.
* @return if session already added, return SOFTBUS_TRANS_SESSION_REPEATED.
* @return return other error codes.
*/
int32_t ClientAddSession(const SessionParam *param, int32_t *sessionId, SessionEnableStatus *isEnabled);

View File

@ -497,8 +497,8 @@ HWTEST_F(LNNTransLaneMockTest, ALLOC_RAW_LANE_TEST_001, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
ret = UpdateReqListLaneId(LANE_REQ_ID, NEW_LANE_REQ_ID);
EXPECT_EQ(ret, SOFTBUS_LOCK_ERR);
NotifyFreeLaneResult(LANE_REQ_ID, SOFTBUS_ERR);
NotifyFreeLaneResult(NEW_LANE_REQ_ID, SOFTBUS_ERR);
NotifyFreeLaneResult(LANE_REQ_ID, SOFTBUS_LOCK_ERR);
NotifyFreeLaneResult(NEW_LANE_REQ_ID, SOFTBUS_LOCK_ERR);
transObj->deinit();
}
} // namespace OHOS

View File

@ -66,7 +66,7 @@ int32_t LnnTransInterfaceMock::ActionOfTransRegister(const INetworkingListener *
{
if (listener == NULL) {
LNN_LOGE(LNN_TEST, "listener is invalid para");
return SOFTBUS_ERR;
return SOFTBUS_INVALID_PARAM;
}
g_networkListener = listener;
return SOFTBUS_OK;