!8 修复嵌入式环境中的编译错误及hilog的sysroot路径并删除多余的tar.gz

From: @s-c-c 
Reviewed-by: @yukaii 
Signed-off-by: @yukaii
This commit is contained in:
openeuler-ci-bot 2024-03-20 03:14:23 +00:00 committed by Gitee
commit c13d8fc647
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 308 additions and 1 deletions

View File

@ -0,0 +1,203 @@
From 196876e52d4f9bc2665987bf11e616a127f6cdcb Mon Sep 17 00:00:00 2001
From: s_c_c <shichuchao@huawei.com>
Date: Mon, 18 Mar 2024 17:48:35 +0800
Subject: [PATCH] feat for embedded fix compile errors
---
interfaces/innerkits/service_control/service_control.c | 10 +++++-----
interfaces/innerkits/service_watcher/service_watcher.c | 2 +-
services/param/linux/param_request.c | 9 +++++----
services/param_service/src/le_utils.c | 2 ++
services/param_service/src/main.c | 2 ++
services/param_service/src/param_server.c | 1 +
services/param_service/src/trie_comm.c | 7 ++++---
services/utils/init_utils.c | 2 +-
8 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/interfaces/innerkits/service_control/service_control.c b/interfaces/innerkits/service_control/service_control.c
index 9fadec4..238d4f4 100644
--- a/interfaces/innerkits/service_control/service_control.c
+++ b/interfaces/innerkits/service_control/service_control.c
@@ -16,22 +16,22 @@
#include "service_control.h"
-static int StartProcess(const char *name, const char *extArgv[], int extArgc)
+__attribute__((unused)) static int StartProcess(const char *name, const char *extArgv[], int extArgc)
{
return -1;
}
-static int StopProcess(const char *serviceName)
+__attribute__((unused)) static int StopProcess(const char *serviceName)
{
return -1;
}
-static int GetCurrentServiceStatus(const char *serviceName, ServiceStatus *status)
+__attribute__((unused)) static int GetCurrentServiceStatus(const char *serviceName, ServiceStatus *status)
{
return -1;
}
-static int RestartProcess(const char *serviceName, const char *extArgv[], int extArgc)
+__attribute__((unused)) static int RestartProcess(const char *serviceName, const char *extArgv[], int extArgc)
{
return -1;
}
@@ -46,7 +46,7 @@ int ServiceControl(const char *serviceName, int action)
return -1;
}
-static int GetProcessInfo(const char *serviceName, char *nameBuffer, char *valueBuffer, ServiceStatus status)
+__attribute__((unused)) static int GetProcessInfo(const char *serviceName, char *nameBuffer, char *valueBuffer, ServiceStatus status)
{
return -1;
}
diff --git a/interfaces/innerkits/service_watcher/service_watcher.c b/interfaces/innerkits/service_watcher/service_watcher.c
index 68cef54..db6f7c0 100644
--- a/interfaces/innerkits/service_watcher/service_watcher.c
+++ b/interfaces/innerkits/service_watcher/service_watcher.c
@@ -15,7 +15,7 @@
#include "service_watcher.h"
#include "parameter.h"
-static void ServiceStateChange(const char *key, const char *value, void *context)
+__attribute__((unused)) static void ServiceStateChange(const char *key, const char *value, void *context)
{
return;
}
diff --git a/services/param/linux/param_request.c b/services/param/linux/param_request.c
index 6bcd72d..afd95fe 100644
--- a/services/param/linux/param_request.c
+++ b/services/param/linux/param_request.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include "beget_ext.h"
+#include "param_manager.h"
static void ClearEnv(ParamRequestMsg* pmsg, ParamRespMsg* respmsg, int fd)
{
@@ -48,7 +49,7 @@ static int GetClientSocket()
struct sockaddr_un serverAddr;
bzero(&serverAddr, sizeof(serverAddr));
serverAddr.sun_family = PF_UNIX;
- strncpy(serverAddr.sun_path, PIPE_NAME, strlen(PIPE_NAME));
+ strncpy(serverAddr.sun_path, PIPE_NAME, strlen(PIPE_NAME) + 1);
if (connect(cfd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) {
close(cfd);
perror("Failed to connect");
@@ -111,7 +112,7 @@ int SystemSetParameter(const char *name, const char *value)
return -1;
}
- strncpy(pmsg->key, name, sizeof(pmsg->key));
+ strncpy(pmsg->key, name, sizeof(pmsg->key) - 1);
strncpy(pmsg->data, value, pmsg->datasize);
int ret;
struct ParamRespMsg* respmsg = StartRequest(fd, pmsg);
@@ -140,7 +141,7 @@ int SystemReadParam(const char *name, char *value, uint32_t *len)
struct ParamRequestMsg* pmsg = GetRequestMsg(GET_PARAMETER, *len);
BEGET_ERROR_CHECK(pmsg != NULL, close(fd);return -1, "Invalid pmsg");
- strncpy(pmsg->key, name, sizeof(pmsg->key));
+ strncpy(pmsg->key, name, sizeof(pmsg->key) - 1);
int ret;
struct ParamRespMsg* respmsg = StartRequest(fd, pmsg);
if (respmsg == NULL) {
@@ -178,7 +179,7 @@ int SystemWaitParameter(const char *name, const char *value, int32_t timeout)
BEGET_ERROR_CHECK(pmsg != NULL, close(fd);return -1, "Invalid pmsg");
pmsg->timeout = timeout;
- strncpy(pmsg->key, name, sizeof(pmsg->key));
+ strncpy(pmsg->key, name, sizeof(pmsg->key) - 1);
strncpy(pmsg->data, value, sizeof(pmsg->datasize));
struct ParamRespMsg* respmsg = StartRequest(fd, pmsg);
if (respmsg == NULL) {
diff --git a/services/param_service/src/le_utils.c b/services/param_service/src/le_utils.c
index c4f5b69..8fa0401 100644
--- a/services/param_service/src/le_utils.c
+++ b/services/param_service/src/le_utils.c
@@ -3,6 +3,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
+#include <sys/stat.h>
+#include "securec.h"
#define MAX_BUF 1024
diff --git a/services/param_service/src/main.c b/services/param_service/src/main.c
index 01cd47a..1daa246 100644
--- a/services/param_service/src/main.c
+++ b/services/param_service/src/main.c
@@ -6,6 +6,8 @@
#include <sys/prctl.h>
#include <string.h>
#include "beget_ext.h"
+#include "trie_comm.h"
+#include "param_server.h"
int main(int argc, char* argv[])
{
diff --git a/services/param_service/src/param_server.c b/services/param_service/src/param_server.c
index 2f6b5ed..8b38d0f 100644
--- a/services/param_service/src/param_server.c
+++ b/services/param_service/src/param_server.c
@@ -17,6 +17,7 @@
#include "param_utils.h"
#include "trie_comm.h"
#include "securec.h"
+#include "le_utils.h"
void HandleEvent(struct EventArgs* args)
{
diff --git a/services/param_service/src/trie_comm.c b/services/param_service/src/trie_comm.c
index 1a66d0d..fd8184a 100644
--- a/services/param_service/src/trie_comm.c
+++ b/services/param_service/src/trie_comm.c
@@ -204,7 +204,7 @@ int SetParamtoMem(const char* key, const char* value)
if (root == NULL || current == NULL)
return -1;
- char* remainKey = key;
+ char* remainKey = (char *)key;
pthread_rwlock_wrlock(&rwlock);
while(1) {
char* subKey;
@@ -266,7 +266,7 @@ int GetParamFromMem(const char* key, char* value, uint32_t len)
return -1;
ParamNode* paramData;
- char* remainKey = key;
+ char* remainKey = (char *)key;
pthread_rwlock_rdlock(&rwlock);
while (1) {
char* subKey;
@@ -477,7 +477,8 @@ int ParamWorkSpaceInit()
BEGET_ERROR_CHECK(paramWorkSpace != NULL, return -1, "failed to malloc for param workspace");
int fd = open(WORKSPACE_NAME, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
BEGET_ERROR_CHECK(fd > 0, return -1, "failed to open %s", WORKSPACE_NAME);
- ftruncate(fd, WORKSPACE_SIZE);
+ int ret = ftruncate(fd, WORKSPACE_SIZE);
+ (void)ret;
paramWorkSpace->shareAddr = mmap(NULL, WORKSPACE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
BEGET_ERROR_CHECK(paramWorkSpace->shareAddr != MAP_FAILED, return -1, "failed to create mmap");
paramWorkSpace->rootOffest = 0;
diff --git a/services/utils/init_utils.c b/services/utils/init_utils.c
index 733f863..8b4b2e0 100644
--- a/services/utils/init_utils.c
+++ b/services/utils/init_utils.c
@@ -49,7 +49,7 @@ float ConvertMicrosecondToSecond(int x)
}
#ifndef __LITEOS_M__
-static bool CheckDigit(const char *name)
+__attribute__((unused)) static bool CheckDigit(const char *name)
{
size_t nameLen = strlen(name);
for (size_t i = 0; i < nameLen; ++i) {
--
2.20.1 (Apple Git-117)

View File

@ -0,0 +1,93 @@
From 09afde568a6869e33893cc32f85768611319f430 Mon Sep 17 00:00:00 2001
From: s_c_c <shichuchao@huawei.com>
Date: Tue, 19 Mar 2024 16:12:51 +0800
Subject: [PATCH] feat for embedded fix sysroot hilog path
---
interfaces/innerkits/BUILD.gn | 3 ++-
services/param/base/BUILD.gn | 5 +++--
services/utils/BUILD.gn | 5 +++--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn
index aeba5e6..a68eaee 100644
--- a/interfaces/innerkits/BUILD.gn
+++ b/interfaces/innerkits/BUILD.gn
@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
+import("//build/config/sysroot.gni")
syspara_sources = [
"syspara/param_comm.c",
@@ -23,7 +24,7 @@ config("exported_header_files") {
"//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/interfaces/innerkits/include/syspara",
"//base/startup/init/services/include",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
+ "${sysroot}/usr/include/hilog",
]
}
diff --git a/services/param/base/BUILD.gn b/services/param/base/BUILD.gn
index b253055..178ac87 100644
--- a/services/param/base/BUILD.gn
+++ b/services/param/base/BUILD.gn
@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
+import("//build/config/sysroot.gni")
config("exported_header_files") {
visibility = [ ":*" ]
@@ -18,7 +19,7 @@ config("exported_header_files") {
"//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/services/include/param",
"//base/startup/init/services/include",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
+ "${sysroot}/usr/include/hilog",
]
}
@@ -29,7 +30,7 @@ comm_sources = [
base_include_dirs = [
"//base/startup/init/services/param/include",
"//base/startup/init/services/param/base",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
+ "${sysroot}/usr/include/hilog",
]
source_set("parameterbase") {
diff --git a/services/utils/BUILD.gn b/services/utils/BUILD.gn
index 11d8bf7..e5f6a96 100644
--- a/services/utils/BUILD.gn
+++ b/services/utils/BUILD.gn
@@ -10,12 +10,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+import("//build/config/sysroot.gni")
config("exported_header_files") {
visibility = [ ":*" ]
include_dirs = [
"//base/startup/init/services/include",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
+ "${sysroot}/usr/include/hilog",
]
}
@@ -26,7 +27,7 @@ ohos_static_library("libinit_utils") {
include_dirs = [
"//base/startup/init/interfaces/innerkits/include",
"//third_party/bounds_checking_function/include",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
+ "${sysroot}/usr/include/hilog",
]
deps = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
--
2.20.1 (Apple Git-117)

View File

@ -5,7 +5,7 @@
Name: distributed-beget
Version: 1.0.0
Release: 1
Release: 3
Summary: openEuler embedded softbus capability support
License: Apache License 2.0
URL: https://gitee.com/openeuler/distributed-beget.git
@ -13,6 +13,8 @@ Source1: distributed-beget.tar.gz
Source2: startup.bundle.json
Source3: startup.BUILD.gn
Patch1: 0001-fixbug_fd_leak_for_init.patch
Patch2: 0002-feat-for-embedded-fix-compile-errors.patch
Patch3: 0003-feat-for-embedded-fix-sysroot-hilog-path.patch
BuildRequires: distributed-build, hilog, commonlibrary_c_utils
@ -37,6 +39,8 @@ cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}
# mkdir -p %{_builddir}/base/startup
%setup -q -D -T -a 1 -c -n %{_builddir}/base/startup
%patch -P1 -p1 -d %{_builddir}/base/startup/init
%patch -P2 -p1 -d %{_builddir}/base/startup/init
%patch -P3 -p1 -d %{_builddir}/base/startup/init
# exit 0
%build
@ -99,6 +103,13 @@ ln -s /usr/include/init %{buildroot}%{build_opt}/openeuler/compiler_gn/%{interfa
%{build_opt}/*
%changelog
* Mon Mar 18 2024 s_c_c <shichuchao@huawei.com> - 1.0.0-3
- Fix compile errors and sysroot hilog path for embedded
* Thu Mar 14 2024 s_c_c <shichuchao@huawei.com> - 1.0.0-2
- Remove unused tar.gz
* Fri Nov 24 2023 muyuying <muyuying1@huawei.com> - 1.0.0-1
- Init and Adapt to Openeule