init代码Review告警修改

Signed-off-by: 陈其文 <chenqiwen6@huawei.com>
This commit is contained in:
陈其文 2024-11-18 18:11:02 +08:00
parent b3e5a5895a
commit d14864d3bc
12 changed files with 19 additions and 15 deletions

View File

@ -47,7 +47,7 @@ static int DoRebootByInitPlugin(const char *mode, const char *option)
ret = snprintf_s(value, MAX_REBOOT_OPTION_SIZE, MAX_REBOOT_OPTION_SIZE - 1, "%s", "reboot");
}
}
BEGET_ERROR_CHECK(ret >= 0, return -1, "Failed to format boot mode ");
BEGET_ERROR_CHECK(ret >= 0, return -1, "Failed to format boot mode");
BEGET_LOGI("Reboot cmd %s", value);
ret = SystemSetParameter(STARTUP_DEVICE_CTL, DEVICE_CMD_STOP);
BEGET_ERROR_CHECK(ret == 0, return -1, "Failed to set stop param");

View File

@ -30,7 +30,7 @@ static int UidVerify(void)
uid = getuid();
if (uid >= KIT_FRAMEWORK_UID_MAX) {
HILOG_ERROR(HILOG_MODULE_HIVIEW, "uid verify failed, get uid:%d", uid);
HILOG_ERROR(HILOG_MODULE_HIVIEW, "uid verify failed, get uid:%u", uid);
return EC_FAILURE;
}

View File

@ -268,6 +268,7 @@ static void ProcessModuleMgrControlFd(uint16_t type, const char *serviceCmd)
void ProcessControlFd(uint16_t type, const char *serviceCmd, const void *context)
{
if ((type >= ACTION_MAX) || (serviceCmd == NULL)) {
INIT_LOGE("Invalid parameter:%s", serviceCmd == NULL ? "serviceCmd" : "type");
return;
}
switch (type) {

View File

@ -25,7 +25,7 @@ void ExecReboot(const char *value)
#ifndef STARTUP_INIT_TEST
// install module
ModuleMgrScan("init/reboot");
if (strstr(value, "reboot") != NULL) {
if ((value != NULL) && (strstr(value, "reboot") != NULL)) {
PluginExecCmdByName("reboot", value);
} else {
PluginExecCmdByName(value, value);

View File

@ -246,7 +246,8 @@ int listenSocket(int fd, int flags, const char *server)
LE_CHECK(ret >= 0, close(fd);
return ret, "Failed to listen socket error: %d", errno);
ret = chmod(server, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
LE_CHECK(ret == 0, return -1, "Failed to chmod %s, err %d. ", server, errno);
LE_CHECK(ret == 0, close(fd);
return -1, "Failed to chmod %s, err %d. ", server, errno);
}
return 0;
}

View File

@ -684,5 +684,6 @@ void CachedParameterDestroy(CachedHandle handle)
{
if (handle != NULL) {
free(handle);
handle = NULL;
}
}

View File

@ -105,7 +105,10 @@ void ParamTimerClose(ParamTaskPtr timer)
{
PARAM_CHECK(timer != NULL, return, "Invalid timer");
ParamTimer *paramTimer = (ParamTimer *)timer;
timer_delete(paramTimer->timerId);
int32_t ret = timer_delete(paramTimer->timerId);
if (ret < 0) {
PARAM_LOGE("Failed to delete timer, errno:%d", errno);
}
free(paramTimer);
}

View File

@ -22,7 +22,6 @@
#include "system_ability_definition.h"
#include "watcher_utils.h"
#include "parameter.h"
#include "init_param.h"
namespace OHOS {
namespace init_param {

View File

@ -178,12 +178,12 @@ int WatcherManager::SendMessage(WatcherGroupPtr group, int type)
}
void WatcherGroup::ProcessParameterChange(
WatcherManager *mananger, const std::string &name, const std::string &value)
WatcherManager *manager, const std::string &name, const std::string &value)
{
WATCHER_LOGV("ProcessParameterChange key '%s' '%s'", GetKeyPrefix().c_str(), name.c_str());
// walk watcher
TraversalNode([this, mananger, name, value](ParamWatcherListPtr list, WatcherNodePtr node, uint32_t index) {
auto remoteWatcher = mananger->GetRemoteWatcher(node->GetNodeId());
TraversalNode([this, manager, name, value](ParamWatcherListPtr list, WatcherNodePtr node, uint32_t index) {
auto remoteWatcher = manager->GetRemoteWatcher(node->GetNodeId());
if (remoteWatcher == nullptr) {
return;
}

View File

@ -41,12 +41,11 @@
#define DT_DIR 4
#endif
#define THOUSAND_UNIT_INT 1000
#define THOUSAND_UNIT_FLOAT 1000.0
float ConvertMicrosecondToSecond(int x)
{
return ((x / THOUSAND_UNIT_INT) / THOUSAND_UNIT_FLOAT);
return ((x / THOUSAND_UNIT_FLOAT) / THOUSAND_UNIT_FLOAT);
}
#ifndef __LITEOS_M__

View File

@ -47,7 +47,7 @@ static DeviceParameterCtrl g_parameterCtrl = {
.threadId = 0
};
static struct DeviceUdevConf *GetFristParameter(DeviceParameterCtrl *parameterCtrl)
static struct DeviceUdevConf *GetFirstParameter(DeviceParameterCtrl *parameterCtrl)
{
struct DeviceUdevConf *conf = NULL;
pthread_mutex_lock(&(parameterCtrl->parameterLock));
@ -81,7 +81,7 @@ static void *ThreadRun(void *data)
break;
}
pthread_mutex_unlock(&(parameterCtrl->lock));
struct DeviceUdevConf *config = GetFristParameter(parameterCtrl);
struct DeviceUdevConf *config = GetFirstParameter(parameterCtrl);
if (config == NULL) {
parameterCtrl->empty = 1;
continue;
@ -109,7 +109,8 @@ static void AddParameter(DeviceParameterCtrl *parameterCtrl, struct DeviceUdevCo
}
pthread_mutex_unlock(&(parameterCtrl->parameterLock));
if (parameterCtrl->threadId == 0) {
(void)pthread_create(&(parameterCtrl->threadId), NULL, ThreadRun, (void *)parameterCtrl);
int ret = pthread_create(&(parameterCtrl->threadId), NULL, ThreadRun, (void *)parameterCtrl);
INIT_ERROR_CHECK(ret == 0, return, "[uevent] pthread_create failed, ret:%d", ret);
}
pthread_mutex_lock(&(parameterCtrl->lock));
parameterCtrl->empty = 0;

View File

@ -22,7 +22,6 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <fcntl.h>
#include <unistd.h>
#include "ueventd_device_handler.h"