From 429be4076909d8a1602d1b749db9ac6e75918b2a Mon Sep 17 00:00:00 2001 From: zhong_ning Date: Thu, 22 Jul 2021 16:36:34 +0800 Subject: [PATCH 1/3] fix code style Signed-off-by: zhong_ning --- services/src/appspawn_process.c | 5 +---- services/src/appspawn_service.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/services/src/appspawn_process.c b/services/src/appspawn_process.c index 277b03f..70cb0c2 100755 --- a/services/src/appspawn_process.c +++ b/services/src/appspawn_process.c @@ -150,9 +150,6 @@ pid_t CreateProcess(const MessageSt* msgSt) #endif // OHOS_DEBUG // set permissions - if (msgSt->caps == NULL) { - exit(0x7f); // 0x7f: user specified - } if (SetPerms(msgSt->uID, msgSt->gID, msgSt->capsCnt, msgSt->caps) != 0) { HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] sub-process %{public}s exit!", msgSt->bundleName); exit(0x7f); // 0x7f: user specified @@ -167,7 +164,7 @@ pid_t CreateProcess(const MessageSt* msgSt) getpid(), errno); } // 1s = 1000000000ns - long timeUsed = (tmEnd.tv_sec - tmStart.tv_sec) * (long)1000000000 + (tmEnd.tv_nsec - tmStart.tv_nsec); + long timeUsed = (tmEnd.tv_sec - tmStart.tv_sec) * 1000000000L + (tmEnd.tv_nsec - tmStart.tv_nsec); HILOG_INFO(HILOG_MODULE_HIVIEW, "[appspawn] sub-process, pid %{public}d, timeused %ld ns.",\ getpid(), timeUsed); #endif // OHOS_DEBUG diff --git a/services/src/appspawn_service.c b/services/src/appspawn_service.c index e861439..a85d24d 100755 --- a/services/src/appspawn_service.c +++ b/services/src/appspawn_service.c @@ -161,7 +161,7 @@ static int Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, Ip GetCurTime(&tmEnd); // 1s = 1000000000ns - long timeUsed = (tmEnd.tv_sec - tmStart.tv_sec) * (long)1000000000 + (tmEnd.tv_nsec - tmStart.tv_nsec); + long timeUsed = (tmEnd.tv_sec - tmStart.tv_sec) * 1000000000L + (tmEnd.tv_nsec - tmStart.tv_nsec); HILOG_INFO(HILOG_MODULE_HIVIEW, "[appspawn] invoke, reply pid %{public}d, timeused %{public}ld ns.",\ newPid, timeUsed); #else -- Gitee From 8be51bfb818f3b0a7a97c992cc187c6587969556 Mon Sep 17 00:00:00 2001 From: zhong_ning Date: Thu, 22 Jul 2021 16:39:02 +0800 Subject: [PATCH 2/3] fix code style Signed-off-by: zhong_ning --- services/src/appspawn_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/appspawn_message.c b/services/src/appspawn_message.c index 1565c52..4526329 100644 --- a/services/src/appspawn_message.c +++ b/services/src/appspawn_message.c @@ -80,7 +80,7 @@ static enum OHOSLiteErrorCode ReadStringItem(cJSON* strItem, char** buf, size_t return EC_NOMEMORY; } - if (strLength > 0 && memcpy_s(bufTmp, strLength + 1, strPtr, strLength) != EOK) { + if (strLength > 0 && memcpy_s(bufTmp, strLength, strPtr, strLength - 1) != EOK) { free(bufTmp); bufTmp = NULL; return EC_FAILURE; -- Gitee From 2e6af0ec2074968c35222a221b02230d38b197bb Mon Sep 17 00:00:00 2001 From: zhong_ning Date: Thu, 22 Jul 2021 17:10:36 +0800 Subject: [PATCH 3/3] fix code style Signed-off-by: zhong_ning --- services/src/appspawn_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/appspawn_message.c b/services/src/appspawn_message.c index 4526329..3406693 100644 --- a/services/src/appspawn_message.c +++ b/services/src/appspawn_message.c @@ -80,7 +80,7 @@ static enum OHOSLiteErrorCode ReadStringItem(cJSON* strItem, char** buf, size_t return EC_NOMEMORY; } - if (strLength > 0 && memcpy_s(bufTmp, strLength, strPtr, strLength - 1) != EOK) { + if (strLength > 0 && memcpy_s(bufTmp, strLength, strPtr, strLength) != EOK) { free(bufTmp); bufTmp = NULL; return EC_FAILURE; -- Gitee