Description:Code optimization

Feature or Bugfix:Bugfix
Binary Source:No

Signed-off-by: lwx1281857 <linnanmu@h-partners.com>
This commit is contained in:
lwx1281857 2024-06-11 20:11:09 +08:00
parent 4fcd70bc00
commit 73a87503ee
4 changed files with 9 additions and 12 deletions

View File

@ -111,7 +111,8 @@ static void MountRequiredPartitions(void)
// If mount required partitions failure.
// There is no necessary to continue.
// Just abort
INIT_LOGE("[startup_failed]Mount required partitions failed; please check fstab file %d", FSTAB_MOUNT_FAILED);
INIT_LOGE("[startup_failed]Mount required partitions failed; please check fstab file %d",
FSTAB_MOUNT_FAILED);
// Execute sh for debugging
#ifndef STARTUP_INIT_TEST
execv("/bin/sh", NULL);

View File

@ -80,7 +80,7 @@ void CheckTimeoutOfTimer(EventLoop *loop, uint64_t currTime)
OH_ListAddTail(&timeoutList, &timer->node);
timer->flags |= TIMER_PROCESSING;
node = loop->timerList.next;;
node = loop->timerList.next;
}
node = timeoutList.next;
@ -146,10 +146,10 @@ LE_STATUS LE_StartTimer(const LoopHandle loopHandle,
uint64_t GetMinTimeoutPeriod(const EventLoop *loop)
{
LE_CHECK(loop != NULL , return 0, "Invalid loop");
LE_CHECK(loop != NULL, return 0, "Invalid loop");
LE_ONLY_CHECK(loop->timerList.next != &(loop->timerList), return 0);
TimerNode *timerNode = ListEntry(loop->timerList.next, TimerNode, node);
LE_CHECK(timerNode != NULL , return 0, "Invalid timeNode");
LE_CHECK(timerNode != NULL, return 0, "Invalid timeNode");
return timerNode->endTime;
}

View File

@ -150,17 +150,14 @@ static int GetSeccompPolicy(const char *filterName, int **handler,
int ret = SECCOMP_SUCCESS;
do {
int rc = snprintf_s(filterVaribleName, sizeof(filterVaribleName), \
strlen(filterName) + strlen(FILTER_NAME_FORMAT) - strlen("%s"), \
FILTER_NAME_FORMAT, filterName);
strlen(filterName) + strlen(FILTER_NAME_FORMAT) - strlen("%s"), FILTER_NAME_FORMAT, filterName);
if (rc == -1) {
return RETURN_ERROR;
}
char realPath[PATH_MAX] = { 0 };
realpath(filterLibRealPath, realPath);
policyHanlder = dlopen(realPath, RTLD_LAZY);
if (policyHanlder == NULL) {
return RETURN_NULL;
}
PLUGIN_CHECK(policyHanlder != NULL, return RETURN_ERROR, "dlopen error policyHanlder:NULL");
filter = (struct sock_filter *)dlsym(policyHanlder, filterVaribleName);
if (filter == NULL) {
@ -168,8 +165,7 @@ static int GetSeccompPolicy(const char *filterName, int **handler,
break;
}
size_t filterVaribleNameLen = strlen(filterVaribleName) + \
strlen(FILTER_SIZE_STRING) + 1;
size_t filterVaribleNameLen = strlen(filterVaribleName) + strlen(FILTER_SIZE_STRING) + 1;
if (filterVaribleNameLen > sizeof(filterVaribleName)) {
ret = RETURN_LENGTH_CHECK;
break;

View File

@ -418,7 +418,7 @@ static int ProcessParamFile(const char *fileName, void *context)
uint32_t mode = *(int *)context;
int ret = LoadDefaultParam_(fileName, mode, exclude, ARRAY_LENGTH(exclude), LoadOneParam_);
if (ret == PARAM_DEFAULT_PARAM_MEMORY_NOT_ENOUGH) {
PARAM_LOGE("[startup_failed]default_param memory is not enough, system reboot! %d",SYS_PARAM_INIT_FAILED);
PARAM_LOGE("[startup_failed]default_param memory is not enough, system reboot! %d", SYS_PARAM_INIT_FAILED);
ExecReboot("panic");
}
return ret;