From 14f7a4bd100974873e9d772dc5b082765e061b0b Mon Sep 17 00:00:00 2001 From: j30052480 Date: Fri, 22 Dec 2023 11:37:36 +0800 Subject: [PATCH 1/5] fix hdi domain id misuse Signed-off-by: j30052480 --- .../tools/hdi-gen/codegen/java_client_proxy_code_emitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/tools/hdi-gen/codegen/java_client_proxy_code_emitter.cpp b/framework/tools/hdi-gen/codegen/java_client_proxy_code_emitter.cpp index 0108ec0f2..b21523326 100644 --- a/framework/tools/hdi-gen/codegen/java_client_proxy_code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/java_client_proxy_code_emitter.cpp @@ -114,7 +114,7 @@ void JavaClientProxyCodeEmitter::EmitProxyImpl(StringBuilder &sb) EmitProxyConstants(sb, TAB); sb.Append("\n"); sb.Append(TAB).AppendFormat( - "private static final HiLogLabel TAG = new HiLogLabel(HiLog.LOG_CORE, 0xD001510, \"%s\");\n", + "private static final HiLogLabel TAG = new HiLogLabel(HiLog.LOG_CORE, 0xD002500, \"%s\");\n", interfaceFullName_.c_str()); sb.Append(TAB).Append("private final IRemoteObject remote;\n"); sb.Append(TAB).Append("private static final int ERR_OK = 0;\n"); -- Gitee From c346c969ce24e7a97112374ed9b0488c5096abe3 Mon Sep 17 00:00:00 2001 From: j30052480 Date: Tue, 9 Jan 2024 16:47:24 +0800 Subject: [PATCH 2/5] fix hdf_core code problem Signed-off-by: j30052480 --- adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp | 2 +- framework/tools/hdi-gen/codegen/code_emitter.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp b/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp index ddf827e3d..43912ba46 100644 --- a/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp +++ b/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp @@ -76,7 +76,7 @@ int SharedMemQueueSyncer::FutexWait(uint32_t bitset, int64_t timeoutNanoSec) } status = -errno; if (status != ETIMEDOUT) { - HDF_LOGE("failed to wait smq futex, %{publich}d", status); + HDF_LOGE("failed to wait smq futex, status: %{public}d, errno desc: %{public}s", status, strerror(errno)); } return status; } diff --git a/framework/tools/hdi-gen/codegen/code_emitter.cpp b/framework/tools/hdi-gen/codegen/code_emitter.cpp index d5645eb24..657a0eeae 100644 --- a/framework/tools/hdi-gen/codegen/code_emitter.cpp +++ b/framework/tools/hdi-gen/codegen/code_emitter.cpp @@ -142,7 +142,9 @@ std::string CodeEmitter::InterfaceToFilePath(const std::string &interfaceName) c { std::string fullName = interfaceName; if (StringHelper::EndWith(fullName, "]")) { - fullName = fullName.substr(0, fullName.find("[")); + if (interfaceName.find("[") != std::string::npos) { + fullName = interfaceName.substr(0, interfaceName.find("[")); + } } size_t index = fullName.rfind("."); std::string prefix = fullName.substr(0, index + 1); -- Gitee From 8a0290d6734b39c0b0d258eb81e7addad3404d14 Mon Sep 17 00:00:00 2001 From: j30052480 Date: Wed, 10 Jan 2024 15:08:07 +0800 Subject: [PATCH 3/5] fix hdf_core code problem Signed-off-by: j30052480 --- framework/tools/hc-gen/src/option.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/tools/hc-gen/src/option.cpp b/framework/tools/hc-gen/src/option.cpp index c661d3301..f94d91cc3 100644 --- a/framework/tools/hc-gen/src/option.cpp +++ b/framework/tools/hc-gen/src/option.cpp @@ -122,8 +122,8 @@ void Option::SetOptionData(char op) void Option::ShowUsage() { - Logger() << "Usage: hc-gen [Options] [File]\n" - << "options:"; + Logger() << "Usage: hc-gen [Options] [File]\n"; + Logger() << "options:"; ShowOption("-o ", "output file name, default same as input"); ShowOption("-a", "hcb align with four bytes"); ShowOption("-b", "output binary output, default enable"); -- Gitee From 2d8e9e42b78f9c68554f287c8001b9e305d3e6d5 Mon Sep 17 00:00:00 2001 From: j30052480 Date: Fri, 19 Jan 2024 11:59:34 +0800 Subject: [PATCH 4/5] fix hdf_core code problem Signed-off-by: j30052480 --- adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp | 2 +- adapter/uhdf2/host/devhost.c | 4 ++-- adapter/uhdf2/host/src/driver_loader_full.c | 2 +- adapter/uhdf2/manager/src/devmgr_uevent.c | 15 ++++++++------- adapter/uhdf2/security/src/hdf_security.c | 2 +- .../adapter/syscall/src/hdf_syscall_adapter.c | 6 +++--- framework/core/host/src/hdf_load_vdi.c | 4 ++-- framework/tools/hdi-gen/util/file.cpp | 2 +- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp b/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp index 43912ba46..59e854d5a 100644 --- a/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp +++ b/adapter/uhdf2/hdi/src/hdi_smq_syncer.cpp @@ -91,7 +91,7 @@ int SharedMemQueueSyncer::Wake(uint32_t bitset) int ret = syscall(__NR_futex, syncAddr_, FUTEX_WAKE_BITSET, INT_MAX, 0, 0, bitset); if (ret < 0) { - HDF_LOGE("failed to wakeup smq futex, %{public}d", errno); + HDF_LOGE("failed to wakeup smq futex, errno: %{public}d, errno desc: %{public}s", errno, strerror(errno)); return -errno; } diff --git a/adapter/uhdf2/host/devhost.c b/adapter/uhdf2/host/devhost.c index d81e3fb23..8a1513196 100644 --- a/adapter/uhdf2/host/devhost.c +++ b/adapter/uhdf2/host/devhost.c @@ -104,13 +104,13 @@ static void HdfSetProcPriority(char **argv) } if (setpriority(PRIO_PROCESS, 0, procPriority) != 0) { - HDF_LOGE("host setpriority failed: %{public}d", errno); + HDF_LOGE("host setpriority failed: errno: %{public}d, errno desc: %{public}s", errno, strerror(errno)); } struct sched_param param = {0}; param.sched_priority = schedPriority; if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { - HDF_LOGE("host sched_setscheduler failed: %{public}d", errno); + HDF_LOGE("host sched_setscheduler failed: errno: %{public}d, errno desc: %{public}s", errno, strerror(errno)); } else { HDF_LOGI("host sched_setscheduler succeed:%{public}d %{public}d", procPriority, schedPriority); } diff --git a/adapter/uhdf2/host/src/driver_loader_full.c b/adapter/uhdf2/host/src/driver_loader_full.c index 6632c4bb2..9c851edae 100644 --- a/adapter/uhdf2/host/src/driver_loader_full.c +++ b/adapter/uhdf2/host/src/driver_loader_full.c @@ -52,7 +52,7 @@ struct HdfDriver *HdfDriverLoaderGetDriver(const char *moduleName) } if (realpath(driverPath, realPath) == NULL) { - HDF_LOGE("%{public}s no valid, errno:%{public}d", driverPath, errno); + HDF_LOGE("%{public}s no valid, errno: %{public}d, errno desc: %{public}s", driverPath, errno, strerror(errno)); return NULL; } diff --git a/adapter/uhdf2/manager/src/devmgr_uevent.c b/adapter/uhdf2/manager/src/devmgr_uevent.c index 461dbcf45..8de1bf08c 100644 --- a/adapter/uhdf2/manager/src/devmgr_uevent.c +++ b/adapter/uhdf2/manager/src/devmgr_uevent.c @@ -301,7 +301,7 @@ static int32_t DevMgrUeventParseConfig(void) char resolvedPath[PATH_MAX] = {0}; if (realpath(path, resolvedPath) == NULL) { - HDF_LOGE("realpath file: %{public}s failed, errno:%{public}d", path, errno); + HDF_LOGE("realpath file: %{public}s failed, errno: %{public}d, errno desc: %{public}s", path, errno, strerror(errno)); return HDF_FAILURE; } if (strncmp(resolvedPath, HDF_CONFIG_DIR, strlen(HDF_CONFIG_DIR)) != 0) { @@ -310,7 +310,8 @@ static int32_t DevMgrUeventParseConfig(void) } FILE *file = fopen(resolvedPath, "r"); if (file == NULL) { - HDF_LOGE("%{public}s fopen %{public}s failed:%{public}d", __func__, resolvedPath, errno); + HDF_LOGE("%{public}s fopen %{public}s failed: errno: %{public}d, errno desc: %{public}s", + __func__, resolvedPath, errno, strerror(errno)); return HDF_FAILURE; } @@ -337,26 +338,26 @@ static int32_t DevMgrUeventSocketInit(void) int32_t sockfd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT); if (sockfd < 0) { - HDF_LOGE("create socket failed, err = %{public}d", errno); + HDF_LOGE("create socket failed, err = %{public}d, desc = %{public}s", errno, strerror(errno)); return HDF_FAILURE; } int32_t buffSize = UEVENT_SOCKET_BUFF_SIZE; if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &buffSize, sizeof(buffSize)) != 0) { - HDF_LOGE("setsockopt: SO_RCVBUF failed err = %{public}d", errno); + HDF_LOGE("setsockopt: SO_RCVBUF failed err = %{public}d, desc = %{public}s", errno, strerror(errno)); close(sockfd); return HDF_FAILURE; } const int32_t on = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) != 0) { - HDF_LOGE("setsockopt: SO_PASSCRED failed, err = %{public}d", errno); + HDF_LOGE("setsockopt: SO_PASSCRED failed, err = %{public}d, desc = %{public}s", errno, strerror(errno)); close(sockfd); return HDF_FAILURE; } if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - HDF_LOGE("bind socket failed, err = %{public}d", errno); + HDF_LOGE("bind socket failed, err = %{public}d, desc = %{public}s", errno, strerror(errno)); close(sockfd); return HDF_FAILURE; } @@ -523,7 +524,7 @@ static int32_t DevMgrUeventThread(void *arg) fd.events = POLLIN | POLLERR; while (true) { if (poll(&fd, 1, -1) <= 0) { - HDF_LOGE("%{public}s poll fail %{public}d", __func__, errno); + HDF_LOGE("%{public}s poll fail %{public}d %{public}s", __func__, errno, strerror(errno)); OsalMSleep(DEVMGR_UEVENT_WAIT_TIME); continue; } diff --git a/adapter/uhdf2/security/src/hdf_security.c b/adapter/uhdf2/security/src/hdf_security.c index 4ed3e4234..75cb876bc 100644 --- a/adapter/uhdf2/security/src/hdf_security.c +++ b/adapter/uhdf2/security/src/hdf_security.c @@ -158,7 +158,7 @@ static int32_t HdfUpdateSecurityId(const char *id, uint64_t perms, int32_t isSet } int32_t fd = open(path, O_WRONLY); if (fd < 0) { - HDF_LOGE("open %{public}s failed, errno is %{public}d", HDF_SECURE_PATH, errno); + HDF_LOGE("open %{public}s failed, errno is %{public}d, desc is %{public}s", HDF_SECURE_PATH, errno, strerror(errno)); return HDF_FAILURE; } diff --git a/framework/core/adapter/syscall/src/hdf_syscall_adapter.c b/framework/core/adapter/syscall/src/hdf_syscall_adapter.c index beb84d8a2..983a02ae0 100644 --- a/framework/core/adapter/syscall/src/hdf_syscall_adapter.c +++ b/framework/core/adapter/syscall/src/hdf_syscall_adapter.c @@ -172,7 +172,7 @@ static int32_t HdfDevEventReadAndDispatch(struct HdfDevListenerThread *thread, i if (ret == -HDF_DEV_ERR_NODATA) { ret = HDF_SUCCESS; } else { - HDF_LOGE("%s:ioctl failed, errno=%d", __func__, ret); + HDF_LOGE("%s:ioctl failed, errno=%d, desc=%s", __func__, ret, strerror(errno)); } goto FINISH; @@ -228,7 +228,7 @@ static void SetThreadName(void) if (ret > 0) { ret = prctl(PR_SET_NAME, newTitle); if (ret < 0) { - HDF_LOGE("%s: failed to set thread name, errno is %d", __func__, errno); + HDF_LOGE("%s: failed to set thread name, errno is %d, desc is %s", __func__, errno, strerror(errno)); } } @@ -694,7 +694,7 @@ static int32_t HdfSyscallAdapterDispatch( wrBuf.cmdCode = code; int32_t ret = ioctl(ioService->fd, HDF_WRITE_READ, &wrBuf); if (ret < 0) { - HDF_LOGE("Failed to dispatch serv call ioctl %{public}d", -errno); + HDF_LOGE("Failed to dispatch serv call ioctl %{public}d, %{public}s", -errno, strerror(errno)); ret = -errno; } if (reply != NULL) { diff --git a/framework/core/host/src/hdf_load_vdi.c b/framework/core/host/src/hdf_load_vdi.c index b5c9c79c0..44e9b65a3 100644 --- a/framework/core/host/src/hdf_load_vdi.c +++ b/framework/core/host/src/hdf_load_vdi.c @@ -37,8 +37,8 @@ struct HdfVdiObject *HdfLoadVdi(const char *libName) } if (realpath(path, resolvedPath) == NULL || strncmp(resolvedPath, VDI_PATH, strlen(VDI_PATH)) != 0) { - HDF_LOGE("%{public}s %{public}s %{public}s realpath file name failed %{public}d", - __func__, path, resolvedPath, errno); + HDF_LOGE("%{public}s %{public}s %{public}s realpath file name failed %{public}d, %{public}s", + __func__, path, resolvedPath, errno, strerror(errno)); return NULL; } diff --git a/framework/tools/hdi-gen/util/file.cpp b/framework/tools/hdi-gen/util/file.cpp index 54929190f..d2ef19e8f 100644 --- a/framework/tools/hdi-gen/util/file.cpp +++ b/framework/tools/hdi-gen/util/file.cpp @@ -303,7 +303,7 @@ std::set File::FindFiles(const std::string &rootDir) dirs.pop(); DIR *dir = opendir(dirPath.c_str()); if (dir == nullptr) { - Logger::E(TAG, "failed to open '%s', errno:%d", dirPath.c_str(), errno); + Logger::E(TAG, "failed to open '%s', errno:%d, desc:%s", dirPath.c_str(), errno, strerror(errno)); continue; } -- Gitee From 61c77084beb83a474a47eccf78ba727edeb8129d Mon Sep 17 00:00:00 2001 From: j30052480 Date: Tue, 23 Jan 2024 17:56:07 +0800 Subject: [PATCH 5/5] fix hdf_core code problem Signed-off-by: j30052480 --- adapter/uhdf2/manager/src/devmgr_uevent.c | 3 ++- adapter/uhdf2/security/src/hdf_security.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/adapter/uhdf2/manager/src/devmgr_uevent.c b/adapter/uhdf2/manager/src/devmgr_uevent.c index 8de1bf08c..c4e223e15 100644 --- a/adapter/uhdf2/manager/src/devmgr_uevent.c +++ b/adapter/uhdf2/manager/src/devmgr_uevent.c @@ -301,7 +301,8 @@ static int32_t DevMgrUeventParseConfig(void) char resolvedPath[PATH_MAX] = {0}; if (realpath(path, resolvedPath) == NULL) { - HDF_LOGE("realpath file: %{public}s failed, errno: %{public}d, errno desc: %{public}s", path, errno, strerror(errno)); + HDF_LOGE("realpath file: %{public}s failed, errno: %{public}d, errno desc: %{public}s", + path, errno, strerror(errno)); return HDF_FAILURE; } if (strncmp(resolvedPath, HDF_CONFIG_DIR, strlen(HDF_CONFIG_DIR)) != 0) { diff --git a/adapter/uhdf2/security/src/hdf_security.c b/adapter/uhdf2/security/src/hdf_security.c index 75cb876bc..d3b9966b5 100644 --- a/adapter/uhdf2/security/src/hdf_security.c +++ b/adapter/uhdf2/security/src/hdf_security.c @@ -158,7 +158,8 @@ static int32_t HdfUpdateSecurityId(const char *id, uint64_t perms, int32_t isSet } int32_t fd = open(path, O_WRONLY); if (fd < 0) { - HDF_LOGE("open %{public}s failed, errno is %{public}d, desc is %{public}s", HDF_SECURE_PATH, errno, strerror(errno)); + HDF_LOGE("open %{public}s failed, errno is %{public}d, desc is %{public}s", + HDF_SECURE_PATH, errno, strerror(errno)); return HDF_FAILURE; } -- Gitee