fix: clear code warnings of master

Signed-off-by: guodongqi <guodongqi2@huawei.com>
This commit is contained in:
guodongqi
2022-03-10 15:47:55 +08:00
parent 502837e8e1
commit 2b1559bd07
7 changed files with 39 additions and 39 deletions
@@ -27,18 +27,18 @@ int32_t HdfLoadDriverByServiceName(const char *serviceName)
if (data == NULL) { if (data == NULL) {
HDF_LOGE("failed to obtain sbuf data"); HDF_LOGE("failed to obtain sbuf data");
ret = HDF_DEV_ERR_NO_MEMORY; ret = HDF_DEV_ERR_NO_MEMORY;
goto out; goto OUT;
} }
if (!HdfSbufWriteString(data, serviceName)) { if (!HdfSbufWriteString(data, serviceName)) {
HDF_LOGE("failed to write sbuf"); HDF_LOGE("failed to write sbuf");
ret = HDF_FAILURE; ret = HDF_FAILURE;
goto out; goto OUT;
} }
ret = ioService->dispatcher->Dispatch(&ioService->object, DEVMGR_LOAD_SERVICE, data, NULL); ret = ioService->dispatcher->Dispatch(&ioService->object, DEVMGR_LOAD_SERVICE, data, NULL);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
HDF_LOGE("failed to load khdf driver %s", serviceName); HDF_LOGE("failed to load khdf driver %s", serviceName);
} }
out: OUT:
HdfIoServiceRecycle(ioService); HdfIoServiceRecycle(ioService);
HdfSbufRecycle(data); HdfSbufRecycle(data);
return ret; return ret;
@@ -61,18 +61,18 @@ int32_t HdfGetServiceNameByDeviceClass(DeviceClass deviceClass, struct HdfSBuf *
if (data == NULL) { if (data == NULL) {
HDF_LOGE("failed to obtain sbuf data"); HDF_LOGE("failed to obtain sbuf data");
ret = HDF_DEV_ERR_NO_MEMORY; ret = HDF_DEV_ERR_NO_MEMORY;
goto out; goto OUT;
} }
if (!HdfSbufWriteInt32(data, deviceClass)) { if (!HdfSbufWriteInt32(data, deviceClass)) {
HDF_LOGE("failed to write sbuf"); HDF_LOGE("failed to write sbuf");
ret = HDF_FAILURE; ret = HDF_FAILURE;
goto out; goto OUT;
} }
ret = ioService->dispatcher->Dispatch(&ioService->object, DEVMGR_GET_SERVICE, data, reply); ret = ioService->dispatcher->Dispatch(&ioService->object, DEVMGR_GET_SERVICE, data, reply);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
HDF_LOGE("failed to query service by class"); HDF_LOGE("failed to query service by class");
} }
out: OUT:
HdfIoServiceRecycle(ioService); HdfIoServiceRecycle(ioService);
HdfSbufRecycle(data); HdfSbufRecycle(data);
return ret; return ret;
+16 -16
View File
@@ -148,7 +148,7 @@ static int32_t HdfDevEventReadAndDispatch(struct HdfDevListenerThread *thread, i
if (adapter == NULL) { if (adapter == NULL) {
HDF_LOGI("%s: invalid adapter", __func__); HDF_LOGI("%s: invalid adapter", __func__);
OsalMSleep(1); // yield to sync adapter list OsalMSleep(1); // yield to sync adapter list
goto finish; goto FINISH;
} }
while (true) { while (true) {
@@ -170,12 +170,12 @@ static int32_t HdfDevEventReadAndDispatch(struct HdfDevListenerThread *thread, i
HDF_LOGE("%s:ioctl failed, errno=%d", __func__, ret); HDF_LOGE("%s:ioctl failed, errno=%d", __func__, ret);
} }
goto finish; goto FINISH;
} }
ret = HdfDevEventDispatchLocked(thread, adapter, &bwr); ret = HdfDevEventDispatchLocked(thread, adapter, &bwr);
finish: FINISH:
OsalMemFree((void *)(uintptr_t)bwr.readBuffer); OsalMemFree((void *)(uintptr_t)bwr.readBuffer);
OsalMutexUnlock(&thread->mutex); OsalMutexUnlock(&thread->mutex);
return ret; return ret;
@@ -228,7 +228,7 @@ static int32_t HdfDevEventListenTask(void *para)
pollCount = AssignPfds(thread, &pfds, &pfdSize); pollCount = AssignPfds(thread, &pfds, &pfdSize);
} }
if (pollCount <= 0) { if (pollCount <= 0) {
goto exit; goto EXIT;
} }
int32_t pollSize = poll(pfds, pollCount, -1); int32_t pollSize = poll(pfds, pollCount, -1);
if (pollSize <= 0) { if (pollSize <= 0) {
@@ -242,17 +242,17 @@ static int32_t HdfDevEventListenTask(void *para)
} }
if ((((uint32_t)pfds[i].revents) & POLLIN) && if ((((uint32_t)pfds[i].revents) & POLLIN) &&
HdfDevEventReadAndDispatch(thread, pfds[i].fd) != HDF_SUCCESS) { HdfDevEventReadAndDispatch(thread, pfds[i].fd) != HDF_SUCCESS) {
goto exit; goto EXIT;
} else if (((uint32_t)pfds[i].revents) & POLLHUP) { } else if (((uint32_t)pfds[i].revents) & POLLHUP) {
HDF_LOGI("event listener task received exit event"); HDF_LOGI("event listener task received exit event");
goto exit; goto EXIT;
} else if (((uint32_t)pfds[i].revents) & POLLNVAL) { } else if (((uint32_t)pfds[i].revents) & POLLNVAL) {
OsalMSleep(1); // polled closed fd, yield to sync OsalMSleep(1); // polled closed fd, yield to sync
} }
} }
} }
exit: EXIT:
HDF_LOGI("event listener task exit"); HDF_LOGI("event listener task exit");
thread->status = LISTENER_EXITED; thread->status = LISTENER_EXITED;
@@ -713,30 +713,30 @@ struct HdfIoService *HdfIoServiceAdapterObtain(const char *serviceName)
realPath = OsalMemCalloc(PATH_MAX); realPath = OsalMemCalloc(PATH_MAX);
if (devNodePath == NULL || realPath == NULL) { if (devNodePath == NULL || realPath == NULL) {
HDF_LOGE("%s: out of memory", __func__); HDF_LOGE("%s: out of memory", __func__);
goto out; goto OUT;
} }
if (sprintf_s(devNodePath, PATH_MAX - 1, "%s%s", devPath, serviceName) < 0) { if (sprintf_s(devNodePath, PATH_MAX - 1, "%s%s", devPath, serviceName) < 0) {
HDF_LOGE("Failed to get the node path"); HDF_LOGE("Failed to get the node path");
goto out; goto OUT;
} }
if (realpath(devNodePath, realPath) == NULL && if (realpath(devNodePath, realPath) == NULL &&
TrytoLoadIoService(serviceName, devNodePath, realPath) != HDF_SUCCESS) { TrytoLoadIoService(serviceName, devNodePath, realPath) != HDF_SUCCESS) {
goto out; goto OUT;
} }
adapter = (struct HdfSyscallAdapter *)OsalMemCalloc(sizeof(struct HdfSyscallAdapter)); adapter = (struct HdfSyscallAdapter *)OsalMemCalloc(sizeof(struct HdfSyscallAdapter));
if (adapter == NULL) { if (adapter == NULL) {
HDF_LOGE("Failed to allocate SyscallAdapter"); HDF_LOGE("Failed to allocate SyscallAdapter");
goto out; goto OUT;
} }
DListHeadInit(&adapter->listenerList); DListHeadInit(&adapter->listenerList);
if (OsalMutexInit(&adapter->mutex)) { if (OsalMutexInit(&adapter->mutex)) {
HDF_LOGE("%s: Failed to create mutex", __func__); HDF_LOGE("%s: Failed to create mutex", __func__);
OsalMemFree(adapter); OsalMemFree(adapter);
goto out; goto OUT;
} }
adapter->fd = open(realPath, O_RDWR); adapter->fd = open(realPath, O_RDWR);
@@ -744,14 +744,14 @@ struct HdfIoService *HdfIoServiceAdapterObtain(const char *serviceName)
HDF_LOGE("Open file node %{public}s failed, (%d)%{public}s", realPath, errno, strerror(errno)); HDF_LOGE("Open file node %{public}s failed, (%d)%{public}s", realPath, errno, strerror(errno));
OsalMutexDestroy(&adapter->mutex); OsalMutexDestroy(&adapter->mutex);
OsalMemFree(adapter); OsalMemFree(adapter);
goto out; goto OUT;
} }
ioService = &adapter->super; ioService = &adapter->super;
static struct HdfIoDispatcher dispatch = { static struct HdfIoDispatcher dispatch = {
.Dispatch = HdfSyscallAdapterDispatch, .Dispatch = HdfSyscallAdapterDispatch,
}; };
ioService->dispatcher = &dispatch; ioService->dispatcher = &dispatch;
out: OUT:
OsalMemFree(devNodePath); OsalMemFree(devNodePath);
OsalMemFree(realPath); OsalMemFree(realPath);
return ioService; return ioService;
@@ -938,7 +938,7 @@ int32_t HdfIoServiceGroupRegisterListener(struct HdfIoServiceGroup *group, struc
if (it == listener) { if (it == listener) {
HDF_LOGE("Failed to add group listener, repeated registration"); HDF_LOGE("Failed to add group listener, repeated registration");
ret = HDF_ERR_INVALID_PARAM; ret = HDF_ERR_INVALID_PARAM;
goto finish; goto FINISH;
} }
} }
DListInsertTail(&listener->listNode, &adapterGroup->listenerList); DListInsertTail(&listener->listNode, &adapterGroup->listenerList);
@@ -949,7 +949,7 @@ int32_t HdfIoServiceGroupRegisterListener(struct HdfIoServiceGroup *group, struc
} }
} }
finish: FINISH:
OsalMutexUnlock(&listenerThread->mutex); OsalMutexUnlock(&listenerThread->mutex);
OsalMutexUnlock(&adapterGroup->mutex); OsalMutexUnlock(&adapterGroup->mutex);
return ret; return ret;
+3 -3
View File
@@ -84,7 +84,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice
driver = driverLoader->GetDriver(deviceInfo->moduleName); driver = driverLoader->GetDriver(deviceInfo->moduleName);
if (driver == NULL) { if (driver == NULL) {
ret = HDF_DEV_ERR_NODATA; ret = HDF_DEV_ERR_NODATA;
goto error; goto ERROR;
} }
devNode = HdfDeviceNodeNewInstance(deviceInfo, driver); devNode = HdfDeviceNodeNewInstance(deviceInfo, driver);
@@ -99,11 +99,11 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice
ret = device->super.Attach(&device->super, devNode); ret = device->super.Attach(&device->super, devNode);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
HdfDeviceNodeFreeInstance(devNode); HdfDeviceNodeFreeInstance(devNode);
goto error; goto ERROR;
} }
return HDF_SUCCESS; return HDF_SUCCESS;
error: ERROR:
if (DListIsEmpty(&device->devNodes)) { if (DListIsEmpty(&device->devNodes)) {
DevHostServiceFreeDevice(hostService, device); DevHostServiceFreeDevice(hostService, device);
} }
@@ -208,13 +208,13 @@ HWTEST_F(CDataTest, CDataTest_014, TestSize.Level1)
ssize_t readSize = read(fd, recvMsg, sizeof(recvMsg)); ssize_t readSize = read(fd, recvMsg, sizeof(recvMsg));
if (readSize < 0) { if (readSize < 0) {
printf("read failed\n"); printf("read failed\n");
goto finished; goto FINISHED;
} else { } else {
printf("read size:%d\n", readSize); printf("read size:%d\n", readSize);
} }
printf("recvMsg:%s", recvMsg); printf("recvMsg:%s", recvMsg);
finished: FINISHED:
close(fd); close(fd);
} }
+8 -8
View File
@@ -711,22 +711,22 @@ String& String::operator+=(const char* other)
String newString(newSize); String newString(newSize);
if (newString.string_ == nullptr) { if (newString.string_ == nullptr) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed.", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed.", string_);
goto finished; goto FINISHED;
} }
if (string_ != nullptr && thisSize > 0) { if (string_ != nullptr && thisSize > 0) {
if (memcpy_s(newString.string_, newSize + 1, string_, thisSize) != EOK) { if (memcpy_s(newString.string_, newSize + 1, string_, thisSize) != EOK) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 2", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 2", string_);
goto finished; goto FINISHED;
} }
} }
if (strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other) != EOK) { if (strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other) != EOK) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed.", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed.", string_);
goto finished; goto FINISHED;
} }
finished: FINISHED:
SharedData::Release(string_); SharedData::Release(string_);
SharedData::AddRef(newString.string_); SharedData::AddRef(newString.string_);
string_ = newString.string_; string_ = newString.string_;
@@ -744,22 +744,22 @@ String& String::operator+=(const String& other)
String newString(newSize); String newString(newSize);
if (newString.string_ == nullptr) { if (newString.string_ == nullptr) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 1", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 1", string_);
goto finished; goto FINISHED;
} }
if (string_ != nullptr && thisSize > 0) { if (string_ != nullptr && thisSize > 0) {
if (memcpy_s(newString.string_, newSize + 1, string_, thisSize) != EOK) { if (memcpy_s(newString.string_, newSize + 1, string_, thisSize) != EOK) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 2", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 2", string_);
goto finished; goto FINISHED;
} }
} }
if (strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other.string_) != EOK) { if (strcpy_s(newString.string_ + thisSize, newSize + 1 - thisSize, other.string_) != EOK) {
Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 3", string_); Logger::E(String::TAG, "The operator+= of \"%s\" is failed. 3", string_);
goto finished; goto FINISHED;
} }
finished: FINISHED:
SharedData::Release(string_); SharedData::Release(string_);
SharedData::AddRef(newString.string_); SharedData::AddRef(newString.string_);
string_ = newString.string_; string_ = newString.string_;
+2 -2
View File
@@ -37,7 +37,7 @@ void HdfOrderedListOffer(struct HdfOrderedList *list, struct HdfOrderedListEntit
OsalMutexLock(&list->mutex); OsalMutexLock(&list->mutex);
if (HdfSListIsEmpty(&list->head)) { if (HdfSListIsEmpty(&list->head)) {
HdfSListAdd(&list->head, &newEntity->node); HdfSListAdd(&list->head, &newEntity->node);
goto finished; goto FINISHED;
} }
HdfSListIteratorInit(&it, &list->head); HdfSListIteratorInit(&it, &list->head);
while (HdfSListIteratorHasNext(&it)) { while (HdfSListIteratorHasNext(&it)) {
@@ -47,7 +47,7 @@ void HdfOrderedListOffer(struct HdfOrderedList *list, struct HdfOrderedListEntit
break; break;
} }
} }
finished: FINISHED:
OsalMutexUnlock(&list->mutex); OsalMutexUnlock(&list->mutex);
OsalSemPost(&list->sem); OsalSemPost(&list->sem);
} }
+2 -2
View File
@@ -44,12 +44,12 @@ void HdfMessageQueueEnqueue(
struct HdfMessage *next = (struct HdfMessage *)HdfSListIteratorNext(&it); struct HdfMessage *next = (struct HdfMessage *)HdfSListIteratorNext(&it);
if (next->timeStamp > message->timeStamp) { if (next->timeStamp > message->timeStamp) {
HdfSListIteratorInsert(&it, &message->entry); HdfSListIteratorInsert(&it, &message->entry);
goto complete; goto COMPLETE;
} }
} }
HdfSListAddTail(&queue->list, &message->entry); HdfSListAddTail(&queue->list, &message->entry);
complete: COMPLETE:
OsalMutexUnlock(&queue->mutex); OsalMutexUnlock(&queue->mutex);
OsalSemPost(&queue->semaphore); OsalSemPost(&queue->semaphore);
} }