From c1ead65e110969fa4906765b074df4f12e9599d3 Mon Sep 17 00:00:00 2001 From: kirby Date: Thu, 4 Jul 2024 19:21:04 +0800 Subject: [PATCH 1/2] bugfix_codecheck_ffi Signed-off-by: kirby --- interfaces/kits/cj/src/config_policy_ffi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/cj/src/config_policy_ffi.cpp b/interfaces/kits/cj/src/config_policy_ffi.cpp index 3af9e30..6997cd8 100644 --- a/interfaces/kits/cj/src/config_policy_ffi.cpp +++ b/interfaces/kits/cj/src/config_policy_ffi.cpp @@ -31,7 +31,7 @@ char** MallocCStringArr(const std::vector& origin) return nullptr; } auto size = origin.size(); - if (size == 0 || size > MAX_MALLOC_LEN) { + if (size > MAX_MALLOC_LEN) { return nullptr; } auto arr = static_cast(malloc(sizeof(char*) * size)); -- Gitee From c2ee4629ccbcce91ab050fa06199e6922e39d653 Mon Sep 17 00:00:00 2001 From: kirby Date: Fri, 26 Jul 2024 11:23:16 +0800 Subject: [PATCH 2/2] delete ffibind Signed-off-by: kirby --- interfaces/kits/cj/BUILD.gn | 2 -- interfaces/kits/cj/src/config_policy_ffi.h | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/cj/BUILD.gn b/interfaces/kits/cj/BUILD.gn index 31cbee1..faa8e70 100644 --- a/interfaces/kits/cj/BUILD.gn +++ b/interfaces/kits/cj/BUILD.gn @@ -29,8 +29,6 @@ ohos_shared_library("cj_config_policy_ffi") { "bounds_checking_function:libsec_shared", "hilog:libhilog", "hisysevent:libhisysevent", - "napi:cj_bind_ffi", - "napi:cj_bind_native", ] sources = [ "../../../frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp", diff --git a/interfaces/kits/cj/src/config_policy_ffi.h b/interfaces/kits/cj/src/config_policy_ffi.h index 17ffea9..29e6c8d 100644 --- a/interfaces/kits/cj/src/config_policy_ffi.h +++ b/interfaces/kits/cj/src/config_policy_ffi.h @@ -16,10 +16,27 @@ #ifndef CONFIG_POLICY_FFI_H #define CONFIG_POLICY_FFI_H -#include "ffi_remote_data.h" -#include "cj_common_ffi.h" +#include + +#define FFI_EXPORT __attribute__((visibility("default"))) extern "C" { + const int32_t SUCCESS_CODE = 0; + struct CArrString { + char** head; + int64_t size; + }; + + struct RetDataCArrString { + int32_t code; + CArrString data; + }; + + struct RetDataCString { + int32_t code; + char* data; + }; + FFI_EXPORT RetDataCArrString CJ_GetCfgDirList(); FFI_EXPORT RetDataCArrString CJ_GetCfgFiles(const char* relPath); FFI_EXPORT RetDataCString CJ_GetOneCfgFile(const char* relPath); -- Gitee