diff --git a/core/adapter/syscall/src/hdf_devmgr_adapter.c b/core/adapter/syscall/src/hdf_devmgr_adapter.c index 5a4e63e3..cb89be9d 100644 --- a/core/adapter/syscall/src/hdf_devmgr_adapter.c +++ b/core/adapter/syscall/src/hdf_devmgr_adapter.c @@ -23,7 +23,7 @@ int32_t HdfLoadDriverByServiceName(const char *serviceName) HDF_LOGE("failed to get %s service", DEV_MGR_NODE); return ret; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("failed to obtain sbuf data"); ret = HDF_DEV_ERR_NO_MEMORY; @@ -40,7 +40,7 @@ int32_t HdfLoadDriverByServiceName(const char *serviceName) } out: HdfIoServiceRecycle(ioService); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -57,7 +57,7 @@ int32_t HdfGetServiceNameByDeviceClass(DeviceClass deviceClass, struct HdfSBuf * HDF_LOGE("failed to get %s service", DEV_MGR_NODE); return ret; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("failed to obtain sbuf data"); ret = HDF_DEV_ERR_NO_MEMORY; @@ -74,7 +74,7 @@ int32_t HdfGetServiceNameByDeviceClass(DeviceClass deviceClass, struct HdfSBuf * } out: HdfIoServiceRecycle(ioService); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } diff --git a/core/adapter/syscall/src/hdf_syscall_adapter.c b/core/adapter/syscall/src/hdf_syscall_adapter.c index 88db2dc9..6d1ea0d0 100644 --- a/core/adapter/syscall/src/hdf_syscall_adapter.c +++ b/core/adapter/syscall/src/hdf_syscall_adapter.c @@ -86,9 +86,9 @@ static int32_t HdfDevEventDispatchLocked(const struct HdfDevListenerThread *thre struct HdfSBuf *sbuf = NULL; if (bwr->readConsumed > 0) { - sbuf = HdfSBufBind(bwr->readBuffer, bwr->readConsumed); + sbuf = HdfSbufBind(bwr->readBuffer, bwr->readConsumed); } else { - sbuf = HdfSBufObtain(sizeof(int)); + sbuf = HdfSbufObtain(sizeof(int)); } if (sbuf == NULL) { @@ -120,7 +120,7 @@ static int32_t HdfDevEventDispatchLocked(const struct HdfDevListenerThread *thre } OsalMutexUnlock(&adapter->mutex); - HdfSBufRecycle(sbuf); + HdfSbufRecycle(sbuf); return HDF_SUCCESS; } diff --git a/core/adapter/vnode/src/hdf_vnode_adapter.c b/core/adapter/vnode/src/hdf_vnode_adapter.c index 90e357ec..7076ca34 100644 --- a/core/adapter/vnode/src/hdf_vnode_adapter.c +++ b/core/adapter/vnode/src/hdf_vnode_adapter.c @@ -137,7 +137,7 @@ static struct HdfSBuf *HdfSbufCopyFromUser(uintptr_t data, size_t size) struct HdfSBuf *sbuf = NULL; if (size == 0) { - return HdfSBufObtain(VOID_DATA_SIZE); + return HdfSbufObtain(VOID_DATA_SIZE); } kData = OsalMemAlloc(size); @@ -151,7 +151,7 @@ static struct HdfSBuf *HdfSbufCopyFromUser(uintptr_t data, size_t size) return NULL; } - sbuf = HdfSBufBind((uintptr_t)kData, size); + sbuf = HdfSbufBind((uintptr_t)kData, size); if (sbuf == NULL) { OsalMemFree(kData); } @@ -185,7 +185,7 @@ static void DevEventFree(struct HdfDevEvent *event) return; } if (event->data != NULL) { - HdfSBufRecycle(event->data); + HdfSbufRecycle(event->data); event->data = NULL; } OsalMemFree(event); @@ -221,18 +221,18 @@ static int HdfVNodeAdapterServCall(const struct HdfVNodeAdapterClient *client, u HDF_LOGE("vnode adapter bind data is null"); return HDF_FAILURE; } - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { HDF_LOGE("%s: oom", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } (void)HdfSbufWriteUint64(reply, (uintptr_t)&client->ioServiceClient); ret = client->adapter->ioService.dispatcher->Dispatch(client->adapter->ioService.target, bwr.cmdCode, data, reply); if (bwr.readSize != 0 && HdfSbufCopyToUser(reply, (void*)(uintptr_t)bwr.readBuffer, bwr.readSize) != HDF_SUCCESS) { - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_ERR_IO; } bwr.readConsumed = HdfSbufGetDataSize(reply); @@ -241,8 +241,8 @@ static int HdfVNodeAdapterServCall(const struct HdfVNodeAdapterClient *client, u ret = HDF_FAILURE; } - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } @@ -330,7 +330,7 @@ static int VNodeAdapterSendDevEventToClient(struct HdfVNodeAdapterClient *vnodeC return HDF_DEV_ERR_NO_MEMORY; } event->id = id; - event->data = HdfSBufCopy(data); + event->data = HdfSbufCopy(data); if (event->data == NULL) { OsalMutexUnlock(&vnodeClient->mutex); HDF_LOGE("%s: sbuf oom", __func__); diff --git a/core/manager/src/servstat_listener_holder.c b/core/manager/src/servstat_listener_holder.c index 25f305c3..31b2f9a3 100644 --- a/core/manager/src/servstat_listener_holder.c +++ b/core/manager/src/servstat_listener_holder.c @@ -48,7 +48,7 @@ void KServStatListenerHolderNotifyStatus(struct ServStatListenerHolder *holder, return; } - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("failed to notify service status, oom"); return; @@ -56,7 +56,7 @@ void KServStatListenerHolderNotifyStatus(struct ServStatListenerHolder *holder, if (ServiceStatusMarshalling(status, data) != HDF_SUCCESS) { HDF_LOGE("failed to marshalling service status"); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return; } @@ -64,7 +64,7 @@ void KServStatListenerHolderNotifyStatus(struct ServStatListenerHolder *holder, HDF_LOGE("failed to notify service status, send error"); } - HdfSBufRecycle(data); + HdfSbufRecycle(data); } struct ServStatListenerHolder *ServStatListenerHolderCreate(uintptr_t listener, uint16_t listenClass) diff --git a/core/manager/test/unittest/common/hdf_ioservice_test.cpp b/core/manager/test/unittest/common/hdf_ioservice_test.cpp index ea9907ee..98161f90 100644 --- a/core/manager/test/unittest/common/hdf_ioservice_test.cpp +++ b/core/manager/test/unittest/common/hdf_ioservice_test.cpp @@ -102,16 +102,16 @@ static int SendEvent(struct HdfIoService *serv, const char *eventData, bool broa OsalGetTime(&time); int ret; - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); if (data == nullptr) { HDF_LOGE("fail to obtain sbuf data"); return HDF_FAILURE; } - struct HdfSBuf *reply = HdfSBufObtainDefaultSize(); + struct HdfSBuf *reply = HdfSbufObtainDefaultSize(); if (reply == nullptr) { HDF_LOGE("fail to obtain sbuf reply"); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_DEV_ERR_NO_MEMORY; } @@ -140,8 +140,8 @@ static int SendEvent(struct HdfIoService *serv, const char *eventData, bool broa HDF_LOGE("send event finish at %" PRIu64 ".%" PRIu64 "", time.sec, time.usec); } while (0); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } @@ -613,7 +613,7 @@ HWTEST_F(IoServiceTest, HdfIoService012, TestSize.Level0) */ HWTEST_F(IoServiceTest, HdfIoService013, TestSize.Level0) { - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); ASSERT_NE(data, nullptr); struct HdfIoService *serv = HdfIoServiceBind(testSvcName); @@ -638,7 +638,7 @@ HWTEST_F(IoServiceTest, HdfIoService013, TestSize.Level0) ret = serv->dispatcher->Dispatch(&serv->object, SAMPLE_DRIVER_PM_STATE_INJECT, data, NULL); ASSERT_EQ(ret, HDF_SUCCESS); HdfIoServiceRecycle(serv); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } /* * @@ -742,7 +742,7 @@ HWTEST_F(IoServiceTest, HdfIoService015, TestSize.Level0) struct HdfIoService *testService = HdfIoServiceBind(SAMPLE_SERVICE); ASSERT_TRUE(testService != NULL); - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); ASSERT_TRUE(data != NULL); const char *newServName = "sample_service1"; ASSERT_TRUE(HdfSbufWriteString(data, "sample_driver")); @@ -783,7 +783,7 @@ HWTEST_F(IoServiceTest, HdfIoService015, TestSize.Level0) IoServiceStatusListenerFree(listener); HdfIoServiceRecycle(testService); SvcMgrIoserviceRelease(servmgr); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } /* * @@ -811,7 +811,7 @@ HWTEST_F(IoServiceTest, HdfIoService016, TestSize.Level0) struct HdfIoService *testService = HdfIoServiceBind(SAMPLE_SERVICE); ASSERT_TRUE(testService != NULL); - HdfSBuf *data = HdfSBufObtainDefaultSize(); + HdfSBuf *data = HdfSbufObtainDefaultSize(); ASSERT_TRUE(data != NULL); std::string servinfo = "foo"; @@ -836,7 +836,7 @@ HWTEST_F(IoServiceTest, HdfIoService016, TestSize.Level0) IoServiceStatusListenerFree(listener); HdfIoServiceRecycle(testService); SvcMgrIoserviceRelease(servmgr); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } /* * @@ -865,7 +865,7 @@ HWTEST_F(IoServiceTest, HdfIoService017, TestSize.Level0) struct HdfIoService *testService = HdfIoServiceBind(SAMPLE_SERVICE); ASSERT_TRUE(testService != NULL); - HdfSBuf *data = HdfSBufObtainDefaultSize(); + HdfSBuf *data = HdfSbufObtainDefaultSize(); ASSERT_TRUE(data != NULL); const char *newServName = "sample_service1"; ASSERT_TRUE(HdfSbufWriteString(data, "sample_driver")); @@ -899,5 +899,5 @@ HWTEST_F(IoServiceTest, HdfIoService017, TestSize.Level0) IoServiceStatusListenerFree(listener); HdfIoServiceRecycle(testService); SvcMgrIoserviceRelease(servmgr); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } diff --git a/core/manager/test/unittest/common/hdf_lite_manager_test.cpp b/core/manager/test/unittest/common/hdf_lite_manager_test.cpp index b6d2e1ca..24462961 100644 --- a/core/manager/test/unittest/common/hdf_lite_manager_test.cpp +++ b/core/manager/test/unittest/common/hdf_lite_manager_test.cpp @@ -85,7 +85,7 @@ HWTEST_F(HdfManagerTest, HdfRegisterDevice001, TestSize.Level0) struct HdfSBuf *data = NULL; struct HdfIoService *ioService = HdfIoServiceBind(SAMPLE_SERVICE); ASSERT_TRUE(ioService != NULL); - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); EXPECT_TRUE(data != NULL); EXPECT_TRUE(HdfSbufWriteString(data, "sample_driver")); EXPECT_TRUE(HdfSbufWriteString(data, "sample_service1")); @@ -106,7 +106,7 @@ HWTEST_F(HdfManagerTest, HdfRegisterDevice001, TestSize.Level0) EXPECT_TRUE(ioService1 == NULL); HdfIoServiceRecycle(ioService); HdfIoServiceRecycle(ioService1); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } /** @@ -117,7 +117,7 @@ HWTEST_F(HdfManagerTest, HdfRegisterDevice001, TestSize.Level0) */ HWTEST_F(HdfManagerTest, HdfGetServiceNameByDeviceClass001, TestSize.Level0) { - struct HdfSBuf *data = HdfSBufObtain(2000); + struct HdfSBuf *data = HdfSbufObtain(2000); ASSERT_TRUE(data != NULL); bool flag = false; @@ -138,7 +138,7 @@ HWTEST_F(HdfManagerTest, HdfGetServiceNameByDeviceClass001, TestSize.Level0) } HdfSbufFlush(data); } - HdfSBufRecycle(data); + HdfSbufRecycle(data); EXPECT_TRUE(flag); } diff --git a/core/manager/test/unittest/common/hdf_sbuf_test.cpp b/core/manager/test/unittest/common/hdf_sbuf_test.cpp index a1f48225..516930ed 100644 --- a/core/manager/test/unittest/common/hdf_sbuf_test.cpp +++ b/core/manager/test/unittest/common/hdf_sbuf_test.cpp @@ -245,9 +245,9 @@ protected: */ HWTEST_F(HdfSBufTest, SbufTestObtain001, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtain(DEFAULT_SBUF_SIZE); + HdfSBuf *sBuf = HdfSbufObtain(DEFAULT_SBUF_SIZE); ASSERT_NE(sBuf, nullptr); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); } /** @@ -258,11 +258,11 @@ HWTEST_F(HdfSBufTest, SbufTestObtain001, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestWriteUint64002, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); auto ret = HdfSbufWriteInt64(sBuf, INT64_MAX); ASSERT_EQ(ret, true); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); } /** @@ -273,13 +273,13 @@ HWTEST_F(HdfSBufTest, SbufTestWriteUint64002, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestWriteUint64Loop003, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); for (int i = 0; i < DEFAULT_BIG_LOOP_COUNT; ++i) { auto ret = HdfSbufWriteInt64(sBuf, INT64_MAX); ASSERT_EQ(ret, true); } - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); } /** @@ -290,14 +290,14 @@ HWTEST_F(HdfSBufTest, SbufTestWriteUint64Loop003, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestReadUint64Loop004, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); int loop = DEFAULT_BIG_LOOP_COUNT; for (int i = 0; i < loop; ++i) { auto ret = HdfSbufWriteInt64(sBuf, INT64_MAX); ASSERT_EQ(ret, true); } - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); uint64_t val = 0; for (int j = 0; j < loop; ++j) { @@ -308,8 +308,8 @@ HWTEST_F(HdfSBufTest, SbufTestReadUint64Loop004, TestSize.Level1) } auto ret = HdfSbufReadUint64(readBuf, &val); ASSERT_EQ(ret, false); - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -320,7 +320,7 @@ HWTEST_F(HdfSBufTest, SbufTestReadUint64Loop004, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestInt8005, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -331,7 +331,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt8005, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); int8_t val = 0; @@ -341,8 +341,8 @@ HWTEST_F(HdfSBufTest, SbufTestInt8005, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, INT8_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -353,7 +353,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt8005, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestInt16006, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -364,7 +364,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt16006, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); int16_t val = 0; @@ -374,8 +374,8 @@ HWTEST_F(HdfSBufTest, SbufTestInt16006, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, INT16_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -386,7 +386,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt16006, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestInt32007, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -397,7 +397,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt32007, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); int32_t val = 0; @@ -407,8 +407,8 @@ HWTEST_F(HdfSBufTest, SbufTestInt32007, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, INT32_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -419,7 +419,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt32007, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestInt64008, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -430,7 +430,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt64008, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint64_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); int64_t val = 0; @@ -440,8 +440,8 @@ HWTEST_F(HdfSBufTest, SbufTestInt64008, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, INT64_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -452,7 +452,7 @@ HWTEST_F(HdfSBufTest, SbufTestInt64008, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestUInt32009, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -463,7 +463,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt32009, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); uint32_t val = 0; @@ -473,8 +473,8 @@ HWTEST_F(HdfSBufTest, SbufTestUInt32009, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, UINT32_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -485,7 +485,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt32009, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestUInt16010, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -496,7 +496,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt16010, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); uint16_t val = 0; @@ -506,8 +506,8 @@ HWTEST_F(HdfSBufTest, SbufTestUInt16010, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, UINT16_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -518,7 +518,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt16010, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestUInt8011, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -529,7 +529,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt8011, TestSize.Level1) size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_EQ(dataSize, loop * sizeof(uint32_t)); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); uint8_t val = 0; @@ -539,8 +539,8 @@ HWTEST_F(HdfSBufTest, SbufTestUInt8011, TestSize.Level1) ASSERT_EQ(ret, true); ASSERT_EQ(val, UINT8_MAX); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -551,7 +551,7 @@ HWTEST_F(HdfSBufTest, SbufTestUInt8011, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestString012, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = DEFAULT_LOOP_COUNT; @@ -561,15 +561,15 @@ HWTEST_F(HdfSBufTest, SbufTestString012, TestSize.Level1) ASSERT_EQ(ret, true); } - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); for (int j = 0; j < loop; ++j) { const char *readStr = HdfSbufReadString(readBuf); ASSERT_EQ(std::string(readStr), str); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -580,7 +580,7 @@ HWTEST_F(HdfSBufTest, SbufTestString012, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestNullString013, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); auto ret = HdfSbufWriteString(sBuf, nullptr); ASSERT_EQ(true, ret); @@ -588,7 +588,7 @@ HWTEST_F(HdfSBufTest, SbufTestNullString013, TestSize.Level1) ASSERT_EQ(true, ret); size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_NE((size_t)0, dataSize); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); auto val = HdfSbufReadString(readBuf); ASSERT_EQ(nullptr, val); @@ -596,8 +596,8 @@ HWTEST_F(HdfSBufTest, SbufTestNullString013, TestSize.Level1) ret = HdfSbufReadInt32(readBuf, &intVal); ASSERT_EQ(true, ret); ASSERT_EQ(INT32_MIN, intVal); - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -608,7 +608,7 @@ HWTEST_F(HdfSBufTest, SbufTestNullString013, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestBuffer014, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; int loop = 1; @@ -618,7 +618,7 @@ HWTEST_F(HdfSBufTest, SbufTestBuffer014, TestSize.Level1) ASSERT_EQ(ret, true); } - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); for (int j = 0; j < loop; ++j) { @@ -629,8 +629,8 @@ HWTEST_F(HdfSBufTest, SbufTestBuffer014, TestSize.Level1) ASSERT_EQ(readSize, str.size() + 1); ASSERT_EQ(std::string(data), str); } - HdfSBufRecycle(readBuf); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(readBuf); + HdfSbufRecycle(sBuf); } /** @@ -641,7 +641,7 @@ HWTEST_F(HdfSBufTest, SbufTestBuffer014, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestNullBuffer015, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); auto ret = HdfSbufWriteBuffer(sBuf, nullptr, 0); ASSERT_EQ(true, ret); @@ -649,7 +649,7 @@ HWTEST_F(HdfSBufTest, SbufTestNullBuffer015, TestSize.Level1) ASSERT_EQ(true, ret); size_t dataSize = HdfSbufGetDataSize(sBuf); ASSERT_NE((size_t)0, dataSize); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); const uint8_t *buffVal = nullptr; uint32_t buffLen = 0; @@ -662,8 +662,8 @@ HWTEST_F(HdfSBufTest, SbufTestNullBuffer015, TestSize.Level1) ret = HdfSbufReadInt16(readBuf, &intVal); ASSERT_EQ(true, ret); ASSERT_EQ(INT16_MIN, intVal); - HdfSBufRecycle(sBuf); - HdfSBufRecycle(readBuf); + HdfSbufRecycle(sBuf); + HdfSbufRecycle(readBuf); } /** @@ -674,7 +674,7 @@ HWTEST_F(HdfSBufTest, SbufTestNullBuffer015, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestRandomDataSeq016, TestSize.Level0) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); GenDataTable(); @@ -682,13 +682,13 @@ HWTEST_F(HdfSBufTest, SbufTestRandomDataSeq016, TestSize.Level0) bool ret = PushDataSequence(sBuf); ASSERT_EQ(true, ret); - HdfSBuf *readBuf = HdfSBufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); + HdfSBuf *readBuf = HdfSbufBind((uintptr_t)HdfSbufGetData(sBuf), HdfSbufGetDataSize(sBuf)); ASSERT_NE(readBuf, nullptr); ret = PullDataSequence(readBuf); ASSERT_EQ(true, ret); - HdfSBufRecycle(sBuf); - HdfSBufRecycle(readBuf); + HdfSbufRecycle(sBuf); + HdfSbufRecycle(readBuf); } /** @@ -699,7 +699,7 @@ HWTEST_F(HdfSBufTest, SbufTestRandomDataSeq016, TestSize.Level0) */ HWTEST_F(HdfSBufTest, SbufTestRandomRWDataSeq017, TestSize.Level0) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); GenDataTable(); @@ -721,7 +721,7 @@ HWTEST_F(HdfSBufTest, SbufTestRandomRWDataSeq017, TestSize.Level0) ASSERT_EQ(false, ret); ASSERT_EQ(0, val); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); } /** @@ -732,7 +732,7 @@ HWTEST_F(HdfSBufTest, SbufTestRandomRWDataSeq017, TestSize.Level0) */ HWTEST_F(HdfSBufTest, SbufTestSbufMove018, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); GenDataTable(); @@ -746,7 +746,7 @@ HWTEST_F(HdfSBufTest, SbufTestSbufMove018, TestSize.Level1) ASSERT_EQ(ret, true); } - HdfSBuf *readBuf = HdfSBufMove(sBuf); + HdfSBuf *readBuf = HdfSbufMove(sBuf); ASSERT_NE(readBuf, nullptr); for (int j = 0; j < loop; ++j) { @@ -757,8 +757,8 @@ HWTEST_F(HdfSBufTest, SbufTestSbufMove018, TestSize.Level1) ASSERT_EQ(readSize, str.size() + 1); ASSERT_EQ(std::string(data), str); } - HdfSBufRecycle(sBuf); - HdfSBufRecycle(readBuf); + HdfSbufRecycle(sBuf); + HdfSbufRecycle(readBuf); } /** @@ -769,7 +769,7 @@ HWTEST_F(HdfSBufTest, SbufTestSbufMove018, TestSize.Level1) */ HWTEST_F(HdfSBufTest, SbufTestSbufMoveHalf019, TestSize.Level1) { - HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); ASSERT_NE(sBuf, nullptr); bool ret; @@ -788,7 +788,7 @@ HWTEST_F(HdfSBufTest, SbufTestSbufMoveHalf019, TestSize.Level1) ASSERT_EQ(std::string(data), str); } - HdfSBuf *readBuf = HdfSBufMove(sBuf); + HdfSBuf *readBuf = HdfSbufMove(sBuf); ASSERT_NE(readBuf, nullptr); for (int j = 0; j < loop; ++j) { @@ -805,6 +805,6 @@ HWTEST_F(HdfSBufTest, SbufTestSbufMoveHalf019, TestSize.Level1) ret = HdfSbufReadBuffer(readBuf, (const void **)(&data), &readSize); ASSERT_EQ(ret, false); - HdfSBufRecycle(sBuf); - HdfSBufRecycle(readBuf); + HdfSbufRecycle(sBuf); + HdfSbufRecycle(readBuf); } diff --git a/core/shared/src/svcmgr_ioservice.c b/core/shared/src/svcmgr_ioservice.c index 363dc1bc..a660164a 100644 --- a/core/shared/src/svcmgr_ioservice.c +++ b/core/shared/src/svcmgr_ioservice.c @@ -23,7 +23,7 @@ struct SvcMgrIoservice { static int32_t SetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t devClass) { - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } @@ -39,7 +39,7 @@ static int32_t SetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t devCl static int32_t UnSetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t devClass) { - struct HdfSBuf *data = HdfSBufObtainDefaultSize(); + struct HdfSBuf *data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } diff --git a/include/utils/hdf_sbuf.h b/include/utils/hdf_sbuf.h index 29ed7006..66780d37 100644 --- a/include/utils/hdf_sbuf.h +++ b/include/utils/hdf_sbuf.h @@ -39,7 +39,7 @@ typedef uint16_t char16_t; #endif /* __cplusplus */ struct HdfSBuf; -struct HdfSbufImpl; +struct HdfSBufImpl; struct HdfRemoteService; /** @@ -235,7 +235,7 @@ bool HdfSbufWriteFileDescriptor(struct HdfSBuf *sbuf, int fd); * * @since 1.0 */ -int32_t HdfSBufWriteRemoteService(struct HdfSBuf *sbuf, const struct HdfRemoteService *service); +int32_t HdfSbufWriteRemoteService(struct HdfSBuf *sbuf, const struct HdfRemoteService *service); /** * @brief Reads an IPC service from a SBuf. @@ -247,7 +247,7 @@ int32_t HdfSBufWriteRemoteService(struct HdfSBuf *sbuf, const struct HdfRemoteSe * * @since 1.0 */ -struct HdfRemoteService *HdfSBufReadRemoteService(struct HdfSBuf *sbuf); +struct HdfRemoteService *HdfSbufReadRemoteService(struct HdfSBuf *sbuf); /** * @brief Reads a file descriptor from a SBuf. @@ -295,7 +295,7 @@ bool HdfSbufReadFloat(struct HdfSBuf *sbuf, float *value); * * @since 1.0 */ -const char16_t *HdfSBufReadString16(struct HdfSBuf *sbuf); +const char16_t *HdfSbufReadString16(struct HdfSBuf *sbuf); /** * @brief Reads a data segment from a SBuf. @@ -479,7 +479,7 @@ void HdfSbufSetDataSize(struct HdfSBuf *sbuf, size_t size); * * @since 1.0 */ -struct HdfSBuf *HdfSBufObtain(size_t capacity); +struct HdfSBuf *HdfSbufObtain(size_t capacity); /** * @brief Obtains a SBuf instance of the default capacity (256 bytes). @@ -488,7 +488,7 @@ struct HdfSBuf *HdfSBufObtain(size_t capacity); * * @since 1.0 */ -struct HdfSBuf *HdfSBufObtainDefaultSize(void); +struct HdfSBuf *HdfSbufObtainDefaultSize(void); /** * @brief Creates a SBuf instance with the specified data and size. @@ -501,7 +501,7 @@ struct HdfSBuf *HdfSBufObtainDefaultSize(void); * * @since 1.0 */ -struct HdfSBuf *HdfSBufBind(uintptr_t base, size_t size); +struct HdfSBuf *HdfSbufBind(uintptr_t base, size_t size); /** * @brief Releases a SBuf. @@ -510,7 +510,7 @@ struct HdfSBuf *HdfSBufBind(uintptr_t base, size_t size); * * @since 1.0 */ -void HdfSBufRecycle(struct HdfSBuf *sbuf); +void HdfSbufRecycle(struct HdfSBuf *sbuf); /** * @brief Creates a SBuf instance with an original SBuf. @@ -521,7 +521,7 @@ void HdfSBufRecycle(struct HdfSBuf *sbuf); * * @since 1.0 */ -struct HdfSBuf *HdfSBufMove(struct HdfSBuf *sbuf); +struct HdfSBuf *HdfSbufMove(struct HdfSBuf *sbuf); /** * @brief Creates a SBuf instance with an original SBuf. @@ -532,11 +532,11 @@ struct HdfSBuf *HdfSBufMove(struct HdfSBuf *sbuf); * * @since 1.0 */ -struct HdfSBuf *HdfSBufCopy(const struct HdfSBuf *sbuf); +struct HdfSBuf *HdfSbufCopy(const struct HdfSBuf *sbuf); /** * @brief Transfers the data ownership to a SBuf. Once the SBuf is released, - * the bound data memory is also released. This function is used together with {@link HdfSBufBind}. + * the bound data memory is also released. This function is used together with {@link HdfSbufBind}. * * @param sbuf Indicates the pointer to the target SBuf. * @@ -552,7 +552,7 @@ void HdfSbufTransDataOwnership(struct HdfSBuf *sbuf); * * @since 1.0 */ -struct HdfSBuf *HdfSBufTypedObtain(uint32_t type); +struct HdfSBuf *HdfSbufTypedObtain(uint32_t type); /** * @brief Obtains a SBuf instance of a specified type based on the implementation of an existing SBuf. @@ -563,7 +563,7 @@ struct HdfSBuf *HdfSBufTypedObtain(uint32_t type); * * @since 1.0 */ -struct HdfSBuf *HdfSBufTypedObtainInplace(uint32_t type, struct HdfSbufImpl *impl); +struct HdfSBuf *HdfSbufTypedObtainInplace(uint32_t type, struct HdfSBufImpl *impl); /** * @brief Obtains a SBuf instance of a specified type with the given initial capacity. @@ -574,7 +574,7 @@ struct HdfSBuf *HdfSBufTypedObtainInplace(uint32_t type, struct HdfSbufImpl *imp * * @since 1.0 */ -struct HdfSBuf *HdfSBufTypedObtainCapacity(uint32_t type, size_t capacity); +struct HdfSBuf *HdfSbufTypedObtainCapacity(uint32_t type, size_t capacity); /** * @brief Creates a SBuf instance of a specified type with the specified data and size. @@ -588,7 +588,7 @@ struct HdfSBuf *HdfSBufTypedObtainCapacity(uint32_t type, size_t capacity); * * @since 1.0 */ -struct HdfSBuf *HdfSBufTypedBind(uint32_t type, uintptr_t base, size_t size); +struct HdfSBuf *HdfSbufTypedBind(uint32_t type, uintptr_t base, size_t size); /** * @brief Obtains the implementation of a SBuf. @@ -598,7 +598,7 @@ struct HdfSBuf *HdfSBufTypedBind(uint32_t type, uintptr_t base, size_t size); * * @since 1.0 */ -struct HdfSbufImpl *HdfSbufGetImpl(struct HdfSBuf *sbuf); +struct HdfSBufImpl *HdfSbufGetImpl(struct HdfSBuf *sbuf); #ifdef __cplusplus } diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index 7f1a02fa..30f7022b 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -235,12 +235,12 @@ static int32_t AllocPackageBuffer(InputDevice *inputDev) HDF_LOGE("%s: devType not exist", __func__); return HDF_FAILURE; } - inputDev->pkgBuf = HdfSBufObtain(sizeof(EventPackage) * pkgNum); + inputDev->pkgBuf = HdfSbufObtain(sizeof(EventPackage) * pkgNum); if (inputDev->pkgBuf == NULL) { HDF_LOGE("%s: malloc sbuf failed", __func__); return HDF_ERR_MALLOC_FAIL; } - inputDev->eventBuf = HdfSBufObtain(sizeof(HotPlugEvent)); + inputDev->eventBuf = HdfSbufObtain(sizeof(HotPlugEvent)); if (inputDev->eventBuf == NULL) { HDF_LOGE("%s: malloc sbuf failed", __func__); return HDF_ERR_MALLOC_FAIL; @@ -340,13 +340,13 @@ void UnregisterInputDevice(InputDevice *inputDev) } DeleteDeviceNode(inputDev); - HdfSBufRecycle(inputDev->pkgBuf); + HdfSbufRecycle(inputDev->pkgBuf); inputDev->pkgBuf = NULL; ret = DeleteInputDevice(inputDev); if (ret != HDF_SUCCESS) { goto EXIT; } - HdfSBufRecycle(inputDev->eventBuf); + HdfSbufRecycle(inputDev->eventBuf); inputDev->eventBuf = NULL; OsalMemFree(inputDev); OsalMutexUnlock(&g_inputManager->mutex); diff --git a/model/misc/dsoftbus/src/wlan_param_monitor.c b/model/misc/dsoftbus/src/wlan_param_monitor.c index d06fa4fe..5356f780 100644 --- a/model/misc/dsoftbus/src/wlan_param_monitor.c +++ b/model/misc/dsoftbus/src/wlan_param_monitor.c @@ -39,18 +39,18 @@ static void ProcessRequestParam(void) info.event = EVENT_WLAN_PARAM; info.value = (uint32_t)OsalGetSysTimeMs(); - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("get sbuf fail"); return; } if (!HdfSbufWriteBuffer(data, (const void *)&info, sizeof(info))) { HDF_LOGE("sbuf write report value fail"); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return; } HdfSoftbusBroadcastEvent(SOFTBUS_MODULE_WLAN_PARAM_MONITOR, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); } int32_t SoftbusWlanParamMonitorInit(struct HdfDeviceObject *device) diff --git a/model/network/wifi/core/module/wifi_base.c b/model/network/wifi/core/module/wifi_base.c index 1228a5a3..7605e9b6 100644 --- a/model/network/wifi/core/module/wifi_base.c +++ b/model/network/wifi/core/module/wifi_base.c @@ -1253,7 +1253,7 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf return HDF_ERR_INVALID_PARAM; } - data = HdfSBufCopy(reqData); + data = HdfSbufCopy(reqData); if (data == NULL) { HDF_LOGE("%s: sbuf copy fail", __func__); return HDF_FAILURE; @@ -1262,7 +1262,7 @@ static int32_t WifiCmdResetDriver(const RequestContext *context, struct HdfSBuf ret = g_baseService->SendAsyncMessage(g_baseService, BASE_SERVICE_ID, CMD_BASE_DO_RESET_PRIVATE, data, SendMessageResetDriverCallBack); if (ret != HDF_SUCCESS) { - HdfSBufRecycle(data); + HdfSbufRecycle(data); HDF_LOGE("%s: fail to reset the driver,%d", __func__, ret); } return ret; diff --git a/model/network/wifi/platform/src/hdf_wifi_event.c b/model/network/wifi/platform/src/hdf_wifi_event.c index e519a13f..e6dc6b10 100644 --- a/model/network/wifi/platform/src/hdf_wifi_event.c +++ b/model/network/wifi/platform/src/hdf_wifi_event.c @@ -38,7 +38,7 @@ int32_t HdfWifiEventNewSta(const struct NetDevice *netDev, const uint8_t *macAdd return HDF_FAILURE; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -48,7 +48,7 @@ int32_t HdfWifiEventNewSta(const struct NetDevice *netDev, const uint8_t *macAdd !HdfSbufWriteBuffer(data, info->assocReqIes, info->assocReqIesLen) || !HdfSbufWriteBuffer(data, macAddr, addrLen)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } @@ -56,7 +56,7 @@ int32_t HdfWifiEventNewSta(const struct NetDevice *netDev, const uint8_t *macAdd (addrLen > 0) ? macAddr[addrLen - 1] : -1); ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_NEW_STA, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -70,7 +70,7 @@ int32_t HdfWifiEventDelSta(struct NetDevice *netDev, const uint8_t *macAddr, uin return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -78,12 +78,12 @@ int32_t HdfWifiEventDelSta(struct NetDevice *netDev, const uint8_t *macAddr, uin if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteBuffer(data, macAddr, addrLen)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_DEL_STA, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -100,7 +100,7 @@ int32_t HdfWifiEventInformBssFrame(const struct NetDevice *netDev, return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -117,12 +117,12 @@ int32_t HdfWifiEventInformBssFrame(const struct NetDevice *netDev, !HdfSbufWriteBuffer(data, bssInfo->mgmt->u.probeResp.variable, ieLen) || !HdfSbufWriteBuffer(data, bssInfo->mgmt->u.beacon.variable, beaconLen)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_SCAN_RESULT, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -137,7 +137,7 @@ int32_t HdfWifiEventScanDone(const struct NetDevice *netDev, WifiScanStatus stat return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -145,12 +145,12 @@ int32_t HdfWifiEventScanDone(const struct NetDevice *netDev, WifiScanStatus stat if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, code)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_SCAN_DONE, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -211,7 +211,7 @@ int32_t HdfWifiEventConnectResult(const struct NetDevice *netDev, const struct C return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -222,12 +222,12 @@ int32_t HdfWifiEventConnectResult(const struct NetDevice *netDev, const struct C !HdfSbufWriteBuffer(data, result->reqIe, result->reqIeLen) || !HdfSbufWriteBuffer(data, result->rspIe, result->rspIeLen)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_CONNECT_RESULT, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) if (result->connectStatus == WIFI_HMAC_MGMT_SUCCESS) { @@ -248,7 +248,7 @@ int32_t HdfWifiEventDisconnected(const struct NetDevice *netDev, uint16_t reason return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -257,12 +257,12 @@ int32_t HdfWifiEventDisconnected(const struct NetDevice *netDev, uint16_t reason if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint16(data, reason) || !HdfSbufWriteBuffer(data, ie, len)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_DISCONNECT, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -276,7 +276,7 @@ int32_t HdfWifiEventMgmtTxStatus(const struct NetDevice *netDev, const uint8_t * return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -285,12 +285,12 @@ int32_t HdfWifiEventMgmtTxStatus(const struct NetDevice *netDev, const uint8_t * if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint8(data, ack) || !HdfSbufWriteBuffer(data, buf, len)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_TX_STATUS, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -304,7 +304,7 @@ int32_t HdfWifiEventCsaChannelSwitch(const struct NetDevice *netDev, int32_t fre return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -312,12 +312,12 @@ int32_t HdfWifiEventCsaChannelSwitch(const struct NetDevice *netDev, int32_t fre if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_CHANNEL_SWITCH, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -331,19 +331,19 @@ int32_t HdfWifiEventTimeoutDisconnected(const struct NetDevice *netDev) return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; } if (!HdfSbufWriteString(data, netDev->name)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_TIMEOUT_DISCONN, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -357,7 +357,7 @@ int32_t HdfWifiEventRxMgmt(const struct NetDevice *netDev, int32_t freq, int32_t return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; @@ -366,12 +366,12 @@ int32_t HdfWifiEventRxMgmt(const struct NetDevice *netDev, int32_t freq, int32_t if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq) || !HdfSbufWriteUint32(data, sigMbm) || !HdfSbufWriteBuffer(data, buf, len)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_RX_MGMT, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -384,19 +384,19 @@ int32_t HdfWifiEventEapolRecv(const char *name, void *context) if (name == NULL) { return HDF_ERR_INVALID_PARAM; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; } if (!HdfSbufWriteString(data, name)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_EAPOL_RECV, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -405,28 +405,28 @@ int32_t HdfWifiEventResetResult(const uint8_t chipId, int32_t resetStatus, const struct HdfSBuf *data = NULL; int32_t ret; - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; } if (!HdfSbufWriteString(data, ifName)) { HDF_LOGE("%s: Serialize failed!", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } if (!HdfSbufWriteInt32(data, resetStatus)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } if (!HdfSbufWriteUint8(data, chipId)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_RESET_DRIVER, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -435,23 +435,23 @@ int32_t HdfWifiEventRemainOnChannel(const struct NetDevice *netDev, uint32_t fre struct HdfSBuf *data = NULL; int32_t ret; - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; } if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } if (!HdfSbufWriteUint32(data, duration)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_REMAIN_ON_CHANNEL, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } @@ -460,18 +460,18 @@ int32_t HdfWifiEventCancelRemainOnChannel(const struct NetDevice *netDev, uint32 struct HdfSBuf *data = NULL; int32_t ret; - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("%s InitDataBlock failed", __func__); return HDF_FAILURE; } if (!HdfSbufWriteString(data, netDev->name) || !HdfSbufWriteUint32(data, freq)) { HDF_LOGE("%s sbuf write failed", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_FAILURE; } ret = HdfWlanSendBroadcastEvent(WIFI_WPA_EVENT_CANCEL_REMAIN_ON_CHANNEL, data); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } diff --git a/model/network/wifi/platform/src/message/message_dispatcher.c b/model/network/wifi/platform/src/message/message_dispatcher.c index 9231270d..34b5b99e 100644 --- a/model/network/wifi/platform/src/message/message_dispatcher.c +++ b/model/network/wifi/platform/src/message/message_dispatcher.c @@ -32,7 +32,7 @@ void ReleaseMessageContext(MessageContext *context) return; } if (context->rspData != NULL) { - HdfSBufRecycle(context->rspData); + HdfSbufRecycle(context->rspData); context->rspData = NULL; } @@ -40,7 +40,7 @@ void ReleaseMessageContext(MessageContext *context) (context->requestType != MESSAGE_TYPE_SYNC_REQ && context->requestType != MESSAGE_TYPE_SYNC_RSP)) { // Sync request message may use stack mem.Memory is managed by user if (context->reqData != NULL) { - HdfSBufRecycle(context->reqData); + HdfSbufRecycle(context->reqData); context->reqData = NULL; } OsalMemFree(context); diff --git a/model/network/wifi/platform/src/message/sidecar.c b/model/network/wifi/platform/src/message/sidecar.c index 75843c05..defefc8e 100644 --- a/model/network/wifi/platform/src/message/sidecar.c +++ b/model/network/wifi/platform/src/message/sidecar.c @@ -158,7 +158,7 @@ static ErrorCode SideCarSendAsyncMessageInner(const Service *sideCar, ServiceId if (context == NULL) { return ME_ERROR_NULL_PTR; } - rspData = HdfSBufObtainDefaultSize(); + rspData = HdfSbufObtainDefaultSize(); if (rspData == NULL) { OsalMemFree(context); return HDF_FAILURE; @@ -180,7 +180,7 @@ static ErrorCode SideCarSendAsyncMessageInner(const Service *sideCar, ServiceId targetService->Disref(targetService); } if (errCode != ME_SUCCESS) { - HdfSBufRecycle(rspData); + HdfSbufRecycle(rspData); OsalMemFree(context); } return errCode; diff --git a/model/sensor/driver/common/src/sensor_device_manager.c b/model/sensor/driver/common/src/sensor_device_manager.c index c38271e7..fd18ac76 100644 --- a/model/sensor/driver/common/src/sensor_device_manager.c +++ b/model/sensor/driver/common/src/sensor_device_manager.c @@ -97,7 +97,7 @@ int32_t ReportSensorEvent(const struct SensorReportEvent *events) CHECK_NULL_PTR_RETURN_VALUE(manager, HDF_ERR_INVALID_PARAM); (void)OsalMutexLock(&manager->eventMutex); - msg = HdfSBufObtain(HDF_SENSOR_EVENT_MAX_BUF); + msg = HdfSbufObtain(HDF_SENSOR_EVENT_MAX_BUF); if (msg == NULL) { (void)OsalMutexUnlock(&manager->eventMutex); return HDF_ERR_INVALID_PARAM; @@ -123,7 +123,7 @@ int32_t ReportSensorEvent(const struct SensorReportEvent *events) ret = HDF_SUCCESS; EXIT: - HdfSBufRecycle(msg); + HdfSbufRecycle(msg); (void)OsalMutexUnlock(&manager->eventMutex); return ret; } diff --git a/model/storage/src/mmc/emmc_if.c b/model/storage/src/mmc/emmc_if.c index 1258278c..642bd342 100644 --- a/model/storage/src/mmc/emmc_if.c +++ b/model/storage/src/mmc/emmc_if.c @@ -47,7 +47,7 @@ int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t s int32_t ret; struct HdfSBuf *reply = NULL; - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { HDF_LOGE("EmmcServiceGetCid: failed to obtain reply!"); ret = HDF_ERR_MALLOC_FAIL; @@ -74,7 +74,7 @@ int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t s __EXIT: if (reply != NULL) { - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); } return ret; } diff --git a/model/storage/src/mmc/mmc_if.c b/model/storage/src/mmc/mmc_if.c index 4f85b54f..f3d15acf 100644 --- a/model/storage/src/mmc/mmc_if.c +++ b/model/storage/src/mmc/mmc_if.c @@ -81,7 +81,7 @@ bool MmcDevPresent(DevHandle handle) struct HdfSBuf *reply = NULL; struct HdfIoService *service = (struct HdfIoService *)handle; - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { HDF_LOGE("MmcDevPresent: failed to obtain reply!"); return false; @@ -103,7 +103,7 @@ bool MmcDevPresent(DevHandle handle) goto __EXIT; } __EXIT: - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return (present != 0); #else return MmcCntlrDevPresent((struct MmcCntlr *)handle); diff --git a/model/usb/src/usb_ddk_pnp_loader.c b/model/usb/src/usb_ddk_pnp_loader.c index 49aace58..94e4b6c1 100644 --- a/model/usb/src/usb_ddk_pnp_loader.c +++ b/model/usb/src/usb_ddk_pnp_loader.c @@ -34,9 +34,9 @@ static struct HdfSBuf *UsbDdkPnpLoaderBufCreate(const char *moduleName, { struct HdfSBuf *pnpData = NULL; - pnpData = HdfSBufObtainDefaultSize(); + pnpData = HdfSbufObtainDefaultSize(); if (pnpData == NULL) { - HDF_LOGE("%s: HdfSBufTypedObtain pnpData fail", __func__); + HDF_LOGE("%s: HdfSbufTypedObtain pnpData fail", __func__); return NULL; } @@ -63,7 +63,7 @@ static struct HdfSBuf *UsbDdkPnpLoaderBufCreate(const char *moduleName, return pnpData; OUT: - HdfSBufRecycle(pnpData); + HdfSbufRecycle(pnpData); return NULL; } @@ -818,7 +818,7 @@ static int UsbDdkPnpLoaderrAddPnpDevice(struct HdfDeviceObject *usbPnpManagerDev } } ERROR: - HdfSBufRecycle(pnpData); + HdfSbufRecycle(pnpData); return ret; } @@ -881,7 +881,7 @@ static int UsbDdkPnpLoaderRemoveHandle(struct HdfDeviceObject *usbPnpManager, } ERROR: - HdfSBufRecycle(pnpData); + HdfSbufRecycle(pnpData); return ret; } @@ -983,14 +983,14 @@ static int UsbDdkPnpLoaderEventSend(const struct HdfIoService *serv, const char int replyData = 0; struct HdfSBuf *data = NULL; - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { ret = HDF_DEV_ERR_NO_MEMORY; HDF_LOGE("%s: fail to obtain sbuf data", __func__); return ret; } - struct HdfSBuf *reply = HdfSBufObtainDefaultSize(); + struct HdfSBuf *reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { ret = HDF_DEV_ERR_NO_MEMORY; HDF_LOGE("%s: fail to obtain sbuf reply", __func__); @@ -1018,8 +1018,8 @@ static int UsbDdkPnpLoaderEventSend(const struct HdfIoService *serv, const char HDF_LOGI("%s:%d get reply is 0x%x", __func__, __LINE__, replyData); OUT: - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } diff --git a/sample/platform/uart/dispatch/uart_if.c b/sample/platform/uart/dispatch/uart_if.c index 9fdb158c..ba928da7 100755 --- a/sample/platform/uart/dispatch/uart_if.c +++ b/sample/platform/uart/dispatch/uart_if.c @@ -61,7 +61,7 @@ int32_t UartWrite(struct DevHandle *handle, uint8_t *data, uint32_t size) return HDF_FAILURE; } - struct HdfSBuf *sBuf = HdfSBufObtainDefaultSize(); + struct HdfSBuf *sBuf = HdfSbufObtainDefaultSize(); if (sBuf == NULL) { HDF_LOGE("Failed to obtain sBuf"); return HDF_FAILURE; @@ -69,7 +69,7 @@ int32_t UartWrite(struct DevHandle *handle, uint8_t *data, uint32_t size) if (!HdfSbufWriteBuffer(sBuf, data, size)) { HDF_LOGE("Failed to write sbuf"); - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); return HDF_FAILURE; } @@ -78,7 +78,7 @@ int32_t UartWrite(struct DevHandle *handle, uint8_t *data, uint32_t size) if (ret != HDF_SUCCESS) { HDF_LOGE("Failed to send service call"); } - HdfSBufRecycle(sBuf); + HdfSbufRecycle(sBuf); return ret; } diff --git a/support/platform/src/gpio/gpio_if.c b/support/platform/src/gpio/gpio_if.c index 24d904e1..7ef98d56 100644 --- a/support/platform/src/gpio/gpio_if.c +++ b/support/platform/src/gpio/gpio_if.c @@ -49,41 +49,41 @@ int32_t GpioRead(uint16_t gpio, uint16_t *val) return HDF_PLT_ERR_DEV_GET; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteUint16(data, (uint16_t)gpio)) { PLAT_LOGE("%s: write gpio number failed!", __func__); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_ERR_IO; } ret = service->dispatcher->Dispatch(&service->object, GPIO_IO_READ, data, reply); if (ret != HDF_SUCCESS) { PLAT_LOGE("%s: service call failed:%d", __func__, ret); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } if (!HdfSbufReadUint16(reply, val)) { PLAT_LOGE("%s: read sbuf failed", __func__); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_SUCCESS; } @@ -98,31 +98,31 @@ int32_t GpioWrite(uint16_t gpio, uint16_t val) return HDF_PLT_ERR_DEV_GET; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteUint16(data, (uint16_t)gpio)) { PLAT_LOGE("%s: write gpio number failed!", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_IO; } if (!HdfSbufWriteUint16(data, (uint16_t)val)) { PLAT_LOGE("%s: write gpio value failed!", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_IO; } ret = service->dispatcher->Dispatch(&service->object, GPIO_IO_WRITE, data, NULL); if (ret != HDF_SUCCESS) { PLAT_LOGE("%s: service call failed:%d", __func__, ret); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_SUCCESS; } @@ -138,41 +138,41 @@ int32_t GpioGetDir(uint16_t gpio, uint16_t *dir) return HDF_PLT_ERR_DEV_GET; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteUint16(data, (uint16_t)gpio)) { PLAT_LOGE("%s: write gpio number failed!", __func__); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_ERR_IO; } ret = service->dispatcher->Dispatch(&service->object, GPIO_IO_GETDIR, data, reply); if (ret != HDF_SUCCESS) { PLAT_LOGE("%s: service call failed:%d", __func__, ret); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } if (!HdfSbufReadUint16(reply, dir)) { PLAT_LOGE("%s: read sbuf failed", __func__); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return HDF_SUCCESS; } @@ -187,31 +187,31 @@ int32_t GpioSetDir(uint16_t gpio, uint16_t dir) return HDF_PLT_ERR_DEV_GET; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteUint16(data, (uint16_t)gpio)) { PLAT_LOGE("%s: write gpio number failed!", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_IO; } if (!HdfSbufWriteUint16(data, (uint16_t)dir)) { PLAT_LOGE("%s: write gpio value failed!", __func__); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_ERR_IO; } ret = service->dispatcher->Dispatch(&service->object, GPIO_IO_SETDIR, data, NULL); if (ret != HDF_SUCCESS) { PLAT_LOGE("%s: service call failed:%d", __func__, ret); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return ret; } - HdfSBufRecycle(data); + HdfSbufRecycle(data); return HDF_SUCCESS; } diff --git a/support/platform/src/hdmi/hdmi_if.c b/support/platform/src/hdmi/hdmi_if.c index d8275659..dd1aee19 100644 --- a/support/platform/src/hdmi/hdmi_if.c +++ b/support/platform/src/hdmi/hdmi_if.c @@ -129,14 +129,14 @@ static int32_t HdmiUserAvmuteSet(DevHandle handle, bool enable) return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(enable)); + buf = HdfSbufObtain(sizeof(enable)); if (buf == NULL) { HDF_LOGE("HdmiUserAvmuteSet: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, &enable, sizeof(enable))) { HDF_LOGE("HdmiUserAvmuteSet: sbuf write buffer failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -144,7 +144,7 @@ static int32_t HdmiUserAvmuteSet(DevHandle handle, bool enable) if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserAvmuteSet: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } @@ -159,14 +159,14 @@ static int32_t HdmiUserDeepColorSet(DevHandle handle, enum HdmiDeepColor color) return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(color)); + buf = HdfSbufObtain(sizeof(color)); if (buf == NULL) { HDF_LOGE("HdmiUserDeepColorSet: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, &color, sizeof(color))) { HDF_LOGE("HdmiUserDeepColorSet: sbuf write color failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -174,7 +174,7 @@ static int32_t HdmiUserDeepColorSet(DevHandle handle, enum HdmiDeepColor color) if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserDeepColorSet: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } @@ -192,14 +192,14 @@ static int32_t HdmiUserSetVideoAttribute(DevHandle handle, struct HdmiVideoAttr return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(struct HdmiVideoAttr)); + buf = HdfSbufObtain(sizeof(struct HdmiVideoAttr)); if (buf == NULL) { HDF_LOGE("HdmiUserSetVideoAttribute: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, attr, sizeof(struct HdmiVideoAttr))) { HDF_LOGE("HdmiUserSetVideoAttribute: sbuf write attr failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -207,7 +207,7 @@ static int32_t HdmiUserSetVideoAttribute(DevHandle handle, struct HdmiVideoAttr if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserSetVideoAttribute: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } @@ -226,14 +226,14 @@ static int32_t HdmiUserSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(struct HdmiAudioAttr)); + buf = HdfSbufObtain(sizeof(struct HdmiAudioAttr)); if (buf == NULL) { HDF_LOGE("HdmiUserSetAudioAttribute: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, attr, sizeof(struct HdmiAudioAttr))) { HDF_LOGE("HdmiUserSetAudioAttribute: sbuf write attr failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -241,7 +241,7 @@ static int32_t HdmiUserSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserSetAudioAttribute: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } @@ -260,14 +260,14 @@ static int32_t HdmiUserSetHdrAttribute(DevHandle handle, struct HdmiHdrAttr *att return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(struct HdmiHdrAttr)); + buf = HdfSbufObtain(sizeof(struct HdmiHdrAttr)); if (buf == NULL) { HDF_LOGE("HdmiUserSetHdrAttribute: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, attr, sizeof(struct HdmiHdrAttr))) { HDF_LOGE("HdmiUserSetHdrAttribute: sbuf write attr failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -275,7 +275,7 @@ static int32_t HdmiUserSetHdrAttribute(DevHandle handle, struct HdmiHdrAttr *att if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserSetAudioAttribute: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } @@ -294,7 +294,7 @@ static int32_t HdmiUserDeepColorGet(DevHandle handle, enum HdmiDeepColor *color) } /* Four bytes are used to store the buffer length, and four bytes are used to align the memory. */ - reply = HdfSBufObtain(sizeof(*color) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*color) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("HdmiUserDeepColorGet: failed to obtain reply"); ret = HDF_ERR_MALLOC_FAIL; @@ -310,7 +310,7 @@ static int32_t HdmiUserDeepColorGet(DevHandle handle, enum HdmiDeepColor *color) __EXIT : if (reply != NULL) { - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); } return ret; } @@ -329,7 +329,7 @@ static int32_t HdmiUserGetSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t l return HDF_ERR_INVALID_PARAM; } - reply = HdfSBufObtain(len); + reply = HdfSbufObtain(len); if (reply == NULL) { HDF_LOGE("HdmiUserGetSinkEdid: failed to obtain reply"); ret = HDF_ERR_MALLOC_FAIL; @@ -345,7 +345,7 @@ static int32_t HdmiUserGetSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t l __EXIT : if (reply != NULL) { - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); } return ret; } @@ -365,14 +365,14 @@ static int32_t HdmiUserRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdC return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(sizeof(uint32_t)); + buf = HdfSbufObtain(sizeof(uint32_t)); if (buf == NULL) { HDF_LOGE("HdmiUserRegisterHpdCallbackFunc: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, (void *)&addr, sizeof(uint32_t))) { HDF_LOGE("HdmiUserRegisterHpdCallbackFunc: sbuf write attr failed"); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -380,7 +380,7 @@ static int32_t HdmiUserRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdC if (ret != HDF_SUCCESS) { HDF_LOGE("HdmiUserRegisterHpdCallbackFunc: failed to write, ret %d", ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } diff --git a/support/platform/src/i2c/i2c_if.c b/support/platform/src/i2c/i2c_if.c index 59665074..3accad85 100644 --- a/support/platform/src/i2c/i2c_if.c +++ b/support/platform/src/i2c/i2c_if.c @@ -60,39 +60,39 @@ DevHandle I2cOpen(int16_t number) if (service == NULL) { return NULL; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return NULL; } - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { - HdfSBufRecycle(data); + HdfSbufRecycle(data); return NULL; } if (!HdfSbufWriteUint16(data, (uint16_t)number)) { HDF_LOGE("I2cOpen: write number fail!"); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return NULL; } ret = service->dispatcher->Dispatch(&service->object, I2C_IO_OPEN, data, reply); if (ret != HDF_SUCCESS) { HDF_LOGE("I2cOpen: service call open fail:%d", ret); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return NULL; } if (!HdfSbufReadUint32(reply, &handle)) { HDF_LOGE("I2cOpen: read handle fail!"); - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return NULL; } - HdfSBufRecycle(data); - HdfSBufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return (DevHandle)(uintptr_t)handle; #else return (DevHandle)I2cCntlrGet(number); @@ -111,14 +111,14 @@ void I2cClose(DevHandle handle) return; } - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { return; } if (!HdfSbufWriteUint32(data, (uint32_t)(uintptr_t)handle)) { HDF_LOGE("I2cClose: write handle fail!"); - HdfSBufRecycle(data); + HdfSbufRecycle(data); return; } @@ -126,7 +126,7 @@ void I2cClose(DevHandle handle) if (ret != HDF_SUCCESS) { HDF_LOGE("I2cClose: close handle fail:%d", ret); } - HdfSBufRecycle(data); + HdfSbufRecycle(data); #else I2cCntlrPut((struct I2cCntlr *)handle); #endif @@ -210,7 +210,7 @@ static int32_t I2cServiceTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t struct HdfSBuf *reply = NULL; struct HdfIoService *service = NULL; - data = HdfSBufObtainDefaultSize(); + data = HdfSbufObtainDefaultSize(); if (data == NULL) { HDF_LOGE("I2cServiceTransfer: failed to obtain data!"); return HDF_ERR_MALLOC_FAIL; @@ -225,7 +225,7 @@ static int32_t I2cServiceTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t for (i = 0; i < count; i++) { recvLen += ((msgs[i].flags & I2C_FLAG_READ) == 0) ? 0 : (msgs[i].len + sizeof(uint64_t)); } - reply = (recvLen == 0) ? HdfSBufObtainDefaultSize() : HdfSBufObtain(recvLen); + reply = (recvLen == 0) ? HdfSbufObtainDefaultSize() : HdfSbufObtain(recvLen); if (reply == NULL) { HDF_LOGE("I2cServiceTransfer: failed to obtain reply!"); ret = HDF_ERR_MALLOC_FAIL; @@ -251,10 +251,10 @@ static int32_t I2cServiceTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t ret = count; __EXIT: if (data != NULL) { - HdfSBufRecycle(data); + HdfSbufRecycle(data); } if (reply != NULL) { - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); } return ret; } diff --git a/support/platform/src/pcie/pcie_if.c b/support/platform/src/pcie/pcie_if.c index df2c9a5c..99fb716f 100644 --- a/support/platform/src/pcie/pcie_if.c +++ b/support/platform/src/pcie/pcie_if.c @@ -68,7 +68,7 @@ static int32_t PcieUserRead(DevHandle handle, uint32_t pos, uint8_t *data, uint3 return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtainDefaultSize(); + buf = HdfSbufObtainDefaultSize(); if (buf == NULL) { HDF_LOGE("PcieUserRead: failed to obtain buf"); ret = HDF_ERR_MALLOC_FAIL; @@ -85,7 +85,7 @@ static int32_t PcieUserRead(DevHandle handle, uint32_t pos, uint8_t *data, uint3 goto EXIT; } - reply = HdfSBufObtainDefaultSize(); + reply = HdfSbufObtainDefaultSize(); if (reply == NULL) { HDF_LOGE("PcieUserRead: failed to obtain reply"); ret = HDF_ERR_MALLOC_FAIL; @@ -101,10 +101,10 @@ static int32_t PcieUserRead(DevHandle handle, uint32_t pos, uint8_t *data, uint3 EXIT : if (reply != NULL) { - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); } if (buf != NULL) { - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); } return ret; } @@ -119,7 +119,7 @@ static int32_t PcieUserWrite(DevHandle handle, uint32_t pos, uint8_t *data, uint HDF_LOGE("PcieUserWrite: service is invalid"); return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtainDefaultSize(); + buf = HdfSbufObtainDefaultSize(); if (buf == NULL) { HDF_LOGE("PcieUserWrite: failed to obtain buf"); return HDF_ERR_MALLOC_FAIL; @@ -140,7 +140,7 @@ static int32_t PcieUserWrite(DevHandle handle, uint32_t pos, uint8_t *data, uint HDF_LOGE("PcieUserWrite: failed to write, ret %d", ret); } EXIT: - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } #endif diff --git a/support/platform/src/uart/uart_if.c b/support/platform/src/uart/uart_if.c index 8ed38d0f..70a749aa 100644 --- a/support/platform/src/uart/uart_if.c +++ b/support/platform/src/uart/uart_if.c @@ -129,7 +129,7 @@ static int32_t UartUserReceive(DevHandle handle, void *data, uint32_t size, enum return HDF_ERR_INVALID_PARAM; } /* Four bytes are used to store the buffer length, and four bytes are used to align the memory. */ - reply = HdfSBufObtain(size + sizeof(uint64_t)); + reply = HdfSbufObtain(size + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -158,7 +158,7 @@ static int32_t UartUserReceive(DevHandle handle, void *data, uint32_t size, enum ret = rLen; } __EXIT: - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return ret; } @@ -172,14 +172,14 @@ static int32_t UartUserSend(DevHandle handle, void *data, uint32_t size, enum Ua HDF_LOGE("%s: service is invalid", __func__); return HDF_ERR_INVALID_PARAM; } - buf = HdfSBufObtain(size); + buf = HdfSbufObtain(size); if (buf == NULL) { HDF_LOGE("%s: failed to obtain buf", __func__); return HDF_ERR_MALLOC_FAIL; } if (!HdfSbufWriteBuffer(buf, data, size)) { HDF_LOGE("%s: sbuf write buffer failed", __func__); - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return HDF_ERR_IO; } @@ -187,7 +187,7 @@ static int32_t UartUserSend(DevHandle handle, void *data, uint32_t size, enum Ua if (ret != HDF_SUCCESS) { HDF_LOGE("%s: failed to write, ret %d", __func__, ret); } - HdfSBufRecycle(buf); + HdfSbufRecycle(buf); return ret; } #endif diff --git a/test/unittest/common/hdf_common_test.c b/test/unittest/common/hdf_common_test.c index 075d51a3..3cca7cb6 100644 --- a/test/unittest/common/hdf_common_test.c +++ b/test/unittest/common/hdf_common_test.c @@ -19,15 +19,15 @@ static struct HdfSBuf *g_reply = NULL; void HdfTestOpenService(void) { g_testService = HdfIoServiceBind(HDF_TEST_SERVICE_NAME); - g_msg = HdfSBufObtainDefaultSize(); + g_msg = HdfSbufObtainDefaultSize(); if (g_msg == NULL) { printf("fail to obtain sbuf data\n\r"); return; } - g_reply = HdfSBufObtainDefaultSize(); + g_reply = HdfSbufObtainDefaultSize(); if (g_reply == NULL) { printf("fail to obtain sbuf reply\n\r"); - HdfSBufRecycle(g_msg); + HdfSbufRecycle(g_msg); return; } } @@ -35,11 +35,11 @@ void HdfTestOpenService(void) void HdfTestCloseService(void) { if (g_msg != NULL) { - HdfSBufRecycle(g_msg); + HdfSbufRecycle(g_msg); g_msg = NULL; }; if (g_reply != NULL) { - HdfSBufRecycle(g_reply); + HdfSbufRecycle(g_reply); g_reply = NULL; }; if (g_testService != NULL) { diff --git a/test/unittest/model/network/wifi/unittest/message/hdf_single_node_message_test.c b/test/unittest/model/network/wifi/unittest/message/hdf_single_node_message_test.c index 92c875e9..0d0fc0e9 100644 --- a/test/unittest/model/network/wifi/unittest/message/hdf_single_node_message_test.c +++ b/test/unittest/model/network/wifi/unittest/message/hdf_single_node_message_test.c @@ -182,13 +182,13 @@ int32_t MessageSingleNodeTest002(void) MSG_BREAK_IF(errCode, g_serviceA == NULL); - rspData = HdfSBufObtainDefaultSize(); + rspData = HdfSbufObtainDefaultSize(); MSG_BREAK_IF_FUNCTION_FAILED(errCode, g_serviceA->SendSyncMessage(g_serviceA, SERVICE_ID_B, 0, NULL, rspData)); } while (false); if (rspData != NULL) { - HdfSBufRecycle(rspData); + HdfSbufRecycle(rspData); rspData = NULL; } @@ -212,8 +212,8 @@ int32_t MessageSingleNodeTest003(void) OsalTimespec diffTime; MSG_BREAK_IF_FUNCTION_FAILED(errCode, StartEnv()); MSG_BREAK_IF(errCode, g_serviceA == NULL); - rspData = HdfSBufObtainDefaultSize(); - sendData = HdfSBufObtainDefaultSize(); + rspData = HdfSbufObtainDefaultSize(); + sendData = HdfSbufObtainDefaultSize(); MSG_BREAK_IF_FUNCTION_FAILED(errCode, OsalGetTime(&startTime)); for (i = 0; i < SEND_MESSAGE_COUNT; i++) { @@ -229,12 +229,12 @@ int32_t MessageSingleNodeTest003(void) } while (false); if (rspData != NULL) { - HdfSBufRecycle(rspData); + HdfSbufRecycle(rspData); rspData = NULL; } if (sendData != NULL) { - HdfSBufRecycle(sendData); + HdfSbufRecycle(sendData); sendData = NULL; } diff --git a/test/unittest/platform/common/adc_test.c b/test/unittest/platform/common/adc_test.c index 3cdc10f0..cef8c160 100644 --- a/test/unittest/platform/common/adc_test.c +++ b/test/unittest/platform/common/adc_test.c @@ -37,7 +37,7 @@ static int32_t AdcTestGetConfig(struct AdcTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -51,22 +51,22 @@ static int32_t AdcTestGetConfig(struct AdcTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("%s: read buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("%s: config size:%zu, read size:%u", __func__, sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("%s: memcpy buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("%s: exit", __func__); return HDF_SUCCESS; } diff --git a/test/unittest/platform/common/dac_test.c b/test/unittest/platform/common/dac_test.c index c89a3eb1..140e69d5 100644 --- a/test/unittest/platform/common/dac_test.c +++ b/test/unittest/platform/common/dac_test.c @@ -32,7 +32,7 @@ static int32_t DacTestGetConfig(struct DacTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -46,22 +46,22 @@ static int32_t DacTestGetConfig(struct DacTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("%s: read buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("%s: config size:%zu, read size:%u", __func__, sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("%s: memcpy buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("%s: exit", __func__); return HDF_SUCCESS; } diff --git a/test/unittest/platform/common/gpio_test.c b/test/unittest/platform/common/gpio_test.c index 94c99ef9..2e19167a 100644 --- a/test/unittest/platform/common/gpio_test.c +++ b/test/unittest/platform/common/gpio_test.c @@ -35,7 +35,7 @@ static int32_t GpioTestGetConfig(struct GpioTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -48,23 +48,23 @@ static int32_t GpioTestGetConfig(struct GpioTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("%s: read buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("%s: config size:%u, but read size:%u!", __func__, sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("%s: memcpy buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("%s: exit", __func__); HdfIoServiceRecycle(service); return HDF_SUCCESS; diff --git a/test/unittest/platform/common/i2c_test.c b/test/unittest/platform/common/i2c_test.c index 2c6a9ed0..0c138649 100644 --- a/test/unittest/platform/common/i2c_test.c +++ b/test/unittest/platform/common/i2c_test.c @@ -44,7 +44,7 @@ static int32_t I2cTestGetConfig(struct I2cTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("I2cTestGetConfig: failed to obtain reply!"); return HDF_ERR_MALLOC_FAIL; @@ -57,23 +57,23 @@ static int32_t I2cTestGetConfig(struct I2cTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("I2cTestGetConfig: read buf fail!"); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("I2cTestGetConfig: config size:%u, but read size:%u!", sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("I2cTestGetConfig: memcpy buf fail!"); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("I2cTestGetConfig: exit!"); HdfIoServiceRecycle(service); return HDF_SUCCESS; diff --git a/test/unittest/platform/common/i3c_test.c b/test/unittest/platform/common/i3c_test.c index a84b8841..917b3c1e 100644 --- a/test/unittest/platform/common/i3c_test.c +++ b/test/unittest/platform/common/i3c_test.c @@ -50,7 +50,7 @@ static int32_t I3cTestGetTestConfig(struct I3cTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: Failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -64,22 +64,22 @@ static int32_t I3cTestGetTestConfig(struct I3cTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("%s: Read buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("%s: Config size:%zu, read size:%u", __func__, sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("%s: Memcpy buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("%s: Done", __func__); return HDF_SUCCESS; } diff --git a/test/unittest/platform/common/pin_test.c b/test/unittest/platform/common/pin_test.c index 2d3a6b30..197f7984 100644 --- a/test/unittest/platform/common/pin_test.c +++ b/test/unittest/platform/common/pin_test.c @@ -45,7 +45,7 @@ static int32_t PinTestGetTestConfig(struct PinTestConfig *config) return HDF_ERR_NOT_SUPPORT; } - reply = HdfSBufObtain(sizeof(*config) + sizeof(uint64_t)); + reply = HdfSbufObtain(sizeof(*config) + sizeof(uint64_t)); if (reply == NULL) { HDF_LOGE("%s: Failed to obtain reply", __func__); return HDF_ERR_MALLOC_FAIL; @@ -59,22 +59,22 @@ static int32_t PinTestGetTestConfig(struct PinTestConfig *config) if (!HdfSbufReadBuffer(reply, &buf, &len)) { HDF_LOGE("%s: Read buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (len != sizeof(*config)) { HDF_LOGE("%s: Config size:%zu, read size:%u", __func__, sizeof(*config), len); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } if (memcpy_s(config, sizeof(*config), buf, sizeof(*config)) != EOK) { HDF_LOGE("%s: Memcpy buf failed", __func__); - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); return HDF_ERR_IO; } - HdfSBufRecycle(reply); + HdfSbufRecycle(reply); HDF_LOGD("%s: Done", __func__); return HDF_SUCCESS; } diff --git a/tools/hdi-gen/ast/ast_interface_type.cpp b/tools/hdi-gen/ast/ast_interface_type.cpp index 79adb8a1..c58da66c 100755 --- a/tools/hdi-gen/ast/ast_interface_type.cpp +++ b/tools/hdi-gen/ast/ast_interface_type.cpp @@ -132,7 +132,7 @@ String ASTInterfaceType::EmitJavaType(TypeMode mode, bool isInnerType) const void ASTInterfaceType::EmitCWriteVar(const String& parcelName, const String& name, const String& gotoLabel, StringBuilder& sb, const String& prefix) const { - sb.Append(prefix).AppendFormat("if (HdfSBufWriteRemoteService(%s, %s->AsObject(%s)) != 0) {\n", + sb.Append(prefix).AppendFormat("if (HdfSbufWriteRemoteService(%s, %s->AsObject(%s)) != 0) {\n", parcelName.string(), name.string(), name.string()); sb.Append(prefix + g_tab).AppendFormat( "HDF_LOGE(\"%%{public}s: write %s failed!\", __func__);\n", name.string()); @@ -147,7 +147,7 @@ void ASTInterfaceType::EmitCStubReadVar(const String& parcelName, const String& String remoteName = String::Format("%sRemote", name.string()); String miName = name_.StartsWith("I") ? name_.Substring(1) : name_; - sb.Append(prefix).AppendFormat("struct HdfRemoteService *%s = HdfSBufReadRemoteService(%s);\n", + sb.Append(prefix).AppendFormat("struct HdfRemoteService *%s = HdfSbufReadRemoteService(%s);\n", remoteName.string(), parcelName.string()); sb.Append(prefix).AppendFormat("if (%s == NULL) {\n", remoteName.string()); sb.Append(prefix + g_tab).AppendFormat( diff --git a/tools/hdi-gen/codegen/c_client_proxy_code_emitter.cpp b/tools/hdi-gen/codegen/c_client_proxy_code_emitter.cpp index ae87d1df..75ae4b77 100755 --- a/tools/hdi-gen/codegen/c_client_proxy_code_emitter.cpp +++ b/tools/hdi-gen/codegen/c_client_proxy_code_emitter.cpp @@ -293,11 +293,11 @@ void CClientProxyCodeEmitter::EmitCreateBuf(const String& dataBufName, const Str StringBuilder& sb, const String& prefix) { if (isKernelCode_) { - sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSBufObtainDefaultSize();\n", dataBufName.string()); - sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSBufObtainDefaultSize();\n", replyBufName.string()); + sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSbufObtainDefaultSize();\n", dataBufName.string()); + sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSbufObtainDefaultSize();\n", replyBufName.string()); } else { - sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSBufTypedObtain(SBUF_IPC);\n", dataBufName.string()); - sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSBufTypedObtain(SBUF_IPC);\n", replyBufName.string()); + sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSbufTypedObtain(SBUF_IPC);\n", dataBufName.string()); + sb.Append(prefix).AppendFormat("struct HdfSBuf *%s = HdfSbufTypedObtain(SBUF_IPC);\n", replyBufName.string()); } sb.Append("\n"); @@ -312,10 +312,10 @@ void CClientProxyCodeEmitter::EmitReleaseBuf(const String& dataBufName, const St const String& prefix) { sb.Append(prefix).AppendFormat("if (%s != NULL) {\n", dataBufName.string()); - sb.Append(prefix + g_tab).AppendFormat("HdfSBufRecycle(%s);\n", dataBufName.string()); + sb.Append(prefix + g_tab).AppendFormat("HdfSbufRecycle(%s);\n", dataBufName.string()); sb.Append(prefix).Append("}\n"); sb.Append(prefix).AppendFormat("if (%s != NULL) {\n", replyBufName.string()); - sb.Append(prefix + g_tab).AppendFormat("HdfSBufRecycle(%s);\n", replyBufName.string()); + sb.Append(prefix + g_tab).AppendFormat("HdfSbufRecycle(%s);\n", replyBufName.string()); sb.Append(prefix).Append("}\n"); } diff --git a/utils/include/hdf_sbuf_impl.h b/utils/include/hdf_sbuf_impl.h index 4b7906ad..dfdec5f4 100644 --- a/utils/include/hdf_sbuf_impl.h +++ b/utils/include/hdf_sbuf_impl.h @@ -16,54 +16,54 @@ extern "C" { #endif /* __cplusplus */ struct HdfSbufConstructor { - struct HdfSbufImpl *(*obtain)(size_t capacity); - struct HdfSbufImpl *(*bind)(uintptr_t base, size_t size); + struct HdfSBufImpl *(*obtain)(size_t capacity); + struct HdfSBufImpl *(*bind)(uintptr_t base, size_t size); }; struct HdfRemoteService; -struct HdfSbufImpl { - bool (*writeBuffer)(struct HdfSbufImpl *sbuf, const uint8_t *data, uint32_t writeSize); - bool (*writeUnpadBuffer)(struct HdfSbufImpl *sbuf, const uint8_t *data, uint32_t writeSize); - bool (*writeUint64)(struct HdfSbufImpl *sbuf, uint64_t value); - bool (*writeUint32)(struct HdfSbufImpl *sbuf, uint32_t value); - bool (*writeUint16)(struct HdfSbufImpl *sbuf, uint16_t value); - bool (*writeUint8)(struct HdfSbufImpl *sbuf, uint8_t value); - bool (*writeInt64)(struct HdfSbufImpl *sbuf, int64_t value); - bool (*writeInt32)(struct HdfSbufImpl *sbuf, int32_t value); - bool (*writeInt16)(struct HdfSbufImpl *sbuf, int16_t value); - bool (*writeInt8)(struct HdfSbufImpl *sbuf, int8_t value); - bool (*writeString)(struct HdfSbufImpl *sbuf, const char *value); - bool (*writeFileDescriptor)(struct HdfSbufImpl *sbuf, int fd); - bool (*writeFloat)(struct HdfSbufImpl *sbuf, float value); - bool (*writeDouble)(struct HdfSbufImpl *sbuf, double value); - bool (*readDouble)(struct HdfSbufImpl *sbuf, double *value); - bool (*readFloat)(struct HdfSbufImpl *sbuf, float *value); - int (*readFileDescriptor)(struct HdfSbufImpl *sbuf); - bool (*writeString16)(struct HdfSbufImpl *sbuf, const char16_t *value, uint32_t size); - bool (*readBuffer)(struct HdfSbufImpl *sbuf, const uint8_t **data, uint32_t *readSize); - const uint8_t *(*readUnpadBuffer)(struct HdfSbufImpl *sbuf, size_t length); - bool (*readUint64)(struct HdfSbufImpl *sbuf, uint64_t *value); - bool (*readUint32)(struct HdfSbufImpl *sbuf, uint32_t *value); - bool (*readUint16)(struct HdfSbufImpl *sbuf, uint16_t *value); - bool (*readUint8)(struct HdfSbufImpl *sbuf, uint8_t *value); - bool (*readInt64)(struct HdfSbufImpl *sbuf, int64_t *value); - bool (*readInt32)(struct HdfSbufImpl *sbuf, int32_t *value); - bool (*readInt16)(struct HdfSbufImpl *sbuf, int16_t *value); - bool (*readInt8)(struct HdfSbufImpl *sbuf, int8_t *value); - const char *(*readString)(struct HdfSbufImpl *sbuf); - const char16_t *(*readString16)(struct HdfSbufImpl *sbuf); - int32_t (*writeRemoteService)(struct HdfSbufImpl *sbuf, const struct HdfRemoteService *service); - struct HdfRemoteService *(*readRemoteService)(struct HdfSbufImpl *sbuf); - const uint8_t *(*getData)(const struct HdfSbufImpl *sbuf); - void (*flush)(struct HdfSbufImpl *sbuf); - size_t (*getCapacity)(const struct HdfSbufImpl *sbuf); - size_t (*getDataSize)(const struct HdfSbufImpl *sbuf); - void (*setDataSize)(struct HdfSbufImpl *sbuf, size_t size); - void (*recycle)(struct HdfSbufImpl *sbuf); - struct HdfSbufImpl *(*move)(struct HdfSbufImpl *sbuf); - struct HdfSbufImpl *(*copy)(const struct HdfSbufImpl *sbuf); - void (*transDataOwnership)(struct HdfSbufImpl *sbuf); +struct HdfSBufImpl { + bool (*writeBuffer)(struct HdfSBufImpl *sbuf, const uint8_t *data, uint32_t writeSize); + bool (*writeUnpadBuffer)(struct HdfSBufImpl *sbuf, const uint8_t *data, uint32_t writeSize); + bool (*writeUint64)(struct HdfSBufImpl *sbuf, uint64_t value); + bool (*writeUint32)(struct HdfSBufImpl *sbuf, uint32_t value); + bool (*writeUint16)(struct HdfSBufImpl *sbuf, uint16_t value); + bool (*writeUint8)(struct HdfSBufImpl *sbuf, uint8_t value); + bool (*writeInt64)(struct HdfSBufImpl *sbuf, int64_t value); + bool (*writeInt32)(struct HdfSBufImpl *sbuf, int32_t value); + bool (*writeInt16)(struct HdfSBufImpl *sbuf, int16_t value); + bool (*writeInt8)(struct HdfSBufImpl *sbuf, int8_t value); + bool (*writeString)(struct HdfSBufImpl *sbuf, const char *value); + bool (*writeFileDescriptor)(struct HdfSBufImpl *sbuf, int fd); + bool (*writeFloat)(struct HdfSBufImpl *sbuf, float value); + bool (*writeDouble)(struct HdfSBufImpl *sbuf, double value); + bool (*readDouble)(struct HdfSBufImpl *sbuf, double *value); + bool (*readFloat)(struct HdfSBufImpl *sbuf, float *value); + int (*readFileDescriptor)(struct HdfSBufImpl *sbuf); + bool (*writeString16)(struct HdfSBufImpl *sbuf, const char16_t *value, uint32_t size); + bool (*readBuffer)(struct HdfSBufImpl *sbuf, const uint8_t **data, uint32_t *readSize); + const uint8_t *(*readUnpadBuffer)(struct HdfSBufImpl *sbuf, size_t length); + bool (*readUint64)(struct HdfSBufImpl *sbuf, uint64_t *value); + bool (*readUint32)(struct HdfSBufImpl *sbuf, uint32_t *value); + bool (*readUint16)(struct HdfSBufImpl *sbuf, uint16_t *value); + bool (*readUint8)(struct HdfSBufImpl *sbuf, uint8_t *value); + bool (*readInt64)(struct HdfSBufImpl *sbuf, int64_t *value); + bool (*readInt32)(struct HdfSBufImpl *sbuf, int32_t *value); + bool (*readInt16)(struct HdfSBufImpl *sbuf, int16_t *value); + bool (*readInt8)(struct HdfSBufImpl *sbuf, int8_t *value); + const char *(*readString)(struct HdfSBufImpl *sbuf); + const char16_t *(*readString16)(struct HdfSBufImpl *sbuf); + int32_t (*writeRemoteService)(struct HdfSBufImpl *sbuf, const struct HdfRemoteService *service); + struct HdfRemoteService *(*readRemoteService)(struct HdfSBufImpl *sbuf); + const uint8_t *(*getData)(const struct HdfSBufImpl *sbuf); + void (*flush)(struct HdfSBufImpl *sbuf); + size_t (*getCapacity)(const struct HdfSBufImpl *sbuf); + size_t (*getDataSize)(const struct HdfSBufImpl *sbuf); + void (*setDataSize)(struct HdfSBufImpl *sbuf, size_t size); + void (*recycle)(struct HdfSBufImpl *sbuf); + struct HdfSBufImpl *(*move)(struct HdfSBufImpl *sbuf); + struct HdfSBufImpl *(*copy)(const struct HdfSBufImpl *sbuf); + void (*transDataOwnership)(struct HdfSBufImpl *sbuf); }; #ifdef __cplusplus diff --git a/utils/src/hdf_sbuf.c b/utils/src/hdf_sbuf.c index 2db96ff6..61cf1d16 100644 --- a/utils/src/hdf_sbuf.c +++ b/utils/src/hdf_sbuf.c @@ -37,16 +37,16 @@ } while (0) struct HdfSBuf { - struct HdfSbufImpl *impl; + struct HdfSBufImpl *impl; uint32_t type; }; -struct HdfSbufImpl *SbufObtainRaw(size_t capacity); -struct HdfSbufImpl *SbufBindRaw(uintptr_t base, size_t size); -struct HdfSbufImpl *SbufObtainIpc(size_t capacity) __attribute__((weak)); -struct HdfSbufImpl *SbufBindIpc(uintptr_t base, size_t size) __attribute__((weak)); -struct HdfSbufImpl *SbufObtainIpcHw(size_t capacity) __attribute__((weak)); -struct HdfSbufImpl *SbufBindRawIpcHw(uintptr_t base, size_t size) __attribute__((weak)); +struct HdfSBufImpl *SbufObtainRaw(size_t capacity); +struct HdfSBufImpl *SbufBindRaw(uintptr_t base, size_t size); +struct HdfSBufImpl *SbufObtainIpc(size_t capacity) __attribute__((weak)); +struct HdfSBufImpl *SbufBindIpc(uintptr_t base, size_t size) __attribute__((weak)); +struct HdfSBufImpl *SbufObtainIpcHw(size_t capacity) __attribute__((weak)); +struct HdfSBufImpl *SbufBindRawIpcHw(uintptr_t base, size_t size) __attribute__((weak)); static const struct HdfSbufConstructor g_sbufConstructorMap[SBUF_TYPE_MAX] = { [SBUF_RAW] = { @@ -250,19 +250,19 @@ bool HdfSBufWriteString16(struct HdfSBuf *sbuf, const char16_t *value, uint32_t return sbuf->impl->writeString16(sbuf->impl, value, size); } -const char16_t *HdfSBufReadString16(struct HdfSBuf *sbuf) +const char16_t *HdfSbufReadString16(struct HdfSBuf *sbuf) { HDF_SBUF_IMPL_CHECK_RETURN(sbuf, readString16, NULL); return sbuf->impl->readString16(sbuf->impl); } -int32_t HdfSBufWriteRemoteService(struct HdfSBuf *sbuf, const struct HdfRemoteService *service) +int32_t HdfSbufWriteRemoteService(struct HdfSBuf *sbuf, const struct HdfRemoteService *service) { HDF_SBUF_IMPL_CHECK_RETURN(sbuf, writeRemoteService, false); return sbuf->impl->writeRemoteService(sbuf->impl, service); } -struct HdfRemoteService *HdfSBufReadRemoteService(struct HdfSBuf *sbuf) +struct HdfRemoteService *HdfSbufReadRemoteService(struct HdfSBuf *sbuf) { HDF_SBUF_IMPL_CHECK_RETURN(sbuf, readRemoteService, NULL); return sbuf->impl->readRemoteService(sbuf->impl); @@ -304,7 +304,7 @@ bool HdfSbufReadFloat(struct HdfSBuf *sbuf, float *data) return sbuf->impl->readFloat(sbuf->impl, data); } -struct HdfSBuf *HdfSBufTypedObtainCapacity(uint32_t type, size_t capacity) +struct HdfSBuf *HdfSbufTypedObtainCapacity(uint32_t type, size_t capacity) { struct HdfSBuf *sbuf = NULL; const struct HdfSbufConstructor *constructor = HdfSbufConstructorGet(type); @@ -333,7 +333,7 @@ struct HdfSBuf *HdfSBufTypedObtainCapacity(uint32_t type, size_t capacity) return sbuf; } -struct HdfSBuf *HdfSBufTypedObtainInplace(uint32_t type, struct HdfSbufImpl *impl) +struct HdfSBuf *HdfSbufTypedObtainInplace(uint32_t type, struct HdfSBufImpl *impl) { struct HdfSBuf *sbuf = NULL; if (type >= SBUF_TYPE_MAX || impl == NULL) { @@ -351,12 +351,12 @@ struct HdfSBuf *HdfSBufTypedObtainInplace(uint32_t type, struct HdfSbufImpl *imp return sbuf; } -struct HdfSBuf *HdfSBufTypedObtain(uint32_t type) +struct HdfSBuf *HdfSbufTypedObtain(uint32_t type) { - return HdfSBufTypedObtainCapacity(type, HDF_SBUF_DEFAULT_SIZE); + return HdfSbufTypedObtainCapacity(type, HDF_SBUF_DEFAULT_SIZE); } -struct HdfSBuf *HdfSBufTypedBind(uint32_t type, uintptr_t base, size_t size) +struct HdfSBuf *HdfSbufTypedBind(uint32_t type, uintptr_t base, size_t size) { struct HdfSBuf *sbuf = NULL; const struct HdfSbufConstructor *constructor = HdfSbufConstructorGet(type); @@ -386,22 +386,27 @@ struct HdfSBuf *HdfSBufTypedBind(uint32_t type, uintptr_t base, size_t size) return sbuf; } -struct HdfSBuf *HdfSBufObtain(size_t capacity) +struct HdfSBuf *HdfSbufObtain(size_t capacity) { - return HdfSBufTypedObtainCapacity(SBUF_RAW, capacity); + return HdfSbufTypedObtainCapacity(SBUF_RAW, capacity); +} + +struct HdfSBuf *HdfSbufObtainDefaultSize() +{ + return HdfSbufObtain(HDF_SBUF_DEFAULT_SIZE); } struct HdfSBuf *HdfSBufObtainDefaultSize() { - return HdfSBufObtain(HDF_SBUF_DEFAULT_SIZE); + return HdfSbufObtain(HDF_SBUF_DEFAULT_SIZE); } -struct HdfSBuf *HdfSBufBind(uintptr_t base, size_t size) +struct HdfSBuf *HdfSbufBind(uintptr_t base, size_t size) { - return HdfSBufTypedBind(SBUF_RAW, base, size); + return HdfSbufTypedBind(SBUF_RAW, base, size); } -struct HdfSBuf *HdfSBufCopy(const struct HdfSBuf *sbuf) +struct HdfSBuf *HdfSbufCopy(const struct HdfSBuf *sbuf) { struct HdfSBuf *newBuf = NULL; HDF_SBUF_IMPL_CHECK_RETURN(sbuf, copy, NULL); @@ -418,7 +423,7 @@ struct HdfSBuf *HdfSBufCopy(const struct HdfSBuf *sbuf) return newBuf; } -struct HdfSBuf *HdfSBufMove(struct HdfSBuf *sbuf) +struct HdfSBuf *HdfSbufMove(struct HdfSBuf *sbuf) { struct HdfSBuf *newBuf = NULL; HDF_SBUF_IMPL_CHECK_RETURN(sbuf, move, NULL); @@ -440,6 +445,17 @@ void HdfSbufTransDataOwnership(struct HdfSBuf *sbuf) sbuf->impl->transDataOwnership(sbuf->impl); } +void HdfSbufRecycle(struct HdfSBuf *sbuf) +{ + if (sbuf != NULL) { + if (sbuf->impl != NULL && sbuf->impl->recycle != NULL) { + sbuf->impl->recycle(sbuf->impl); + sbuf->impl = NULL; + } + OsalMemFree(sbuf); + } +} + void HdfSBufRecycle(struct HdfSBuf *sbuf) { if (sbuf != NULL) { @@ -451,7 +467,7 @@ void HdfSBufRecycle(struct HdfSBuf *sbuf) } } -struct HdfSbufImpl *HdfSbufGetImpl(struct HdfSBuf *sbuf) +struct HdfSBufImpl *HdfSbufGetImpl(struct HdfSBuf *sbuf) { if (sbuf != NULL) { return sbuf->impl; diff --git a/utils/src/hdf_sbuf_impl_raw.c b/utils/src/hdf_sbuf_impl_raw.c index 24423d11..1facdb7d 100644 --- a/utils/src/hdf_sbuf_impl_raw.c +++ b/utils/src/hdf_sbuf_impl_raw.c @@ -25,7 +25,7 @@ #endif // INT16_MAX struct HdfSBufRaw { - struct HdfSbufImpl infImpl; + struct HdfSBufImpl infImpl; size_t writePos; /**< Current write position */ size_t readPos; /**< Current read position */ size_t capacity; /**< Storage capacity, 512 KB at most. */ @@ -36,14 +36,14 @@ struct HdfSBufRaw { #define SBUF_RAW_CAST(impl) (struct HdfSBufRaw *)(impl) static struct HdfSBufRaw *SbufRawImplNewInstance(size_t capacity); -static void SbufInterfaceAssign(struct HdfSbufImpl *inf); +static void SbufInterfaceAssign(struct HdfSBufImpl *inf); static size_t SbufRawImplGetAlignSize(size_t size) { return (size + HDF_SBUF_ALIGN - 1) & (~(HDF_SBUF_ALIGN - 1)); } -static void SbufRawImplRecycle(struct HdfSbufImpl *impl) +static void SbufRawImplRecycle(struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); if (sbuf != NULL) { @@ -64,7 +64,7 @@ static size_t SbufRawImplGetLeftReadSize(struct HdfSBufRaw *sbuf) return (sbuf->writePos < sbuf->readPos) ? 0 : (sbuf->writePos - sbuf->readPos); } -static bool SbufRawImplWriteRollback(struct HdfSbufImpl *impl, uint32_t size) +static bool SbufRawImplWriteRollback(struct HdfSBufImpl *impl, uint32_t size) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); size_t alignSize; @@ -81,7 +81,7 @@ static bool SbufRawImplWriteRollback(struct HdfSbufImpl *impl, uint32_t size) return true; } -static bool SbufRawImplReadRollback(struct HdfSbufImpl *impl, uint32_t size) +static bool SbufRawImplReadRollback(struct HdfSBufImpl *impl, uint32_t size) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); size_t alignSize; @@ -98,7 +98,7 @@ static bool SbufRawImplReadRollback(struct HdfSbufImpl *impl, uint32_t size) return true; } -static const uint8_t *SbufRawImplGetData(const struct HdfSbufImpl *impl) +static const uint8_t *SbufRawImplGetData(const struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); if (sbuf == NULL) { @@ -108,7 +108,7 @@ static const uint8_t *SbufRawImplGetData(const struct HdfSbufImpl *impl) return (uint8_t *)sbuf->data; } -static void SbufRawImplSetDataSize(struct HdfSbufImpl *impl, size_t size) +static void SbufRawImplSetDataSize(struct HdfSBufImpl *impl, size_t size) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); if (sbuf == NULL) { @@ -120,7 +120,7 @@ static void SbufRawImplSetDataSize(struct HdfSbufImpl *impl, size_t size) } } -static void SbufRawImplFlush(struct HdfSbufImpl *impl) +static void SbufRawImplFlush(struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); if (sbuf != NULL) { @@ -129,13 +129,13 @@ static void SbufRawImplFlush(struct HdfSbufImpl *impl) } } -static size_t SbufRawImplGetCapacity(const struct HdfSbufImpl *impl) +static size_t SbufRawImplGetCapacity(const struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); return (sbuf != NULL) ? sbuf->capacity : 0; } -static size_t SbufRawImplGetDataSize(const struct HdfSbufImpl *impl) +static size_t SbufRawImplGetDataSize(const struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); return (sbuf != NULL) ? sbuf->writePos : 0; @@ -180,7 +180,7 @@ static bool SbufRawImplGrow(struct HdfSBufRaw *sbuf, uint32_t growSize) return true; } -static bool SbufRawImplWrite(struct HdfSbufImpl *impl, const uint8_t *data, uint32_t size) +static bool SbufRawImplWrite(struct HdfSBufImpl *impl, const uint8_t *data, uint32_t size) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); size_t alignSize; @@ -220,7 +220,7 @@ static bool SbufRawImplWrite(struct HdfSbufImpl *impl, const uint8_t *data, uint return true; } -static bool SbufRawImplRead(struct HdfSbufImpl *impl, uint8_t *data, uint32_t readSize) +static bool SbufRawImplRead(struct HdfSBufImpl *impl, uint8_t *data, uint32_t readSize) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); size_t alignSize; @@ -245,47 +245,47 @@ static bool SbufRawImplRead(struct HdfSbufImpl *impl, uint8_t *data, uint32_t re return true; } -static bool SbufRawImplWriteUint64(struct HdfSbufImpl *impl, uint64_t value) +static bool SbufRawImplWriteUint64(struct HdfSBufImpl *impl, uint64_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteUint32(struct HdfSbufImpl *impl, uint32_t value) +static bool SbufRawImplWriteUint32(struct HdfSBufImpl *impl, uint32_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteUint16(struct HdfSbufImpl *impl, uint16_t value) +static bool SbufRawImplWriteUint16(struct HdfSBufImpl *impl, uint16_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteUint8(struct HdfSbufImpl *impl, uint8_t value) +static bool SbufRawImplWriteUint8(struct HdfSBufImpl *impl, uint8_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteInt64(struct HdfSbufImpl *impl, int64_t value) +static bool SbufRawImplWriteInt64(struct HdfSBufImpl *impl, int64_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteInt32(struct HdfSbufImpl *impl, int32_t value) +static bool SbufRawImplWriteInt32(struct HdfSBufImpl *impl, int32_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteInt16(struct HdfSbufImpl *impl, int16_t value) +static bool SbufRawImplWriteInt16(struct HdfSBufImpl *impl, int16_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteInt8(struct HdfSbufImpl *impl, int8_t value) +static bool SbufRawImplWriteInt8(struct HdfSBufImpl *impl, int8_t value) { return SbufRawImplWrite(impl, (uint8_t *)(&value), sizeof(value)); } -static bool SbufRawImplWriteBuffer(struct HdfSbufImpl *impl, const uint8_t *data, uint32_t writeSize) +static bool SbufRawImplWriteBuffer(struct HdfSBufImpl *impl, const uint8_t *data, uint32_t writeSize) { if (impl == NULL) { HDF_LOGE("Failed to write the Sbuf, invalid input params"); @@ -306,7 +306,7 @@ static bool SbufRawImplWriteBuffer(struct HdfSbufImpl *impl, const uint8_t *data return true; } -static bool SbufRawImplWriteString(struct HdfSbufImpl *impl, const char *value) +static bool SbufRawImplWriteString(struct HdfSBufImpl *impl, const char *value) { if (impl == NULL) { HDF_LOGE("%s: input null", __func__); @@ -316,47 +316,47 @@ static bool SbufRawImplWriteString(struct HdfSbufImpl *impl, const char *value) return SbufRawImplWriteBuffer(impl, (const uint8_t *)value, value ? (strlen(value) + 1) : 0); } -static bool SbufRawImplReadUint64(struct HdfSbufImpl *impl, uint64_t *value) +static bool SbufRawImplReadUint64(struct HdfSBufImpl *impl, uint64_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadUint32(struct HdfSbufImpl *impl, uint32_t *value) +static bool SbufRawImplReadUint32(struct HdfSBufImpl *impl, uint32_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadUint16(struct HdfSbufImpl *impl, uint16_t *value) +static bool SbufRawImplReadUint16(struct HdfSBufImpl *impl, uint16_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadUint8(struct HdfSbufImpl *impl, uint8_t *value) +static bool SbufRawImplReadUint8(struct HdfSBufImpl *impl, uint8_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadInt64(struct HdfSbufImpl *impl, int64_t *value) +static bool SbufRawImplReadInt64(struct HdfSBufImpl *impl, int64_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadInt32(struct HdfSbufImpl *impl, int32_t *value) +static bool SbufRawImplReadInt32(struct HdfSBufImpl *impl, int32_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadInt16(struct HdfSbufImpl *impl, int16_t *value) +static bool SbufRawImplReadInt16(struct HdfSBufImpl *impl, int16_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadInt8(struct HdfSbufImpl *impl, int8_t *value) +static bool SbufRawImplReadInt8(struct HdfSBufImpl *impl, int8_t *value) { return SbufRawImplRead(impl, (uint8_t *)(value), sizeof(*value)); } -static bool SbufRawImplReadBuffer(struct HdfSbufImpl *impl, const uint8_t **data, uint32_t *readSize) +static bool SbufRawImplReadBuffer(struct HdfSBufImpl *impl, const uint8_t **data, uint32_t *readSize) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); int buffSize = 0; @@ -388,7 +388,7 @@ static bool SbufRawImplReadBuffer(struct HdfSbufImpl *impl, const uint8_t **data return true; } -static const char *SbufRawImplReadString(struct HdfSbufImpl *impl) +static const char *SbufRawImplReadString(struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); int32_t strLen = 0; @@ -415,7 +415,7 @@ static const char *SbufRawImplReadString(struct HdfSbufImpl *impl) return str; } -static struct HdfSbufImpl *SbufRawImplCopy(const struct HdfSbufImpl *impl) +static struct HdfSBufImpl *SbufRawImplCopy(const struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); struct HdfSBufRaw *new = NULL; @@ -438,7 +438,7 @@ static struct HdfSbufImpl *SbufRawImplCopy(const struct HdfSbufImpl *impl) return &new->infImpl; } -static struct HdfSbufImpl *SbufRawImplMove(struct HdfSbufImpl *impl) +static struct HdfSBufImpl *SbufRawImplMove(struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); struct HdfSBufRaw *new = NULL; @@ -463,7 +463,7 @@ static struct HdfSbufImpl *SbufRawImplMove(struct HdfSbufImpl *impl) return &new->infImpl; } -static void SbufRawImplTransDataOwnership(struct HdfSbufImpl *impl) +static void SbufRawImplTransDataOwnership(struct HdfSBufImpl *impl) { struct HdfSBufRaw *sbuf = SBUF_RAW_CAST(impl); if (sbuf == NULL) { @@ -473,7 +473,7 @@ static void SbufRawImplTransDataOwnership(struct HdfSbufImpl *impl) sbuf->isBind = false; } -static void SbufInterfaceAssign(struct HdfSbufImpl *inf) +static void SbufInterfaceAssign(struct HdfSBufImpl *inf) { inf->writeBuffer = SbufRawImplWriteBuffer; inf->writeUint64 = SbufRawImplWriteUint64; @@ -533,7 +533,7 @@ static struct HdfSBufRaw *SbufRawImplNewInstance(size_t capacity) return sbuf; } -struct HdfSbufImpl *SbufObtainRaw(size_t capacity) +struct HdfSBufImpl *SbufObtainRaw(size_t capacity) { struct HdfSBufRaw *sbuf = SbufRawImplNewInstance(capacity); if (sbuf == NULL) { @@ -542,7 +542,7 @@ struct HdfSbufImpl *SbufObtainRaw(size_t capacity) return &sbuf->infImpl; } -struct HdfSbufImpl *SbufBindRaw(uintptr_t base, size_t size) +struct HdfSBufImpl *SbufBindRaw(uintptr_t base, size_t size) { struct HdfSBufRaw *sbuf = NULL; if (base == 0 || size == 0) {