From bb0c6c94a781f47b8c253c80cae9651f7de0bdad Mon Sep 17 00:00:00 2001 From: zhanghaitao Date: Tue, 20 Sep 2022 00:00:17 +0800 Subject: [PATCH 1/3] fix MEMOEY to MEMORY Signed-off-by: zht --- libpurgeablemem/c/include/purgeable_mem_builder_c.h | 6 +++--- libpurgeablemem/c/include/purgeable_mem_c.h | 8 ++++---- libpurgeablemem/common/include/pm_ptr_util.h | 6 +++--- libpurgeablemem/common/include/pm_state_c.h | 6 +++--- libpurgeablemem/common/include/pm_util.h | 6 +++--- libpurgeablemem/common/include/ux_page_table_c.h | 6 +++--- libpurgeablemem/cpp/include/purgeable_mem.h | 6 +++--- libpurgeablemem/cpp/include/purgeable_mem_builder.h | 6 +++--- libpurgeablemem/cpp/include/ux_page_table.h | 6 +++--- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/libpurgeablemem/c/include/purgeable_mem_builder_c.h b/libpurgeablemem/c/include/purgeable_mem_builder_c.h index 2ccd331..488e5b2 100644 --- a/libpurgeablemem/c/include/purgeable_mem_builder_c.h +++ b/libpurgeablemem/c/include/purgeable_mem_builder_c.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H #include @@ -49,4 +49,4 @@ bool PurgMemBuilderBuildAll(struct PurgMemBuilder *builder, void *data, size_t s #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_BUILDER_C_H */ diff --git a/libpurgeablemem/c/include/purgeable_mem_c.h b/libpurgeablemem/c/include/purgeable_mem_c.h index 3628ac7..fb34147 100644 --- a/libpurgeablemem/c/include/purgeable_mem_c.h +++ b/libpurgeablemem/c/include/purgeable_mem_c.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H #include /* bool */ #include /* size_t */ @@ -30,7 +30,7 @@ struct PurgMem; /* * Function pointer, it points to a function which build content of a PurgMem obj. - * Input: void *: data ptr, ponits to start address of a PurgMem obj's content. + * Input: void *: data ptr, points to start address of a PurgMem obj's content. * Input: size_t: data size of the content. * Input: void *: other private parameters. * Return: build content result, true means success, while false is fail. @@ -128,4 +128,4 @@ bool PurgMemAppendModify(struct PurgMem *purgObj, PurgMemModifyFunc func, void * #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEM_C_H */ diff --git a/libpurgeablemem/common/include/pm_ptr_util.h b/libpurgeablemem/common/include/pm_ptr_util.h index 75d7f76..6180d6a 100644 --- a/libpurgeablemem/common/include/pm_ptr_util.h +++ b/libpurgeablemem/common/include/pm_ptr_util.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H #include "hilog/log_c.h" @@ -33,4 +33,4 @@ } \ } while (0) -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_PTR_UTIL_H */ diff --git a/libpurgeablemem/common/include/pm_state_c.h b/libpurgeablemem/common/include/pm_state_c.h index 90b2057..e18254d 100644 --- a/libpurgeablemem/common/include/pm_state_c.h +++ b/libpurgeablemem/common/include/pm_state_c.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H #ifdef __cplusplus #if __cplusplus @@ -64,4 +64,4 @@ const char *GetPMStateName(PMState state); #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_STATE_C_H */ diff --git a/libpurgeablemem/common/include/pm_util.h b/libpurgeablemem/common/include/pm_util.h index 9442325..954e7ee 100644 --- a/libpurgeablemem/common/include/pm_util.h +++ b/libpurgeablemem/common/include/pm_util.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H #ifdef __cplusplus #if __cplusplus @@ -57,4 +57,4 @@ extern "C" { #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_PM_UTIL_H */ diff --git a/libpurgeablemem/common/include/ux_page_table_c.h b/libpurgeablemem/common/include/ux_page_table_c.h index cbfdc1d..1ee3625 100644 --- a/libpurgeablemem/common/include/ux_page_table_c.h +++ b/libpurgeablemem/common/include/ux_page_table_c.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H #include /* uint64_t */ #include /* bool */ @@ -46,4 +46,4 @@ bool UxpteIsPresent(UxPageTableStruct *upt, uint64_t addr, size_t len); } #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_COMMON_INCLUDE_UX_PAGE_TABLE_C_H */ diff --git a/libpurgeablemem/cpp/include/purgeable_mem.h b/libpurgeablemem/cpp/include/purgeable_mem.h index 9f2d461..c77e91b 100644 --- a/libpurgeablemem/cpp/include/purgeable_mem.h +++ b/libpurgeablemem/cpp/include/purgeable_mem.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H #include /* unique_ptr */ #include /* shared_mutex */ @@ -113,4 +113,4 @@ private: }; } /* namespace PurgeableMem */ } /* namespace OHOS */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_H */ diff --git a/libpurgeablemem/cpp/include/purgeable_mem_builder.h b/libpurgeablemem/cpp/include/purgeable_mem_builder.h index b8e9269..7b09b4f 100644 --- a/libpurgeablemem/cpp/include/purgeable_mem_builder.h +++ b/libpurgeablemem/cpp/include/purgeable_mem_builder.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H #include /* unique_ptr */ @@ -47,4 +47,4 @@ private: }; } /* namespace PurgeableMem */ } /* namespace OHOS */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_PURGEABLE_MEM_BUILDER_H */ diff --git a/libpurgeablemem/cpp/include/ux_page_table.h b/libpurgeablemem/cpp/include/ux_page_table.h index 301640a..a0481be 100644 --- a/libpurgeablemem/cpp/include/ux_page_table.h +++ b/libpurgeablemem/cpp/include/ux_page_table.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H -#define OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H #include /* std::string */ @@ -38,4 +38,4 @@ private: }; } /* namespace PurgeableMem */ } /* namespace OHOS */ -#endif /* OHOS_UTILS_MEMOEY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H */ +#endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_CPP_INCLUDE_UX_PAGE_TABLE_H */ -- Gitee From 60bc787497f03c5911e481d891a976e63b9c58ba Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Tue, 20 Sep 2022 22:24:24 +0800 Subject: [PATCH 2/3] feat: move from dmabuf_alloc.c to dmabuff_alloc.h Signed-off-by: Caoruihong --- libdmabufheap/include/dmabuf_alloc.h | 1 + libdmabufheap/src/dmabuf_alloc.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libdmabufheap/include/dmabuf_alloc.h b/libdmabufheap/include/dmabuf_alloc.h index 07ec54b..e823319 100644 --- a/libdmabufheap/include/dmabuf_alloc.h +++ b/libdmabufheap/include/dmabuf_alloc.h @@ -18,6 +18,7 @@ #include #include +#include #undef LOG_TAG #define LOG_TAG "dmabufheap" diff --git a/libdmabufheap/src/dmabuf_alloc.c b/libdmabufheap/src/dmabuf_alloc.c index e20a781..b283b78 100644 --- a/libdmabufheap/src/dmabuf_alloc.c +++ b/libdmabufheap/src/dmabuf_alloc.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include "securec.h" #include "hilog/log.h" #include "dmabuf_alloc.h" -- Gitee From 031a0ab5019441315cedb98ddc4a8c7b40f797cd Mon Sep 17 00:00:00 2001 From: Yuanzheng Song Date: Tue, 27 Sep 2022 04:19:51 +0000 Subject: [PATCH 3/3] use sprintf_s instead of sprint in usecase of the libdmabufheap issue: #I5TC7S Signed-off-by: Yuanzheng Song --- libdmabufheap/test/BUILD.gn | 1 + .../test/unittest/libdmabufheap/dmabuf_alloc_test.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libdmabufheap/test/BUILD.gn b/libdmabufheap/test/BUILD.gn index 4f525f3..7aceed6 100644 --- a/libdmabufheap/test/BUILD.gn +++ b/libdmabufheap/test/BUILD.gn @@ -19,6 +19,7 @@ ohos_unittest("DmabufAllocTest") { module_out_path = module_output_path sources = [ "unittest/libdmabufheap/dmabuf_alloc_test.cpp" ] deps = [ "//utils/memory/libdmabufheap:libdmabufheap" ] + external_deps = [ "c_utils:utils" ] } group("unittest") { diff --git a/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp b/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp index 0cd07b3..a47c608 100644 --- a/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp +++ b/libdmabufheap/test/unittest/libdmabufheap/dmabuf_alloc_test.cpp @@ -23,6 +23,7 @@ #include #include #include +#include "securec.h" #include "gtest/gtest.h" #include "dmabuf_alloc.h" @@ -69,7 +70,7 @@ HWTEST_F(DmabufAllocTest, AllocSingleBuffer, TestSize.Level1) ASSERT_EQ(0, DmabufHeapBufferSyncStart(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); - ASSERT_GE(sprintf((char *)ptr, "libdmabufheap"), 0); + ASSERT_GE(sprintf_s((char *)ptr, BUFFER_SIZE, "libdmabufheap"), 0); ASSERT_EQ(0, DmabufHeapBufferSyncEnd(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); @@ -95,7 +96,7 @@ HWTEST_F(DmabufAllocTest, ShareBufferBetweenProcess, Function|MediumTest|Level1) ASSERT_EQ(0, DmabufHeapBufferSyncStart(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); - ASSERT_GE(sprintf((char *)ptr, "parent"), 0); + ASSERT_GE(sprintf_s((char *)ptr, BUFFER_SIZE, "parent"), 0); ASSERT_EQ(0, DmabufHeapBufferSyncEnd(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); @@ -110,7 +111,7 @@ HWTEST_F(DmabufAllocTest, ShareBufferBetweenProcess, Function|MediumTest|Level1) ASSERT_STREQ("parent", (char *)ptr); - ASSERT_GE(sprintf((char *)ptr, "child"), 0); + ASSERT_GE(sprintf_s((char *)ptr, BUFFER_SIZE, "child"), 0); ASSERT_EQ(0, DmabufHeapBufferSyncEnd(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); @@ -224,7 +225,7 @@ HWTEST_F(DmabufAllocTest, SyncBufferTwice, Function|MediumTest|Level1) ASSERT_EQ(0, DmabufHeapBufferSyncStart(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); - ASSERT_GE(sprintf((char *)ptr, "libdmabufheap"), 0); + ASSERT_GE(sprintf_s((char *)ptr, BUFFER_SIZE, "libdmabufheap"), 0); ASSERT_EQ(0, DmabufHeapBufferSyncEnd(buffer.fd, DMA_BUF_HEAP_BUF_SYNC_RW)); -- Gitee