From 36fbcb10ed82d1dbb4ea0f385ea66e8619a4a1ce Mon Sep 17 00:00:00 2001 From: j30052480 Date: Thu, 21 Mar 2024 15:07:14 +0800 Subject: [PATCH 1/4] feat: hdf_core optimize log information Signed-off-by: j30052480 --- adapter/uhdf2/hdi/src/hdi_support.cpp | 5 +- .../uhdf2/hdi/src/servstat_listener_stub.cpp | 8 ++- adapter/uhdf2/host/devhost.c | 3 + adapter/uhdf2/host/src/device_service_stub.c | 2 +- adapter/uhdf2/manager/device_manager.c | 2 + adapter/uhdf2/manager/src/devmgr_uevent.c | 2 +- .../manager/src/servstat_listener_holder.c | 2 +- .../adapter/syscall/src/hdf_devmgr_adapter.c | 12 ++-- .../adapter/syscall/src/hdf_syscall_adapter.c | 65 ++++++++++--------- .../core/common/src/devmgr_service_start.c | 8 +-- framework/core/common/src/hdf_attribute.c | 23 +++---- .../core/common/src/hdf_attribute_macro.c | 14 ++-- .../core/common/src/hdf_device_node_ext.c | 2 +- framework/core/host/src/devhost_service.c | 20 ++++-- framework/core/host/src/hdf_device.c | 5 +- framework/core/host/src/hdf_device_node.c | 4 +- framework/core/host/src/hdf_device_object.c | 10 +-- framework/core/host/src/hdf_driver_loader.c | 7 +- framework/core/host/src/hdf_observer_record.c | 2 +- .../core/manager/src/devhost_service_clnt.c | 2 +- framework/core/manager/src/devmgr_service.c | 4 +- framework/core/manager/src/devsvc_manager.c | 2 +- .../core/manager/src/devsvc_manager_ext.c | 2 +- framework/core/manager/src/driver_manager.c | 4 +- .../core/manager/src/hdf_driver_installer.c | 2 +- .../core/shared/include/hdf_attribute_macro.h | 6 +- framework/core/shared/src/svcmgr_ioservice.c | 2 +- framework/utils/src/hdf_message_looper.c | 2 + 28 files changed, 123 insertions(+), 99 deletions(-) diff --git a/adapter/uhdf2/hdi/src/hdi_support.cpp b/adapter/uhdf2/hdi/src/hdi_support.cpp index 7b4acb258..e7080f5fc 100644 --- a/adapter/uhdf2/hdi/src/hdi_support.cpp +++ b/adapter/uhdf2/hdi/src/hdi_support.cpp @@ -157,14 +157,15 @@ void *LoadHdiImpl(const char *desc, const char *serviceName) std::string symName = interfaceName + "ImplGetInstance"; hdiImpl.constructor = reinterpret_cast(dlsym(hdiImpl.handler, symName.data())); if (hdiImpl.constructor == nullptr) { - HDF_LOGE("%{public}s failed to get symbol of '%s', %{public}s", __func__, symName.c_str(), dlerror()); + HDF_LOGE("%{public}s failed to get symbol of '%{public}s', %{public}s", __func__, symName.c_str(), dlerror()); hdiImpl.Unload(); return nullptr; } std::string desSymName = interfaceName + "ImplRelease"; hdiImpl.destructor = reinterpret_cast(dlsym(hdiImpl.handler, desSymName.data())); if (hdiImpl.destructor == nullptr) { - HDF_LOGE("%{public}s failed to get symbol of '%s', %{public}s", __func__, desSymName.c_str(), dlerror()); + HDF_LOGW("%{public}s failed to get symbol of '%{public}s', %{public}s", + __func__, desSymName.c_str(), dlerror()); } void *implInstance = hdiImpl.constructor(); diff --git a/adapter/uhdf2/hdi/src/servstat_listener_stub.cpp b/adapter/uhdf2/hdi/src/servstat_listener_stub.cpp index 33c994e08..9eafc8a07 100644 --- a/adapter/uhdf2/hdi/src/servstat_listener_stub.cpp +++ b/adapter/uhdf2/hdi/src/servstat_listener_stub.cpp @@ -38,25 +38,27 @@ int32_t ServStatListenerStub::ServStatListenerStubOnReceive( { ServiceStatus status; if (data.ReadInterfaceToken() != GetDescriptor()) { - HDF_LOGI("failed to check interface token"); + HDF_LOGE("failed to check interface token"); return HDF_FAILURE; } const char *name = data.ReadCString(); status.serviceName = (name == nullptr) ? "" : name; if (status.serviceName.empty()) { - HDF_LOGI("failed to read serviceName in ServiceStatus"); + HDF_LOGE("failed to read serviceName in ServiceStatus"); return HDF_FAILURE; } if (!data.ReadUint16(status.deviceClass) || !data.ReadUint16(status.status)) { - HDF_LOGI("failed to read deviceClass or status in ServiceStatus"); + HDF_LOGE("failed to read deviceClass or status in ServiceStatus"); return HDF_FAILURE; } const char *info = data.ReadCString(); status.info = (info == nullptr) ? "" : info; + HDF_LOGI("%{public}s call func OnReceive, serviceName: %{public}s, status: %{public}d", + __func__, status.serviceName.c_str(), status.status); OnReceive(status); return HDF_SUCCESS; } diff --git a/adapter/uhdf2/host/devhost.c b/adapter/uhdf2/host/devhost.c index d81e3fb23..f5bf2311d 100644 --- a/adapter/uhdf2/host/devhost.c +++ b/adapter/uhdf2/host/devhost.c @@ -144,8 +144,10 @@ int main(int argc, char **argv) HDF_LOGE("DevHostServiceGetInstance fail"); return HDF_ERR_INVALID_OBJECT; } + HDF_LOGD("create IDevHostService of %{public}s success", hostName); DevHostDumpInit(); + HDF_LOGD("%{public}s start device service begin", hostName); int status = instance->StartService(instance); if (status != HDF_SUCCESS) { HDF_LOGE("Devhost StartService fail, return: %{public}d", status); @@ -158,6 +160,7 @@ int main(int argc, char **argv) struct DevHostServiceFull *fullService = (struct DevHostServiceFull *)instance; struct HdfMessageLooper *looper = &fullService->looper; if ((looper != NULL) && (looper->Start != NULL)) { + HDF_LOGI("%{public}s start loop", hostName); looper->Start(looper); } diff --git a/adapter/uhdf2/host/src/device_service_stub.c b/adapter/uhdf2/host/src/device_service_stub.c index 7137a53e9..55ac66fbc 100644 --- a/adapter/uhdf2/host/src/device_service_stub.c +++ b/adapter/uhdf2/host/src/device_service_stub.c @@ -52,7 +52,7 @@ int DeviceServiceStubPublishService(struct HdfDeviceNode *service) struct DeviceServiceStub *fullService = (struct DeviceServiceStub *)service; if (service->servName == NULL) { - HDF_LOGE("device %x miss service name", service->devId); + HDF_LOGE("device %{public}x miss service name", service->devId); return HDF_ERR_INVALID_OBJECT; } diff --git a/adapter/uhdf2/manager/device_manager.c b/adapter/uhdf2/manager/device_manager.c index 3803b9a75..20fb2494a 100644 --- a/adapter/uhdf2/manager/device_manager.c +++ b/adapter/uhdf2/manager/device_manager.c @@ -34,6 +34,7 @@ int main() if (instance->StartService != NULL) { status = instance->StartService(instance); + HDF_LOGI("device manager start service success"); } (void)DevMgrUeventReceiveStart(); DevMgrRegisterDumpFunc(); @@ -41,6 +42,7 @@ int main() struct DevmgrServiceFull *fullService = (struct DevmgrServiceFull *)instance; struct HdfMessageLooper *looper = &fullService->looper; if ((looper != NULL) && (looper->Start != NULL)) { + HDF_LOGI("device manager start loop"); looper->Start(looper); } } diff --git a/adapter/uhdf2/manager/src/devmgr_uevent.c b/adapter/uhdf2/manager/src/devmgr_uevent.c index 461dbcf45..d52bdf4b5 100644 --- a/adapter/uhdf2/manager/src/devmgr_uevent.c +++ b/adapter/uhdf2/manager/src/devmgr_uevent.c @@ -150,7 +150,7 @@ static bool DevMgrUeventCheckRuleValid(const char *line) } if (strstr(line, PNP_EVENT_STR) == NULL) { - HDF_LOGE("%s invalid rule: %s", __func__, line); + HDF_LOGE("%{public}s invalid rule: %{public}s", __func__, line); return false; } diff --git a/adapter/uhdf2/manager/src/servstat_listener_holder.c b/adapter/uhdf2/manager/src/servstat_listener_holder.c index cedf2f35e..09662398a 100644 --- a/adapter/uhdf2/manager/src/servstat_listener_holder.c +++ b/adapter/uhdf2/manager/src/servstat_listener_holder.c @@ -73,7 +73,7 @@ int32_t UServStatListenerHolderNotifyStatus(struct ServStatListenerHolder *holde HDF_LOGE("failed to notify service status, invalid holder"); return HDF_ERR_INVALID_PARAM; } - HDF_LOGI("notify service status %{public}s", status->serviceName); + HDF_LOGI("notify service status %{public}s, %{public}d", status->serviceName, status->status); struct HdfSBuf *data = HdfSbufTypedObtain(SBUF_IPC); if (data == NULL) { HDF_LOGE("failed to notify service status, oom"); diff --git a/framework/core/adapter/syscall/src/hdf_devmgr_adapter.c b/framework/core/adapter/syscall/src/hdf_devmgr_adapter.c index 8668d46fc..2f6e032b2 100644 --- a/framework/core/adapter/syscall/src/hdf_devmgr_adapter.c +++ b/framework/core/adapter/syscall/src/hdf_devmgr_adapter.c @@ -22,7 +22,7 @@ int32_t HdfLoadDriverByServiceName(const char *serviceName) } struct HdfIoService *ioService = HdfIoServiceBind(DEV_MGR_NODE); if (ioService == NULL) { - HDF_LOGE("HdfLoadDriverByServiceName failed to get %s service", DEV_MGR_NODE); + HDF_LOGE("HdfLoadDriverByServiceName failed to get %{public}s service", DEV_MGR_NODE); return ret; } data = HdfSbufObtainDefaultSize(); @@ -38,7 +38,7 @@ int32_t HdfLoadDriverByServiceName(const char *serviceName) } ret = ioService->dispatcher->Dispatch(&ioService->object, DEVMGR_LOAD_SERVICE, data, NULL); if (ret != HDF_SUCCESS) { - HDF_LOGE("HdfLoadDriverByServiceName failed to load khdf driver %s", serviceName); + HDF_LOGE("HdfLoadDriverByServiceName failed to load khdf driver %{public}s", serviceName); } OUT: HdfIoServiceRecycle(ioService); @@ -51,12 +51,12 @@ int32_t HdfGetServiceNameByDeviceClass(DeviceClass deviceClass, struct HdfSBuf * int32_t ret = HDF_FAILURE; struct HdfSBuf *data = NULL; if (reply == NULL) { - HDF_LOGE("%s input reply is null", __func__); + HDF_LOGE("%{public}s input reply is null", __func__); return ret; } struct HdfIoService *ioService = HdfIoServiceBind(DEV_MGR_NODE); if (ioService == NULL) { - HDF_LOGE("HdfGetServiceNameByDeviceClass failed to get %s service", DEV_MGR_NODE); + HDF_LOGE("HdfGetServiceNameByDeviceClass failed to get %{public}s service", DEV_MGR_NODE); return ret; } data = HdfSbufObtainDefaultSize(); @@ -89,7 +89,7 @@ int32_t HdfListAllService(struct HdfSBuf *reply) } struct HdfIoService *ioService = HdfIoServiceBind(DEV_MGR_NODE); if (ioService == NULL) { - HDF_LOGE("HdfListAllService failed to get %s service", DEV_MGR_NODE); + HDF_LOGE("HdfListAllService failed to get %{public}s service", DEV_MGR_NODE); return ret; } @@ -110,7 +110,7 @@ int32_t HdfListAllDevice(struct HdfSBuf *reply) } struct HdfIoService *ioService = HdfIoServiceBind(DEV_MGR_NODE); if (ioService == NULL) { - HDF_LOGE("HdfListAllDevice failed to get %s service", DEV_MGR_NODE); + HDF_LOGE("HdfListAllDevice failed to get %{public}s service", DEV_MGR_NODE); return ret; } diff --git a/framework/core/adapter/syscall/src/hdf_syscall_adapter.c b/framework/core/adapter/syscall/src/hdf_syscall_adapter.c index beb84d8a2..b238dfe78 100644 --- a/framework/core/adapter/syscall/src/hdf_syscall_adapter.c +++ b/framework/core/adapter/syscall/src/hdf_syscall_adapter.c @@ -53,13 +53,13 @@ static int32_t HdfDevEventGrowReadBuffer(struct HdfWriteReadBuf *buffer) size_t newSize = buffer->readSize; if (newSize > EVENT_READ_BUFF_MAX) { - HDF_LOGE("%s: report event size out of max limit", __func__); + HDF_LOGE("%{public}s: report event size out of max limit", __func__); return HDF_DEV_ERR_NORANGE; } void *newBuff = OsalMemAlloc(newSize); if (newBuff == NULL) { - HDF_LOGE("%s:oom,%d", __func__, (int)newSize); + HDF_LOGE("%{public}s:oom,%{public}d", __func__, (int)newSize); return HDF_DEV_ERR_NO_MEMORY; } @@ -101,7 +101,7 @@ static int32_t HdfDevEventDispatchLocked( } if (sbuf == NULL) { - HDF_LOGE("%s:sbuf oom", __func__); + HDF_LOGE("%{public}s:sbuf oom", __func__); return HDF_DEV_ERR_NO_MEMORY; } @@ -140,7 +140,7 @@ static int32_t HdfDevEventReadAndDispatch(struct HdfDevListenerThread *thread, i bwr.readBuffer = (uintptr_t)OsalMemAlloc(HDF_DEFAULT_BWR_READ_SIZE); if (bwr.readBuffer == (uintptr_t)NULL) { - HDF_LOGE("%s: oom", __func__); + HDF_LOGE("%{public}s: oom", __func__); return HDF_DEV_ERR_NO_MEMORY; } bwr.cmdCode = -1; @@ -151,7 +151,7 @@ static int32_t HdfDevEventReadAndDispatch(struct HdfDevListenerThread *thread, i struct HdfSyscallAdapter *adapter = HdfFdToAdapterLocked(thread, fd); if (adapter == NULL) { - HDF_LOGI("%s: invalid adapter", __func__); + HDF_LOGI("%{public}s: invalid adapter", __func__); OsalMSleep(1); // yield to sync adapter list goto FINISH; } @@ -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("%{public}s:ioctl failed, errno=%{public}d", __func__, ret); } goto FINISH; @@ -195,7 +195,7 @@ static int32_t AssignPfds(struct HdfDevListenerThread *thread, struct pollfd **p if (*pfdSize < thread->pfdSize) { pfdPtr = OsalMemAlloc(sizeof(struct pollfd) * thread->pfdSize); if (pfdPtr == NULL) { - HDF_LOGE("%s: oom", __func__); + HDF_LOGE("%{public}s: oom", __func__); OsalMutexUnlock(&thread->mutex); return HDF_ERR_MALLOC_FAIL; } @@ -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("%{public}s: failed to set thread name, errno is %{public}d", __func__, errno); } } @@ -254,7 +254,7 @@ static int32_t HdfDevEventListenTask(void *para) } int32_t pollSize = poll(pfds, pollCount, -1); if (pollSize <= 0) { - HDF_LOGE("%s: poll fail (%d)%s", __func__, errno, strerror(errno)); + HDF_LOGE("%{public}s: poll fail (%{public}d)%{public}s", __func__, errno, strerror(errno)); OsalMSleep(POLL_WAIT_TIME_MS); continue; } @@ -295,7 +295,8 @@ static int32_t HdfAdapterStartListenIoctl(int fd) { int32_t ret = ioctl(fd, HDF_LISTEN_EVENT_START, 0); if (ret) { - HDF_LOGE("%s: failed to notify drv(%d) of start %d %{public}s", __func__, fd, errno, strerror(errno)); + HDF_LOGE("%{public}s: failed to notify drv(%{public}d) of start %{public}d %{public}s", + __func__, fd, errno, strerror(errno)); return HDF_ERR_IO; } @@ -306,7 +307,8 @@ static int32_t HdfAdapterStopListenIoctl(int fd) { int32_t ret = ioctl(fd, HDF_LISTEN_EVENT_STOP, 0); if (ret) { - HDF_LOGE("%s: failed to notify drv(%d) of stop %d %{public}s", __func__, fd, errno, strerror(errno)); + HDF_LOGE("%{public}s: failed to notify drv(%{public}d) of stop %{public}d %{public}s", + __func__, fd, errno, strerror(errno)); return HDF_ERR_IO; } @@ -317,23 +319,24 @@ static int32_t HdfAdapterExitListenIoctl(int fd) { int32_t ret = ioctl(fd, HDF_LISTEN_EVENT_EXIT, 0); if (ret) { - HDF_LOGE("%s: failed to notify drv(%d) of exit %d %{public}s", __func__, fd, errno, strerror(errno)); + HDF_LOGE("%{public}s: failed to notify drv(%{public}d) of exit %{public}d %{public}s", + __func__, fd, errno, strerror(errno)); return HDF_ERR_IO; } - HDF_LOGD("ioctl send poll thread(%d) exit event, ret=%d", fd, ret); + HDF_LOGD("ioctl send poll thread(%{public}d) exit event, ret=%{public}d", fd, ret); return HDF_SUCCESS; } static int32_t HdfDevListenerThreadDoInit(struct HdfDevListenerThread *thread) { if (OsalMutexInit(&thread->mutex) != HDF_SUCCESS) { - HDF_LOGE("%s: failed to create thread lock", __func__); + HDF_LOGE("%{public}s: failed to create thread lock", __func__); return HDF_FAILURE; } int32_t ret = OsalThreadCreate(&thread->thread, HdfDevEventListenTask, thread); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: failed to create thread", __func__); + HDF_LOGE("%{public}s: failed to create thread", __func__); thread->status = LISTENER_UNINITED; OsalMutexDestroy(&thread->mutex); return HDF_ERR_THREAD_CREATE_FAIL; @@ -449,7 +452,7 @@ static int32_t HdfDevListenerThreadStart(struct HdfDevListenerThread *thread) int32_t ret = HdfListenThreadInitPollFds(thread); if (ret != HDF_SUCCESS || thread->pfdSize <= 0) { - HDF_LOGE("%s:invalid poll list", __func__); + HDF_LOGE("%{public}s:invalid poll list", __func__); return HDF_DEV_ERR_NO_DEVICE; } @@ -472,7 +475,7 @@ static int32_t HdfDevListenerThreadStart(struct HdfDevListenerThread *thread) thread->status = LISTENER_STARTED; if (OsalThreadStart(&thread->thread, &config) != HDF_SUCCESS) { - HDF_LOGE("%s:OsalThreadStart failed", __func__); + HDF_LOGE("%{public}s:OsalThreadStart failed", __func__); ret = HDF_FAILURE; break; } @@ -556,7 +559,8 @@ static int32_t HdfListenThreadPollAdd(struct HdfDevListenerThread *thread, struc if (headAdapter != NULL) { if (ioctl(headAdapter->fd, HDF_LISTEN_EVENT_WAKEUP, 0) != 0) { - HDF_LOGE("%s: failed to wakeup drv to add poll %d %{public}s", __func__, errno, strerror(errno)); + HDF_LOGE("%{public}s: failed to wakeup drv to add poll %{public}d %{public}s", + __func__, errno, strerror(errno)); thread->pfds[index].fd = SYSCALL_INVALID_FD; ret = HDF_ERR_IO; break; @@ -596,7 +600,8 @@ static void HdfListenThreadPollDel(struct HdfDevListenerThread *thread, struct H HdfAdapterStopListenIoctl(adapter->fd); if (ioctl(adapter->fd, HDF_LISTEN_EVENT_WAKEUP, 0) != 0) { - HDF_LOGE("%s: failed to wakeup drv to del poll %d %s", __func__, errno, strerror(errno)); + HDF_LOGE("%{public}s: failed to wakeup drv to del poll %{public}d %{public}s", + __func__, errno, strerror(errno)); } DListRemove(&adapter->listNode); adapter->group = NULL; @@ -637,7 +642,7 @@ static void HdfDevListenerThreadDestroy(struct HdfDevListenerThread *thread) if (stopCount == 0) { thread->shouldStop = true; - HDF_LOGE("%s:failed to exit listener thread with ioctl, will go async way", __func__); + HDF_LOGE("%{public}s:failed to exit listener thread with ioctl, will go async way", __func__); return; } while (thread->status != LISTENER_EXITED && count <= TIMEOUT_US) { @@ -706,7 +711,7 @@ static int32_t HdfSyscallAdapterDispatch( static int TrytoLoadIoService(const char *serviceName, char *devNodePath, char *realPath) { if (HdfLoadDriverByServiceName(serviceName) != HDF_SUCCESS) { - HDF_LOGE("%s: load %{public}s driver failed", __func__, serviceName); + HDF_LOGE("%{public}s: load %{public}s driver failed", __func__, serviceName); return HDF_DEV_ERR_NO_DEVICE; } @@ -716,7 +721,7 @@ static int TrytoLoadIoService(const char *serviceName, char *devNodePath, char * waitCount--; } if (waitCount <= 0) { - HDF_LOGE("%s: char dev %{public}s is invalid", __func__, devNodePath); + HDF_LOGE("%{public}s: char dev %{public}s is invalid", __func__, devNodePath); return HDF_DEV_ERR_NO_DEVICE_SERVICE; } @@ -738,7 +743,7 @@ struct HdfIoService *HdfIoServiceAdapterObtain(const char *serviceName) nodePath = OsalMemCalloc(PATH_MAX); realPath = OsalMemCalloc(PATH_MAX); if (nodePath == NULL || realPath == NULL) { - HDF_LOGE("%s: out of memory", __func__); + HDF_LOGE("%{public}s: out of memory", __func__); goto OUT; } @@ -759,14 +764,14 @@ struct HdfIoService *HdfIoServiceAdapterObtain(const char *serviceName) DListHeadInit(&adapter->listenerList); if (OsalMutexInit(&adapter->mutex)) { - HDF_LOGE("%s: Failed to create mutex", __func__); + HDF_LOGE("%{public}s: Failed to create mutex", __func__); OsalMemFree(adapter); goto OUT; } adapter->fd = open(realPath, O_RDWR); if (adapter->fd < 0) { - HDF_LOGE("Open file node %{public}s failed, (%d)%{public}s", realPath, errno, strerror(errno)); + HDF_LOGE("Open file node %{public}s failed, (%{public}d)%{public}s", realPath, errno, strerror(errno)); OsalMutexDestroy(&adapter->mutex); OsalMemFree(adapter); goto OUT; @@ -813,7 +818,7 @@ static int32_t HdfIoServiceThreadBindLocked(struct HdfSyscallAdapter *adapter) static int32_t HdfIoServiceStartListen(struct HdfSyscallAdapter *adapter, int policy) { if (HdfIoServiceThreadBindLocked(adapter) != HDF_SUCCESS) { - HDF_LOGE("%s: Failed to bind a thread to SyscallAdapter", __func__); + HDF_LOGE("%{public}s: Failed to bind a thread to SyscallAdapter", __func__); return HDF_FAILURE; } adapter->thread->policy = policy; @@ -888,7 +893,7 @@ int32_t HdfDeviceUnregisterEventListener(struct HdfIoService *target, struct Hdf } if (listener->listNode.next == NULL || listener->listNode.prev == NULL) { - HDF_LOGE("%s: broken listener, may double unregister", __func__); + HDF_LOGE("%{public}s: broken listener, may double unregister", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -967,7 +972,7 @@ int32_t HdfIoServiceGroupRegisterListenerWithSchedPolicy( OsalMutexLock(&adapterGroup->mutex); if (HdfIoServiceGroupThreadInit(adapterGroup) != HDF_SUCCESS) { - HDF_LOGE("%s:failed to bind listener thread for service group", __func__); + HDF_LOGE("%{public}s:failed to bind listener thread for service group", __func__); OsalMutexUnlock(&adapterGroup->mutex); return HDF_FAILURE; } @@ -1036,7 +1041,7 @@ int32_t HdfIoServiceGroupUnregisterListener(struct HdfIoServiceGroup *group, str } if (listener->listNode.next == NULL || listener->listNode.prev == NULL) { - HDF_LOGE("%s:broken listener, may double unregister", __func__); + HDF_LOGE("%{public}s:broken listener, may double unregister", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -1076,7 +1081,7 @@ int32_t HdfIoServiceGroupAddService(struct HdfIoServiceGroup *group, struct HdfI OsalMutexLock(&adapterGroup->mutex); if (HdfIoServiceGroupThreadInit(adapterGroup) != HDF_SUCCESS) { - HDF_LOGE("%s:failed to bind listener thread for service group", __func__); + HDF_LOGE("%{public}s:failed to bind listener thread for service group", __func__); OsalMutexUnlock(&adapterGroup->mutex); return HDF_FAILURE; } diff --git a/framework/core/common/src/devmgr_service_start.c b/framework/core/common/src/devmgr_service_start.c index bf7909d36..ad0c8d258 100644 --- a/framework/core/common/src/devmgr_service_start.c +++ b/framework/core/common/src/devmgr_service_start.c @@ -30,7 +30,7 @@ static int32_t GetDeviceServiceNameByClass(struct HdfSBuf *data, struct HdfSBuf } if (!HdfSbufReadInt32(data, &deviceClass)) { - HDF_LOGE("%s: failed to get deviceClass", __func__); + HDF_LOGE("%{public}s: failed to get deviceClass", __func__); return HDF_FAILURE; } @@ -74,7 +74,7 @@ int DeviceManagerDispatch(struct HdfObject *stub, int code, struct HdfSBuf *data }; (void)stub; if (devMgrSvc == NULL) { - HDF_LOGE("%s: input param is invalid", __func__); + HDF_LOGE("%{public}s: input param is invalid", __func__); return ret; } OsalMutexLock(&devMgrSvc->devMgrMutex); @@ -97,7 +97,7 @@ int DeviceManagerDispatch(struct HdfObject *stub, int code, struct HdfSBuf *data ret = ListAllDevice(devMgrSvc, reply); break; default: - HDF_LOGE("%s: unsupported configuration type: %d", __func__, code); + HDF_LOGE("%{public}s: unsupported configuration type: %{public}d", __func__, code); break; } OsalMutexUnlock(&devMgrSvc->devMgrMutex); @@ -145,7 +145,7 @@ int DeviceManagerStartStep2(void) { struct DevmgrService *devMgrSvc = NULL; if (DeviceManagerIsQuickLoad() == DEV_MGR_SLOW_LOAD) { - HDF_LOGW("%s: device manager is not set to QuickLoad mode", __func__); + HDF_LOGW("%{public}s: device manager is not set to QuickLoad mode", __func__); return HDF_SUCCESS; } devMgrSvc = (struct DevmgrService *)DevmgrServiceGetInstance(); diff --git a/framework/core/common/src/hdf_attribute.c b/framework/core/common/src/hdf_attribute.c index b531a600b..2337c49dd 100644 --- a/framework/core/common/src/hdf_attribute.c +++ b/framework/core/common/src/hdf_attribute.c @@ -50,11 +50,11 @@ static bool GetHostInfo(const struct DeviceResourceNode *hostNode, struct HdfHos uint16_t readNum = 0; if ((HcsGetString(hostNode, ATTR_HOST_NAME, &hostInfo->hostName, NULL) != HDF_SUCCESS) || (strcmp(hostInfo->hostName, "") == 0)) { - HDF_LOGW("%s: get host name failed", __func__); + HDF_LOGW("%{public}s: get host name failed", __func__); return false; } if ((HcsGetUint16(hostNode, ATTR_DEV_PRIORITY, &readNum, 0) != HDF_SUCCESS) || (readNum > MAX_PRIORITY_NUM)) { - HDF_LOGW("%s: get host priority failed, priority is: %u", __func__, readNum); + HDF_LOGW("%{public}s: get host priority failed, priority is: %{public}u", __func__, readNum); return false; } hostInfo->priority = readNum; @@ -72,7 +72,7 @@ bool HdfAttributeManagerGetHostList(struct HdfSList *hostList) hdfManagerNode = GetHdfManagerNode(HdfGetHcsRootNode()); if (hdfManagerNode == NULL) { - HDF_LOGE("%s: get hdf manager node is null", __func__); + HDF_LOGE("%{public}s: get hdf manager node is null", __func__); return false; } @@ -81,7 +81,7 @@ bool HdfAttributeManagerGetHostList(struct HdfSList *hostList) struct HdfHostInfo *hostInfo = HdfHostInfoNewInstance(); if (hostInfo == NULL) { HdfSListFlush(hostList, HdfHostInfoDelete); - HDF_LOGE("%s: new hostInfo is null", __func__); + HDF_LOGE("%{public}s: new hostInfo is null", __func__); return false; } if (!GetHostInfo(hostNode, hostInfo)) { @@ -139,17 +139,17 @@ static const struct DeviceResourceNode *GetHostNode(const char *inHostName) static bool CheckDeviceInfo(const struct HdfDeviceInfo *deviceNodeInfo) { if (deviceNodeInfo->policy >= SERVICE_POLICY_INVALID) { - HDF_LOGE("%s: policy %u is invalid", __func__, deviceNodeInfo->policy); + HDF_LOGE("%{public}s: policy %{public}u is invalid", __func__, deviceNodeInfo->policy); return false; } if (deviceNodeInfo->priority > MAX_PRIORITY_NUM) { - HDF_LOGE("%s: priority %u is invalid", __func__, deviceNodeInfo->priority); + HDF_LOGE("%{public}s: priority %{public}u is invalid", __func__, deviceNodeInfo->priority); return false; } if (deviceNodeInfo->preload >= DEVICE_PRELOAD_INVALID) { - HDF_LOGE("%s: preload %u is invalid", __func__, deviceNodeInfo->preload); + HDF_LOGE("%{public}s: preload %{public}u is invalid", __func__, deviceNodeInfo->preload); return false; } @@ -165,12 +165,12 @@ static bool GetDeviceNodeInfo(const struct DeviceResourceNode *deviceNode, struc HcsGetString(deviceNode, ATTR_DEV_MATCHATTR, &deviceNodeInfo->deviceMatchAttr, NULL); if (HcsGetString(deviceNode, ATTR_DEV_MODULENAME, &deviceNodeInfo->moduleName, NULL) != HDF_SUCCESS) { - HDF_LOGE("%s: failed to get module name", __func__); + HDF_LOGE("%{public}s: failed to get module name", __func__); return false; } if (HcsGetString(deviceNode, ATTR_DEV_SVCNAME, &deviceNodeInfo->svcName, NULL) != HDF_SUCCESS) { - HDF_LOGE("%s: failed to get service name", __func__); + HDF_LOGE("%{public}s: failed to get service name", __func__); return false; } deviceNodeInfo->deviceName = deviceNode->name; @@ -192,14 +192,15 @@ static bool GetDevcieNodeList( } if (!GetDeviceNodeInfo(devNodeResource, deviceNodeInfo)) { HdfDeviceInfoFreeInstance(deviceNodeInfo); - HDF_LOGE("%s: failed to parse device node info, ignore", __func__); + HDF_LOGE("%{public}s: failed to parse device node info, ignore", __func__); continue; } deviceNodeInfo->deviceId = MK_DEVID(hostId, deviceIdx, deviceNodeIdx); if (deviceNodeInfo->preload != DEVICE_PRELOAD_DISABLE) { if (!HdfSListAddOrder(&hostClnt->unloadDevInfos, &deviceNodeInfo->node, HdfDeviceListCompare)) { - HDF_LOGE("%s: failed to add device info to list %s", __func__, deviceNodeInfo->svcName); + HDF_LOGE("%{public}s: failed to add device info to list %{public}s", + __func__, deviceNodeInfo->svcName); HdfDeviceInfoFreeInstance(deviceNodeInfo); continue; } diff --git a/framework/core/common/src/hdf_attribute_macro.c b/framework/core/common/src/hdf_attribute_macro.c index dc15d38a6..7fc3de1c8 100644 --- a/framework/core/common/src/hdf_attribute_macro.c +++ b/framework/core/common/src/hdf_attribute_macro.c @@ -38,7 +38,7 @@ static bool GetHostInfoMacro(const struct HdfHostType *hostNode, struct HdfHostI return false; } if (hostInfo->priority > MAX_PRIORITY_NUM) { - HDF_LOGW("GetHostInfoMacro get host priority failed, priority is: %u", hostInfo->priority); + HDF_LOGW("GetHostInfoMacro get host priority failed, priority is: %{public}u", hostInfo->priority); return false; } @@ -79,7 +79,7 @@ bool HdfAttributeManagerGetHostList(struct HdfSList *hostList) struct HdfHostInfo *hostInfo = HdfHostInfoNewInstance(); if (hostInfo == NULL) { HdfSListFlush(hostList, HdfHostInfoDelete); - HDF_LOGE("%s: new hostInfo is null", __func__); + HDF_LOGE("%{public}s: new hostInfo is null", __func__); return false; } @@ -115,17 +115,17 @@ static bool HdfDeviceListCompareMacro(struct HdfSListNode *listEntryFirst, struc static bool CheckDeviceInfoMacro(const struct HdfDeviceInfo *deviceNodeInfo) { if (deviceNodeInfo->policy >= SERVICE_POLICY_INVALID) { - HDF_LOGE("CheckDeviceInfoMacro policy %u is invalid", deviceNodeInfo->policy); + HDF_LOGE("CheckDeviceInfoMacro policy %{public}u is invalid", deviceNodeInfo->policy); return false; } if (deviceNodeInfo->priority > MAX_PRIORITY_NUM) { - HDF_LOGE("CheckDeviceInfoMacro priority %u is invalid", deviceNodeInfo->priority); + HDF_LOGE("CheckDeviceInfoMacro priority %{public}u is invalid", deviceNodeInfo->priority); return false; } if (deviceNodeInfo->preload >= DEVICE_PRELOAD_INVALID) { - HDF_LOGE("CheckDeviceInfoMacro preload %u is invalid", deviceNodeInfo->preload); + HDF_LOGE("CheckDeviceInfoMacro preload %{public}u is invalid", deviceNodeInfo->preload); return false; } @@ -161,14 +161,14 @@ static bool GetDevcieNodeList(const struct HdfDeviceType *device, } if (!GetDeviceNodeInfo(devNode, devInfo)) { HdfDeviceInfoFreeInstance(devInfo); - HDF_LOGE("%s: failed to parse device node info, ignore", __func__); + HDF_LOGE("%{public}s: failed to parse device node info, ignore", __func__); continue; } devInfo->deviceId = MK_DEVID(hostId, deviceIdx, deviceNodeIdx); if (devInfo->preload != DEVICE_PRELOAD_DISABLE) { if (!HdfSListAddOrder(&hostClnt->unloadDevInfos, &devInfo->node, HdfDeviceListCompareMacro)) { - HDF_LOGE("%s: failed to add device info to list %s", __func__, devInfo->svcName); + HDF_LOGE("%{public}s: failed to add device info to list %{public}s", __func__, devInfo->svcName); HdfDeviceInfoFreeInstance(devInfo); continue; } diff --git a/framework/core/common/src/hdf_device_node_ext.c b/framework/core/common/src/hdf_device_node_ext.c index 326dc927f..7231c2432 100644 --- a/framework/core/common/src/hdf_device_node_ext.c +++ b/framework/core/common/src/hdf_device_node_ext.c @@ -79,7 +79,7 @@ static int DeviceNodeExtPublishService(struct HdfDeviceNode *devNode) // base(device node) publish inner service ret = HdfDeviceNodePublishPublicService(devNode); if (ret != HDF_SUCCESS) { - HDF_LOGE("failed to publish device service, ret is %d", ret); + HDF_LOGE("failed to publish device service, ret is %{public}d", ret); HdfIoServiceRemove(devNodeExt->ioService); devNodeExt->ioService = NULL; return ret; diff --git a/framework/core/host/src/devhost_service.c b/framework/core/host/src/devhost_service.c index 363e78913..9aa143452 100644 --- a/framework/core/host/src/devhost_service.c +++ b/framework/core/host/src/devhost_service.c @@ -47,6 +47,7 @@ static struct HdfDevice *DevHostServiceQueryOrAddDevice(struct DevHostService *i { struct HdfDevice *device = DevHostServiceFindDevice(inst, deviceId); if (device == NULL) { + HDF_LOGD("%{public}s can't find device %{public}d, try to create", __func__, deviceId); device = HdfDeviceNewInstance(); if (device == NULL) { HDF_LOGE("Dev host service failed to create driver instance"); @@ -54,6 +55,7 @@ static struct HdfDevice *DevHostServiceQueryOrAddDevice(struct DevHostService *i } device->deviceId = MK_DEVID(inst->hostId, deviceId, 0); DListInsertHead(&device->node, &inst->devices); + HDF_LOGD("%{public}s add device %{public}d complete", __func__, deviceId); } return device; } @@ -78,7 +80,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice } devNode = device->super.GetDeviceNode(&device->super, deviceInfo->deviceId); if (devNode != NULL) { - HDF_LOGE("failed to add device %d, device already exist", deviceInfo->deviceId); + HDF_LOGE("failed to add device %{public}d, device already exist", deviceInfo->deviceId); return HDF_ERR_DEVICE_BUSY; } driver = driverLoader->GetDriver(deviceInfo->moduleName); @@ -101,6 +103,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice HdfDeviceNodeFreeInstance(devNode); goto ERROR; } + HDF_LOGD("%{public}s add device %{public}d success", __func__, deviceInfo->deviceId); return HDF_SUCCESS; ERROR: @@ -125,17 +128,17 @@ int DevHostServiceDelDevice(struct IDevHostService *inst, devid_t devId) devNode = device->super.GetDeviceNode(&device->super, devId); if (devNode == NULL) { - HDF_LOGI("failed to del device %u, not exist", devId); + HDF_LOGI("failed to del device %{public}u, not exist", devId); return HDF_DEV_ERR_NO_DEVICE; } if (device->super.Detach == NULL) { - HDF_LOGE("failed to del device %u, invalid device", devId); + HDF_LOGE("failed to del device %{public}u, invalid device", devId); return HDF_ERR_INVALID_OBJECT; } if (device->super.Detach(&device->super, devNode) != HDF_SUCCESS) { - HDF_LOGE("failed to detach device %u", devId); + HDF_LOGE("failed to detach device %{public}u", devId); return HDF_FAILURE; } HdfDeviceNodeFreeInstance(devNode); @@ -143,6 +146,7 @@ int DevHostServiceDelDevice(struct IDevHostService *inst, devid_t devId) if (DListIsEmpty(&device->devNodes)) { DevHostServiceFreeDevice(hostService, device); } + HDF_LOGD("%{public}s add device %{public}u success", __func__, devId); return HDF_SUCCESS; } @@ -168,7 +172,8 @@ static int ApplyDevicesPowerState(struct HdfDevice *device, uint32_t state) if (deviceNode->powerToken != NULL) { ret = PowerStateChange(deviceNode->powerToken, state); if (ret != HDF_SUCCESS) { - HDF_LOGE("device %s failed to resume(%u)", deviceNode->driver->entry->moduleName, state); + HDF_LOGE("device %{public}s failed to resume(%{public}u)", + deviceNode->driver->entry->moduleName, state); } } } @@ -177,7 +182,8 @@ static int ApplyDevicesPowerState(struct HdfDevice *device, uint32_t state) if (deviceNode->powerToken != NULL) { ret = PowerStateChange(deviceNode->powerToken, state); if (ret != HDF_SUCCESS) { - HDF_LOGE("device %s failed to suspend(%u)", deviceNode->driver->entry->moduleName, state); + HDF_LOGE("device %{public}s failed to suspend(%{public}u)", + deviceNode->driver->entry->moduleName, state); } } } @@ -196,7 +202,7 @@ static int DevHostServicePmNotify(struct IDevHostService *service, uint32_t stat return HDF_FAILURE; } - HDF_LOGD("host(%s) set power state=%u", hostService->hostName, state); + HDF_LOGD("host(%{public}s) set power state=%{public}u", hostService->hostName, state); if (IsPowerWakeState(state)) { DLIST_FOR_EACH_ENTRY_REVERSE(device, &hostService->devices, struct HdfDevice, node) { if (ApplyDevicesPowerState(device, state) != HDF_SUCCESS) { diff --git a/framework/core/host/src/hdf_device.c b/framework/core/host/src/hdf_device.c index 57c8abd9b..e595bab30 100644 --- a/framework/core/host/src/hdf_device.c +++ b/framework/core/host/src/hdf_device.c @@ -107,7 +107,8 @@ int HdfDeviceDetach(struct IHdfDevice *devInst, struct HdfDeviceNode *devNode) device = CONTAINER_OF(devInst, struct HdfDevice, super); if (DEVICEID(device->deviceId) != DEVICEID(devNode->devId)) { - HDF_LOGE("%s: device %x detach unknown devnode %x", __func__, device->deviceId, devNode->devId); + HDF_LOGE("%{public}s: device %{public}x detach unknown devnode %{public}x", + __func__, device->deviceId, devNode->devId); return HDF_DEV_ERR_NO_DEVICE; } @@ -138,7 +139,7 @@ static int HdfDeviceDetachWithDevid(struct IHdfDevice *device, devid_t devid) struct HdfDevice *dev = CONTAINER_OF(device, struct HdfDevice, super); struct HdfDeviceNode *devNode = HdfDeviceGetDeviceNode(device, devid); if (devNode == NULL) { - HDF_LOGE("detach device node %x not in device %x", devid, dev->deviceId); + HDF_LOGE("detach device node %{public}x not in device %{public}x", devid, dev->deviceId); return HDF_DEV_ERR_NO_DEVICE; } diff --git a/framework/core/host/src/hdf_device_node.c b/framework/core/host/src/hdf_device_node.c index f8bc59aa1..6475b0991 100644 --- a/framework/core/host/src/hdf_device_node.c +++ b/framework/core/host/src/hdf_device_node.c @@ -70,13 +70,13 @@ int DeviceDriverBind(struct HdfDeviceNode *devNode) driverEntry = devNode->driver->entry; if (devNode->policy == SERVICE_POLICY_PUBLIC || devNode->policy == SERVICE_POLICY_CAPACITY) { if (driverEntry->Bind == NULL) { - HDF_LOGE("driver %s bind method not implement", driverEntry->moduleName); + HDF_LOGE("driver %{public}s bind method not implement", driverEntry->moduleName); devNode->devStatus = DEVNODE_NONE; return HDF_ERR_INVALID_OBJECT; } ret = driverEntry->Bind(&devNode->deviceObject); if (ret != HDF_SUCCESS) { - HDF_LOGE("bind driver %s failed", driverEntry->moduleName); + HDF_LOGE("bind driver %{public}s failed", driverEntry->moduleName); return HDF_DEV_ERR_DEV_INIT_FAIL; } } diff --git a/framework/core/host/src/hdf_device_object.c b/framework/core/host/src/hdf_device_object.c index 16f102094..fed79048e 100644 --- a/framework/core/host/src/hdf_device_object.c +++ b/framework/core/host/src/hdf_device_object.c @@ -116,7 +116,7 @@ void HdfPmAcquireDeviceAsync(struct HdfDeviceObject *deviceObject) struct HdfDeviceNode *devNode = NULL; if (deviceObject == NULL) { - HDF_LOGE("%s: input param is invalid", __func__); + HDF_LOGE("%{public}s: input param is invalid", __func__); return; } @@ -130,7 +130,7 @@ void HdfPmReleaseDeviceAsync(struct HdfDeviceObject *deviceObject) struct HdfDeviceNode *devNode = NULL; if (deviceObject == NULL) { - HDF_LOGE("%s: input param is invalid", __func__); + HDF_LOGE("%{public}s: input param is invalid", __func__); return; } @@ -145,7 +145,7 @@ void HdfPmSetMode(struct HdfDeviceObject *deviceObject, uint32_t mode) struct HdfDeviceNode *devNode = NULL; struct PowerStateToken *token = NULL; if (deviceObject == NULL || mode > HDF_POWER_MODE_MAX) { - HDF_LOGE("%s: input param is invalid", __func__); + HDF_LOGE("%{public}s: input param is invalid", __func__); return; } devNode = (struct HdfDeviceNode *)HDF_SLIST_CONTAINER_OF( @@ -236,13 +236,13 @@ int HdfDeviceObjectRegister(struct HdfDeviceObject *dev) devNode->driver = driverLoader->GetDriver(devNode->driverName); if (devNode->driver == NULL) { - HDF_LOGE("can not found driver %s", devNode->driverName); + HDF_LOGE("can not found driver %{public}s", devNode->driverName); return HDF_DEV_ERR_NO_DEVICE; } ret = devNode->device->super.Attach(&devNode->device->super, devNode); if (ret != HDF_SUCCESS) { - HDF_LOGE("failed to attach device %s", devNode->driverName); + HDF_LOGE("failed to attach device %{public}s", devNode->driverName); return HDF_DEV_ERR_ATTACHDEV_FAIL; } diff --git a/framework/core/host/src/hdf_driver_loader.c b/framework/core/host/src/hdf_driver_loader.c index 66495ef18..abcbdce8d 100644 --- a/framework/core/host/src/hdf_driver_loader.c +++ b/framework/core/host/src/hdf_driver_loader.c @@ -20,7 +20,7 @@ int32_t HdfDriverEntryConstruct(void) size_t *addrBegin = NULL; int32_t count = (int32_t)(((uint8_t *)(HDF_DRIVER_END()) - (uint8_t *)(HDF_DRIVER_BEGIN())) / sizeof(size_t)); if (count <= 0) { - HDF_LOGE("%s: no hdf driver exist", __func__); + HDF_LOGE("%{public}s: no hdf driver exist", __func__); return HDF_FAILURE; } @@ -28,7 +28,8 @@ int32_t HdfDriverEntryConstruct(void) for (i = 0; i < count; i++) { driverEntry = (struct HdfDriverEntry *)(*addrBegin); if (HdfRegisterDriverEntry(driverEntry) != HDF_SUCCESS) { - HDF_LOGE("failed to register driver %s, skip and try another", driverEntry ? driverEntry->moduleName : ""); + HDF_LOGE("failed to register driver %{public}s, skip and try another", + driverEntry ? driverEntry->moduleName : ""); continue; } addrBegin++; @@ -39,7 +40,7 @@ int32_t HdfDriverEntryConstruct(void) struct HdfDriver *HdfDriverLoaderGetDriver(const char *moduleName) { if (moduleName == NULL) { - HDF_LOGE("%s: failed to get device entry, moduleName is NULL", __func__); + HDF_LOGE("%{public}s: failed to get device entry, moduleName is NULL", __func__); return NULL; } diff --git a/framework/core/host/src/hdf_observer_record.c b/framework/core/host/src/hdf_observer_record.c index 8caa0e51d..ba60bcc7a 100644 --- a/framework/core/host/src/hdf_observer_record.c +++ b/framework/core/host/src/hdf_observer_record.c @@ -58,7 +58,7 @@ void HdfServiceObserverRecordNotifySubscribers( { struct HdfSListIterator it; if (record == NULL) { - HDF_LOGE("%s: record is null", __func__); + HDF_LOGE("%{public}s: record is null", __func__); return; } diff --git a/framework/core/manager/src/devhost_service_clnt.c b/framework/core/manager/src/devhost_service_clnt.c index ac0bc0431..354b4e046 100644 --- a/framework/core/manager/src/devhost_service_clnt.c +++ b/framework/core/manager/src/devhost_service_clnt.c @@ -69,7 +69,7 @@ static int32_t DevHostServiceClntConstruct(struct DevHostServiceClnt *hostClnt) HdfSListInit(&hostClnt->dynamicDevInfos); hostClnt->deviceHashMap = (Map *)OsalMemCalloc(sizeof(Map)); if (hostClnt->deviceHashMap == NULL) { - HDF_LOGE("%s:failed to malloc deviceHashMap", __func__); + HDF_LOGE("%{public}s:failed to malloc deviceHashMap", __func__); return HDF_ERR_MALLOC_FAIL; } if (OsalMutexInit(&hostClnt->hostLock) != HDF_SUCCESS) { diff --git a/framework/core/manager/src/devmgr_service.c b/framework/core/manager/src/devmgr_service.c index 38c7b3bdd..513b35bc8 100644 --- a/framework/core/manager/src/devmgr_service.c +++ b/framework/core/manager/src/devmgr_service.c @@ -342,7 +342,7 @@ static int DevmgrServiceStartDeviceHosts(struct DevmgrService *inst) HdfSListInit(&hostList); if (!HdfAttributeManagerGetHostList(&hostList)) { - HDF_LOGW("%s: host list is null", __func__); + HDF_LOGW("%{public}s: host list is null", __func__); return HDF_SUCCESS; } HdfSListIteratorInit(&it, &hostList); @@ -452,7 +452,7 @@ bool DevmgrServiceConstruct(struct DevmgrService *inst) { struct IDevmgrService *devMgrSvcIf = NULL; if (OsalMutexInit(&inst->devMgrMutex) != HDF_SUCCESS) { - HDF_LOGE("%s:failed to mutex init ", __func__); + HDF_LOGE("%{public}s:failed to mutex init ", __func__); return false; } devMgrSvcIf = (struct IDevmgrService *)inst; diff --git a/framework/core/manager/src/devsvc_manager.c b/framework/core/manager/src/devsvc_manager.c index 3374a2fb3..4d5ec55f1 100644 --- a/framework/core/manager/src/devsvc_manager.c +++ b/framework/core/manager/src/devsvc_manager.c @@ -354,7 +354,7 @@ bool DevSvcManagerConstruct(struct DevSvcManager *inst) { struct IDevSvcManager *devSvcMgrIf = NULL; if (inst == NULL) { - HDF_LOGE("%s: inst is null!", __func__); + HDF_LOGE("%{public}s: inst is null!", __func__); return false; } devSvcMgrIf = &inst->super; diff --git a/framework/core/manager/src/devsvc_manager_ext.c b/framework/core/manager/src/devsvc_manager_ext.c index d38b2eea6..aea085026 100644 --- a/framework/core/manager/src/devsvc_manager_ext.c +++ b/framework/core/manager/src/devsvc_manager_ext.c @@ -50,7 +50,7 @@ static int32_t DevSvcManagerExtRegisterListener(struct HdfDeviceIoClient *client holder = ServStatListenerHolderGet((uintptr_t)client); if (holder != NULL) { - HDF_LOGE("%s:register listener exist, update and return", __func__); + HDF_LOGE("%{public}s:register listener exist, update and return", __func__); holder->listenClass = devClass; return HDF_SUCCESS; } diff --git a/framework/core/manager/src/driver_manager.c b/framework/core/manager/src/driver_manager.c index e93912da8..23193e814 100644 --- a/framework/core/manager/src/driver_manager.c +++ b/framework/core/manager/src/driver_manager.c @@ -122,7 +122,7 @@ struct HdfDriver *HdfDriverManagerGetDriver(const char *driverName) } if (HdfSysEventSend != NULL) { - HDF_LOGI("%s:try to dynamic load driver %s", __func__, driverName); + HDF_LOGI("%{public}s:try to dynamic load driver %{public}s", __func__, driverName); if (HdfSysEventSend(HDF_SYSEVENT_CLASS_MODULE, KEVENT_MODULE_INSTALL, driverName, true) != HDF_SUCCESS) { return NULL; } @@ -130,7 +130,7 @@ struct HdfDriver *HdfDriverManagerGetDriver(const char *driverName) driver = HdfDriverManagerFoundDriver(driverName); } if (driver == NULL) { - HDF_LOGE("%s:driver %s not found", __func__, driverName); + HDF_LOGE("%{public}s:driver %{public}s not found", __func__, driverName); } return driver; } diff --git a/framework/core/manager/src/hdf_driver_installer.c b/framework/core/manager/src/hdf_driver_installer.c index 755a03248..730bc92c2 100644 --- a/framework/core/manager/src/hdf_driver_installer.c +++ b/framework/core/manager/src/hdf_driver_installer.c @@ -24,7 +24,7 @@ static int DriverInstallerStartDeviceHost(uint32_t devHostId, const char *devHos } ret = hostServiceIf->StartService(hostServiceIf); if (ret != HDF_SUCCESS) { - HDF_LOGE("failed to start host service, ret: %d", ret); + HDF_LOGE("failed to start host service, ret: %{public}d", ret); DevHostServiceFreeInstance(hostServiceIf); } return ret; diff --git a/framework/core/shared/include/hdf_attribute_macro.h b/framework/core/shared/include/hdf_attribute_macro.h index 965e82583..58330efb3 100644 --- a/framework/core/shared/include/hdf_attribute_macro.h +++ b/framework/core/shared/include/hdf_attribute_macro.h @@ -44,7 +44,7 @@ struct HdfDeviceNodeType { do { \ deviceNode = (struct HdfDeviceNodeType *)OsalMemCalloc(sizeof(*deviceNode)); \ if (deviceNode == NULL) { \ - HDF_LOGE("%s malloc fail", __func__); \ + HDF_LOGE("%{public}s malloc fail", __func__); \ AttributeManagerFreeHost(host); \ return (retCode); \ } \ @@ -63,7 +63,7 @@ struct HdfDeviceNodeType { do { \ device = (struct HdfDeviceType *)OsalMemCalloc(sizeof(*device)); \ if (device == NULL) { \ - HDF_LOGE("%s malloc fail", __func__); \ + HDF_LOGE("%{public}s malloc fail", __func__); \ AttributeManagerFreeHost(host); \ return (retCode); \ } \ @@ -85,7 +85,7 @@ struct HdfDeviceNodeType { do { \ host = (struct HdfHostType *)OsalMemCalloc(sizeof(*host)); \ if (host == NULL) { \ - HDF_LOGE("%s malloc fail", __func__); \ + HDF_LOGE("%{public}s malloc fail", __func__); \ AttributeManagerFreeDevHost(devHost); \ return (retCode); \ } \ diff --git a/framework/core/shared/src/svcmgr_ioservice.c b/framework/core/shared/src/svcmgr_ioservice.c index 817e6b0ee..f9061014b 100644 --- a/framework/core/shared/src/svcmgr_ioservice.c +++ b/framework/core/shared/src/svcmgr_ioservice.c @@ -108,7 +108,7 @@ struct ISvcMgrIoservice *SvcMgrIoserviceGet(void) svcmgrInst->iosvc = HdfIoServiceBind(DEV_SVCMGR_NODE); if (svcmgrInst->iosvc == NULL) { - HDF_LOGE("ioserivce %s not exist", DEV_SVCMGR_NODE); + HDF_LOGE("ioserivce %{public}s not exist", DEV_SVCMGR_NODE); OsalMemFree(svcmgrInst); return NULL; } diff --git a/framework/utils/src/hdf_message_looper.c b/framework/utils/src/hdf_message_looper.c index 209250d43..d30ee279e 100644 --- a/framework/utils/src/hdf_message_looper.c +++ b/framework/utils/src/hdf_message_looper.c @@ -9,6 +9,7 @@ #include "hdf_message_looper.h" #include "hdf_message_task.h" #include "osal_message.h" +#include "hdf_log.h" void HdfMessageLooperStart(struct HdfMessageLooper *looper) { @@ -20,6 +21,7 @@ void HdfMessageLooperStart(struct HdfMessageLooper *looper) while (true) { message = HdfMessageQueueNext(&looper->messageQueue); if (message != NULL) { + HDF_LOGD("%{public}s received message %{public}d", __func__, message->messageId); if (message->messageId == MESSAGE_STOP_LOOP) { HdfMessageRecycle(message); OsalMessageQueueDestroy(&looper->messageQueue); -- Gitee From 5ff531436a52d85b78bbf7712173575d650785ae Mon Sep 17 00:00:00 2001 From: j30052480 Date: Thu, 21 Mar 2024 17:04:45 +0800 Subject: [PATCH 2/4] feat: hdf_core optimize log information Signed-off-by: j30052480 --- adapter/uhdf2/manager/src/devmgr_service_stub.c | 10 ++++++++-- adapter/uhdf2/manager/src/devsvc_manager_stub.c | 6 ++++-- framework/core/host/src/devhost_service.c | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/adapter/uhdf2/manager/src/devmgr_service_stub.c b/adapter/uhdf2/manager/src/devmgr_service_stub.c index 302d61ef6..5e05b25e7 100644 --- a/adapter/uhdf2/manager/src/devmgr_service_stub.c +++ b/adapter/uhdf2/manager/src/devmgr_service_stub.c @@ -110,6 +110,8 @@ int32_t DevmgrServiceStubDispatch(struct HdfRemoteService *stub, int code, struc return HDF_ERR_INVALID_PARAM; } uint32_t hostId = 0; + HDF_LOGD("DevmgrServiceStubDispatch called: code=%{public}d, calling pid=%{public}d", + code, HdfRemoteGetCallingPid()); switch (code) { case DEVMGR_SERVICE_ATTACH_DEVICE_HOST: if (!HdfSbufReadUint32(data, &hostId)) { @@ -244,18 +246,19 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) { struct DevmgrServiceStub *fullService = (struct DevmgrServiceStub *)inst; if (fullService == NULL) { + HDF_LOGE("Start service failed, fullService is null"); return HDF_ERR_INVALID_PARAM; } struct IDevSvcManager *serviceManager = DevSvcManagerGetInstance(); if (serviceManager == NULL) { - HDF_LOGI("Start service failed, fullService is null"); + HDF_LOGE("Start service failed, get service manager failed"); return HDF_ERR_INVALID_OBJECT; } struct HdfRemoteService *remoteService = HdfRemoteServiceObtain((struct HdfObject *)inst, &g_devmgrDispatcher); if (remoteService == NULL) { - HDF_LOGI("failed to start devmgr, remoteService obtain err"); + HDF_LOGE("failed to start devmgr, remoteService obtain err"); return HDF_ERR_MALLOC_FAIL; } if (!HdfRemoteServiceSetInterfaceDesc(remoteService, "HDI.IDeviceManager.V1_0")) { @@ -265,6 +268,7 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) } struct HdfDeviceObject *deviceObject = OsalMemCalloc(sizeof(struct HdfDeviceObject)); if (deviceObject == NULL) { + HDF_LOGE("%{public}s: failed to malloc device obj", __func__); HdfRemoteServiceRecycle(remoteService); return HDF_ERR_MALLOC_FAIL; } @@ -276,6 +280,7 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) info.devClass = DEVICE_CLASS_DEFAULT; int status = DevSvcManagerAddService(serviceManager, deviceObject, &info); if (status != HDF_SUCCESS) { + HDF_LOGE("%{public}s: failed to add service", __func__); HdfRemoteServiceRecycle(remoteService); OsalMemFree(deviceObject); return status; @@ -285,6 +290,7 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) (void)DriverModuleLoadHelperInit(); status = DevmgrServiceStartService((struct IDevmgrService *)&fullService->super); if (status != HDF_SUCCESS) { + HDF_LOGE("%{public}s: failed to start service", __func__); HdfRemoteServiceRecycle(remoteService); OsalMemFree(deviceObject); return status; diff --git a/adapter/uhdf2/manager/src/devsvc_manager_stub.c b/adapter/uhdf2/manager/src/devsvc_manager_stub.c index 452ea9bd2..a85a3bbf1 100644 --- a/adapter/uhdf2/manager/src/devsvc_manager_stub.c +++ b/adapter/uhdf2/manager/src/devsvc_manager_stub.c @@ -408,7 +408,7 @@ static int32_t DevSvcManagerStubRemoveService(struct IDevSvcManager *super, stru OsalMutexLock(&stub->devSvcStubMutex); if (!CheckServiceObjectValidNoLock(stub, serviceObject)) { OsalMutexUnlock(&stub->devSvcStubMutex); - HDF_LOGI("StubRemoveService service %{public}s is invalid", name); + HDF_LOGE("StubRemoveService service %{public}s is invalid", name); return HDF_FAILURE; } @@ -497,7 +497,8 @@ int DevSvcManagerStubDispatch(struct HdfRemoteService *service, int code, struct return ret; } struct IDevSvcManager *super = (struct IDevSvcManager *)&stub->super; - HDF_LOGD("DevSvcManagerStubDispatch called: code=%{public}d", code); + HDF_LOGD("DevSvcManagerStubDispatch called: code=%{public}d, calling pid=%{public}d", + code, HdfRemoteGetCallingPid()); switch (code) { case DEVSVC_MANAGER_ADD_SERVICE: ret = DevSvcManagerStubAddService(super, data); @@ -574,6 +575,7 @@ int DevSvcManagerStubStart(struct IDevSvcManager *svcmgr) { struct DevSvcManagerStub *inst = (struct DevSvcManagerStub *)svcmgr; if (inst == NULL) { + HDF_LOGE("%{public}s: failed to init interface desc", __func__); return HDF_ERR_INVALID_PARAM; } if (inst->started) { diff --git a/framework/core/host/src/devhost_service.c b/framework/core/host/src/devhost_service.c index 9aa143452..9ec409e5d 100644 --- a/framework/core/host/src/devhost_service.c +++ b/framework/core/host/src/devhost_service.c @@ -76,6 +76,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice device = DevHostServiceQueryOrAddDevice(hostService, DEVICEID(deviceInfo->deviceId)); if (device == NULL || device->super.Attach == NULL) { + HDF_LOGE("failed to add device %{public}d, device or Attach func is null", deviceInfo->deviceId); return HDF_DEV_ERR_NO_DEVICE; } devNode = device->super.GetDeviceNode(&device->super, deviceInfo->deviceId); @@ -85,12 +86,14 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice } driver = driverLoader->GetDriver(deviceInfo->moduleName); if (driver == NULL) { + HDF_LOGE("failed to add device %{public}s, get driver failed", deviceInfo->moduleName); ret = HDF_DEV_ERR_NODATA; goto ERROR; } devNode = HdfDeviceNodeNewInstance(deviceInfo, driver); if (devNode == NULL) { + HDF_LOGE("failed to add device %{public}d, create devNode failed", deviceInfo->deviceId); driverLoader->ReclaimDriver(driver); return HDF_DEV_ERR_NO_MEMORY; } @@ -100,6 +103,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice devNode->driver = driver; ret = device->super.Attach(&device->super, devNode); if (ret != HDF_SUCCESS) { + HDF_LOGE("failed to add device %{public}d, attach devNode failed", deviceInfo->deviceId); HdfDeviceNodeFreeInstance(devNode); goto ERROR; } -- Gitee From 655089393f27adbc10069c8ef74e7a865355e927 Mon Sep 17 00:00:00 2001 From: j30052480 Date: Thu, 21 Mar 2024 19:30:09 +0800 Subject: [PATCH 3/4] feat: hdf_core optimize log information Signed-off-by: j30052480 --- .../uhdf2/manager/src/devmgr_service_stub.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/adapter/uhdf2/manager/src/devmgr_service_stub.c b/adapter/uhdf2/manager/src/devmgr_service_stub.c index 5e05b25e7..4e30c2db4 100644 --- a/adapter/uhdf2/manager/src/devmgr_service_stub.c +++ b/adapter/uhdf2/manager/src/devmgr_service_stub.c @@ -35,6 +35,18 @@ #define HDF_LOG_TAG devmgr_service_stub +static int32_t DevmgrServiceStubDispatchAttachDeviceHost(struct IDevmgrService *devmgrSvc, struct HdfSBuf *data) +{ + uint32_t hostId = 0; + if (!HdfSbufReadUint32(data, &hostId)) { + HDF_LOGE("invalid host id"); + return HDF_FAILURE; + } + struct HdfRemoteService *service = HdfSbufReadRemoteService(data); + struct IDevHostService *hostIf = DevHostServiceProxyObtain(hostId, service); + return devmgrSvc->AttachDeviceHost(devmgrSvc, hostId, hostIf); +} + static int32_t DevmgrServiceStubDispatchAttachDevice(struct IDevmgrService *devmgrSvc, struct HdfSBuf *data) { uint32_t deviceId; @@ -109,18 +121,11 @@ int32_t DevmgrServiceStubDispatch(struct HdfRemoteService *stub, int code, struc HDF_LOGE("%{public}s: invalid interface token, code=%{public}d", __func__, code); return HDF_ERR_INVALID_PARAM; } - uint32_t hostId = 0; HDF_LOGD("DevmgrServiceStubDispatch called: code=%{public}d, calling pid=%{public}d", code, HdfRemoteGetCallingPid()); switch (code) { case DEVMGR_SERVICE_ATTACH_DEVICE_HOST: - if (!HdfSbufReadUint32(data, &hostId)) { - HDF_LOGE("invalid host id"); - return HDF_FAILURE; - } - struct HdfRemoteService *service = HdfSbufReadRemoteService(data); - struct IDevHostService *hostIf = DevHostServiceProxyObtain(hostId, service); - ret = super->AttachDeviceHost(super, hostId, hostIf); + ret = DevmgrServiceStubDispatchAttachDeviceHost(super, data); break; case DEVMGR_SERVICE_ATTACH_DEVICE: ret = DevmgrServiceStubDispatchAttachDevice(super, data); @@ -249,13 +254,11 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) HDF_LOGE("Start service failed, fullService is null"); return HDF_ERR_INVALID_PARAM; } - struct IDevSvcManager *serviceManager = DevSvcManagerGetInstance(); if (serviceManager == NULL) { HDF_LOGE("Start service failed, get service manager failed"); return HDF_ERR_INVALID_OBJECT; } - struct HdfRemoteService *remoteService = HdfRemoteServiceObtain((struct HdfObject *)inst, &g_devmgrDispatcher); if (remoteService == NULL) { HDF_LOGE("failed to start devmgr, remoteService obtain err"); -- Gitee From 3d6293f077133f139f4142577278ee606c345b2a Mon Sep 17 00:00:00 2001 From: j30052480 Date: Thu, 21 Mar 2024 20:36:43 +0800 Subject: [PATCH 4/4] feat: hdf_core optimize log information Signed-off-by: j30052480 --- adapter/uhdf2/manager/src/devmgr_service_stub.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/adapter/uhdf2/manager/src/devmgr_service_stub.c b/adapter/uhdf2/manager/src/devmgr_service_stub.c index 4e30c2db4..41edbff17 100644 --- a/adapter/uhdf2/manager/src/devmgr_service_stub.c +++ b/adapter/uhdf2/manager/src/devmgr_service_stub.c @@ -254,16 +254,14 @@ int DevmgrServiceStubStartService(struct IDevmgrService *inst) HDF_LOGE("Start service failed, fullService is null"); return HDF_ERR_INVALID_PARAM; } + struct IDevSvcManager *serviceManager = DevSvcManagerGetInstance(); - if (serviceManager == NULL) { - HDF_LOGE("Start service failed, get service manager failed"); - return HDF_ERR_INVALID_OBJECT; - } struct HdfRemoteService *remoteService = HdfRemoteServiceObtain((struct HdfObject *)inst, &g_devmgrDispatcher); - if (remoteService == NULL) { - HDF_LOGE("failed to start devmgr, remoteService obtain err"); - return HDF_ERR_MALLOC_FAIL; + if (serviceManager == NULL || remoteService == NULL) { + HDF_LOGE("Start service failed, get service manager failed or remoteService obtain err"); + return HDF_FAILURE; } + if (!HdfRemoteServiceSetInterfaceDesc(remoteService, "HDI.IDeviceManager.V1_0")) { HDF_LOGE("%{public}s: failed to init interface desc", __func__); HdfRemoteServiceRecycle(remoteService); -- Gitee