From 44ee5206714cda767c62452cabdb5267dd7d2a48 Mon Sep 17 00:00:00 2001 From: guodongqi Date: Thu, 10 Mar 2022 15:49:16 +0800 Subject: [PATCH] fix: clear code warnings of master Signed-off-by: guodongqi --- .../sample_service_c/sample_service_stub.c | 32 +++++++++---------- uhdf2/manager/src/devhost_service_proxy.c | 8 ++--- uhdf2/manager/src/devsvc_manager_stub.c | 16 +++++----- uhdf2/shared/src/dev_attribute_serialize.c | 1 + 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/uhdf2/hdi/test/hdi_sample/sample_service_c/sample_service_stub.c b/uhdf2/hdi/test/hdi_sample/sample_service_c/sample_service_stub.c index d64ec8b..e6afc49 100644 --- a/uhdf2/hdi/test/hdi_sample/sample_service_c/sample_service_stub.c +++ b/uhdf2/hdi/test/hdi_sample/sample_service_c/sample_service_stub.c @@ -307,31 +307,31 @@ static int32_t SerStubListTypeTest(struct HdfDeviceIoClient *client, struct HdfS if (!HdfSbufReadInt8(data, (input + i))) { HDF_LOGE("%{public}s: read data size failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } } ec = HdiSampleImplInstance()->ArrayTypeTest(client->device, input, inSize, &output, &outSize); if (ec != HDF_SUCCESS) { HDF_LOGE("%{public}s: call failed!", __func__); - goto finished; + goto FINISHED; } if (!HdfSbufWriteUint32(reply, outSize)) { HDF_LOGE("%{public}s: write output size failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } - for (uint8_t i = 0; i < outSize; i++) { + for (uint32_t i = 0; i < outSize; i++) { if (!HdfSbufWriteInt8(reply, output[i])) { HDF_LOGE("%{public}s: write output failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } } -finished: +FINISHED: if (input != NULL) { (void)OsalMemFree(input); } @@ -360,31 +360,31 @@ static int32_t SerStubArrayTypeTest(struct HdfDeviceIoClient *client, struct Hdf if (!HdfSbufReadInt8(data, (input + i))) { HDF_LOGE("%{public}s: read data size failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } } ec = HdiSampleImplInstance()->ArrayTypeTest(client->device, input, inSize, &output, &outSize); if (ec != HDF_SUCCESS) { HDF_LOGE("%{public}s: call failed!", __func__); - goto finished; + goto FINISHED; } if (!HdfSbufWriteUint32(reply, outSize)) { HDF_LOGE("%{public}s: write output size failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } - for (uint8_t i = 0; i < outSize; i++) { + for (uint32_t i = 0; i < outSize; i++) { if (!HdfSbufWriteInt8(reply, output[i])) { HDF_LOGE("%{public}s: write output failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } } -finished: +FINISHED: if (input != NULL) { (void)OsalMemFree(input); } @@ -404,20 +404,20 @@ static int32_t SerStubStructTypeTest(struct HdfDeviceIoClient *client, struct Hd if (!HdfSbufReadBuffer(data, (const void **)&input, &dataSize)) { HDF_LOGE("%{public}s: read struct data failed!", __func__); ec = HDF_ERR_INVALID_PARAM; - goto finished; + goto FINISHED; } ec = HdiSampleImplInstance()->StructTypeTest(client->device, input, &output); if (ec != HDF_SUCCESS) { HDF_LOGE("%{public}s: call StructTypeTest failed! error code is %{public}d", __func__, ec); - goto finished; + goto FINISHED; } if (!HdfSbufWriteBuffer(reply, (const void *)&output, sizeof(output))) { HDF_LOGE("%{public}s: struct result write failed", __func__); - goto finished; + goto FINISHED; } -finished: +FINISHED: return ec; } diff --git a/uhdf2/manager/src/devhost_service_proxy.c b/uhdf2/manager/src/devhost_service_proxy.c index ca4f50b..4e2a087 100644 --- a/uhdf2/manager/src/devhost_service_proxy.c +++ b/uhdf2/manager/src/devhost_service_proxy.c @@ -32,12 +32,12 @@ static int32_t DevHostServiceProxyOpsDevice( struct DevHostServiceProxy *hostClnt = (struct DevHostServiceProxy *)inst; if (hostClnt->remote == NULL || data == NULL) { HDF_LOGE("Adding device failed, hostClnt->remote or data or reply is null"); - goto finished; + goto FINISHED; } DeviceAttributeSerialize(attribute, data); status = hostClnt->remote->dispatcher->Dispatch(hostClnt->remote, DEVHOST_SERVICE_ADD_DEVICE, data, NULL); -finished: +FINISHED: if (data != NULL) { HdfSbufRecycle(data); } @@ -58,13 +58,13 @@ static int32_t DevHostServiceProxyDelDevice( struct DevHostServiceProxy *hostClnt = (struct DevHostServiceProxy *)inst; if (hostClnt->remote == NULL || data == NULL) { HDF_LOGE("Del device failed, hostClnt->remote or data is null"); - goto finished; + goto FINISHED; } HdfSbufWriteUint32(data, devid); status = hostClnt->remote->dispatcher->Dispatch(hostClnt->remote, DEVHOST_SERVICE_DEL_DEVICE, data, NULL); -finished: +FINISHED: if (data != NULL) { HdfSbufRecycle(data); } diff --git a/uhdf2/manager/src/devsvc_manager_stub.c b/uhdf2/manager/src/devsvc_manager_stub.c index 362a073..7ad16d8 100644 --- a/uhdf2/manager/src/devsvc_manager_stub.c +++ b/uhdf2/manager/src/devsvc_manager_stub.c @@ -26,8 +26,8 @@ #define HDF_LOG_TAG devsvc_manager_stub -static struct HdfDeviceObject *ObtainServiceObject(struct DevSvcManagerStub *stub, - const char *name, struct HdfRemoteService *service) +static struct HdfDeviceObject *ObtainServiceObject( + struct DevSvcManagerStub *stub, const char *name, struct HdfRemoteService *service) { struct HdfDeviceObject *serviceObject = OsalMemCalloc(sizeof(struct HdfDeviceObject)); if (serviceObject == NULL) { @@ -54,7 +54,7 @@ static void ReleaseServiceObject(struct DevSvcManagerStub *stub, struct HdfDevic HDF_LOGW("release service object has empty name, may broken object"); return; } - struct HdfRemoteService *serviceRemote = (struct HdfRemoteService *) serviceObject->service; + struct HdfRemoteService *serviceRemote = (struct HdfRemoteService *)serviceObject->service; HdfRemoteServiceRemoveDeathRecipient(serviceRemote, &stub->recipient); HdfRemoteServiceRecycle((struct HdfRemoteService *)serviceObject->service); OsalMemFree(serviceObject->priv); @@ -227,8 +227,8 @@ static int32_t DevSvcManagerStubRegisterServListener(struct IDevSvcManager *supe return HDF_ERR_INVALID_PARAM; } - struct ServStatListenerHolder *listenerHolder - = ServStatListenerHolderCreate((uintptr_t)listenerRemote, listenClass); + struct ServStatListenerHolder *listenerHolder = + ServStatListenerHolderCreate((uintptr_t)listenerRemote, listenClass); if (listenerHolder == NULL) { return HDF_ERR_MALLOC_FAIL; } @@ -305,8 +305,8 @@ int DevSvcManagerStubDispatch(struct HdfRemoteService *service, int code, struct void DevSvcManagerOnServiceDied(struct HdfDeathRecipient *recipient, struct HdfRemoteService *remote) { - struct DevSvcManagerStub *stub - = HDF_SLIST_CONTAINER_OF(struct HdfDeathRecipient, recipient, struct DevSvcManagerStub, recipient); + struct DevSvcManagerStub *stub = + HDF_SLIST_CONTAINER_OF(struct HdfDeathRecipient, recipient, struct DevSvcManagerStub, recipient); if (stub == NULL) { return; } @@ -348,7 +348,7 @@ int DevSvcManagerStubStart(struct IDevSvcManager *svcmgr) ServStatListenerHolderinit(); - static struct HdfRemoteDispatcher dispatcher = { .Dispatch = DevSvcManagerStubDispatch }; + static struct HdfRemoteDispatcher dispatcher = {.Dispatch = DevSvcManagerStubDispatch}; inst->remote = HdfRemoteServiceObtain((struct HdfObject *)inst, &dispatcher); if (inst->remote == NULL) { HDF_LOGE("failed to obtain device service manager remote service"); diff --git a/uhdf2/shared/src/dev_attribute_serialize.c b/uhdf2/shared/src/dev_attribute_serialize.c index 65fb021..a57565c 100644 --- a/uhdf2/shared/src/dev_attribute_serialize.c +++ b/uhdf2/shared/src/dev_attribute_serialize.c @@ -66,6 +66,7 @@ struct HdfDeviceInfo *DeviceAttributeDeserialize(struct HdfSBuf *sbuf) if (!HdfSbufReadUint32(sbuf, &attribute->deviceId) || !HdfSbufReadUint16(sbuf, &attribute->policy)) { HDF_LOGE("invalid deviceId or policy"); + DeviceSerializedAttributeRelease(attribute); return NULL; }