!123 Fix code-review warning.

Merge pull request !123 from zhufenghao/master
This commit is contained in:
openharmony_ci 2021-07-30 09:22:06 +00:00 committed by Gitee
commit c80b82441f
9 changed files with 34 additions and 13 deletions

View File

@ -148,15 +148,12 @@ int SoftBusWriteFile(const char *fileName, const char *writeBuf, int len)
return SOFTBUS_FILE_ERR;
}
int ret;
int fd;
fd = open(fileName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
int fd = open(fileName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (fd < 0) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "WriteDeviceId open file fail");
return SOFTBUS_FILE_ERR;
}
ret = write(fd, writeBuf, len);
int ret = write(fd, writeBuf, len);
if (ret != len) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "WriteDeviceId write fail");
close(fd);

View File

@ -197,8 +197,8 @@ static int StartNewLooperThread(SoftBusLooper *looper)
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "create DeathProcTask failed");
return -1;
}
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "loop thread creating %s id %d", looper->context->name, (int)tid);
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "loop thread creating %s id %d", looper->context->name,
(int)(uintptr_t)tid);
return 0;
}

View File

@ -240,6 +240,7 @@ static int32_t OnEvent(ListenerModule module, int32_t fd, uint32_t events)
listener->onConnectEvent(events, cfd, ip);
} else {
SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_ERROR, "Please set onConnectEvent callback");
close(cfd);
}
} else {
if (listener->onDataEvent != NULL) {

View File

@ -233,6 +233,7 @@ static int32_t CheckThreadPoolAddReady(ThreadPool *pool, int32_t (*callbackFunct
pthread_mutex_unlock(&(pool->mutex));
return SOFTBUS_ERR;
}
pthread_mutex_unlock(&(pool->mutex));
return SOFTBUS_OK;
}

View File

@ -25,6 +25,8 @@
#include "softbus_log.h"
#include "softbus_os_interface.h"
#define WAIT_SERVER_READY_INTERVAL_COUNT 50
static IClientProxy *g_serverProxy = NULL;
int32_t DiscServerProxyInit(void)
@ -35,10 +37,16 @@ int32_t DiscServerProxyInit(void)
}
IUnknown *iUnknown = NULL;
int ret;
int32_t ret;
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_INFO, "disc start get server proxy");
int32_t proxyInitCount = 0;
while (g_serverProxy == NULL) {
proxyInitCount++;
if (proxyInitCount == WAIT_SERVER_READY_INTERVAL_COUNT) {
proxyInitCount = 0;
break;
}
iUnknown = SAMGR_GetInstance()->GetDefaultFeatureApi(SOFTBUS_SERVICE);
if (iUnknown == NULL) {
SoftBusSleepMs(WAIT_SERVER_READY_INTERVAL);

View File

@ -111,7 +111,6 @@ int RegisterEventCallback(enum SoftBusEvent event, EventCallback cb, void *userD
ListAdd(&g_observerList->list, &observer->node);
g_observerList->cnt++;
(void)pthread_mutex_unlock(&g_observerList->lock);
return SOFTBUS_OK;
}

View File

@ -58,7 +58,11 @@ void ClientOnChannelOpened(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
channel.peerPort = IpcIoPopInt32(reply);
channel.peerIp = IpcIoPopString(reply, &size);
}
(void)TransOnChannelOpened(sessionName, &channel);
int ret = TransOnChannelOpened(sessionName, &channel);
if (ret < 0) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "TransOnChannelOpened fail, error code: %d.", ret);
}
FreeBuffer(ctx, ipcMsg);
}

View File

@ -25,6 +25,8 @@
#include "softbus_mem_interface.h"
#include "softbus_os_interface.h"
#define WAIT_SERVER_READY_INTERVAL_COUNT 50
static IClientProxy *g_serverProxy = NULL;
static int ProxyCallback(IOwner owner, int code, IpcIo *reply)
@ -47,10 +49,16 @@ int32_t TransServerProxyInit(void)
}
IUnknown *iUnknown = NULL;
int ret;
int32_t ret;
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "trans start get server proxy");
int32_t proxyInitCount = 0;
while (g_serverProxy == NULL) {
proxyInitCount++;
if (proxyInitCount == WAIT_SERVER_READY_INTERVAL_COUNT) {
proxyInitCount = 0;
break;
}
iUnknown = SAMGR_GetInstance()->GetDefaultFeatureApi(SOFTBUS_SERVICE);
if (iUnknown == NULL) {
SoftBusSleepMs(WAIT_SERVER_READY_INTERVAL);

View File

@ -215,7 +215,6 @@ int32_t TransAddDataBufNode(int32_t channelId, int32_t fd)
ListAdd(&g_tcpDataList->list, &node->node);
g_tcpDataList->cnt++;
pthread_mutex_unlock(&g_tcpDataList->lock);
return SOFTBUS_OK;
}
@ -304,8 +303,12 @@ static int32_t TransTdcProcessData(int32_t channelId)
return SOFTBUS_ERR;
}
pthread_mutex_unlock(&g_tcpDataList->lock);
pthread_mutex_lock(&g_tcpDataList->lock);
ClientDataBuf *node = TransGetDataBufNodeById(channelId);
if (node == NULL) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "node is null.");
return SOFTBUS_ERR;
}
TcpDataPacketHead *pktHead = (TcpDataPacketHead *)(node->data);
int32_t seqNum = pktHead->seq;
int32_t flag = pktHead->flags;