!2485 fix:repair dump service crash

Merge pull request !2485 from liveery/master
This commit is contained in:
openharmony_ci 2024-01-18 13:32:19 +00:00 committed by Gitee
commit 64115ca93e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -101,7 +101,8 @@ static void DumpOneService(const Service *service)
printf("\tservice name: [%s] \n", service->name);
printf("\tservice pid: [%d] \n", service->pid);
if (service->lastErrno < sizeof(initErrMaps)) {
int tmpCount = sizeof(initErrMaps) / sizeof(initErrMaps[0]);
if (service->lastErrno < tmpCount) {
printf("\tservice last error: %s(%d) \n", initErrMaps[service->lastErrno].info, service->lastErrno);
} else {
printf("\tservice last error: %d \n", service->lastErrno);