提交 5a5bad86 编写于 作者: S sun_fan

init: fix bugs

Signed-off-by: Nsun_fan <sun_fan1@hoperun.com>
上级 5b5de9f7
......@@ -95,6 +95,7 @@ int GetParamValue(const char *symValue, char *paramValue, unsigned int paramLen)
return -1;
}
INIT_CHECK_RETURN_VALUE(strncpy_s(tmpName, MAX_PARAM_NAME_LEN, p, tmpLen) == EOK, -1);
tmpLen = MAX_PARAM_VALUE_LEN;
int ret = SystemReadParam(tmpName, tmpValue, &tmpLen); // get param
if (ret != 0) {
INIT_LOGE("Failed to read parameter \" %s \"", tmpName);
......@@ -429,7 +430,6 @@ static void DoCopy(const char *cmdContent, int maxArg)
struct CmdArgs *ctx = GetCmd(cmdContent, " ", maxArg);
if (ctx == NULL || ctx->argv == NULL || ctx->argc != DEFAULT_COPY_ARGS_CNT) {
INIT_LOGE("Command copy with invalid arguments");
FreeCmd(ctx);
return;
}
char srcPath[PATH_MAX] = {0};
......
......@@ -50,7 +50,7 @@ static int CreateSocket(struct ServiceSocket *sockopt)
sockopt->name) < 0) {
return -1;
}
if (access(addr.sun_path, F_OK)) {
if (access(addr.sun_path, F_OK) == 0) {
INIT_LOGE("%s already exist, remove it", addr.sun_path);
if (unlink(addr.sun_path) != 0) {
INIT_LOGE("ulink fail err %d ", errno);
......
......@@ -119,7 +119,7 @@ static void HandleUevent(const struct Uevent *uevent)
static void AddUevent(struct Uevent *uevent, const char *event, size_t len)
{
if (uevent == NULL || uevent == NULL || len == 0) {
if (uevent == NULL || event == NULL || len == 0) {
return;
}
......
......@@ -207,6 +207,7 @@ static int ParseSysfsConfig(char *p)
config->uid = (uid_t)StringToInt(items[SYS_CONFIG_UID_NUM], 0);
config->gid = (gid_t)StringToInt(items[SYS_CONFIG_GID_NUM], 0);
ListAddTail(&g_sysDevices, &config->list);
FreeConfigItems(items, count);
return 0;
}
......@@ -216,11 +217,6 @@ static int ParseFirmwareConfig(char *p)
if (INVALIDSTRING(p)) {
INIT_LOGE("Invalid argument");
}
struct FirmwareUdevConf *config = calloc(1, sizeof(struct FirmwareUdevConf));
if (config == NULL) {
errno = ENOMEM;
return -1;
}
// Sanity checks
struct stat st = {};
......@@ -234,6 +230,12 @@ static int ParseFirmwareConfig(char *p)
return -1;
}
struct FirmwareUdevConf *config = calloc(1, sizeof(struct FirmwareUdevConf));
if (config == NULL) {
errno = ENOMEM;
return -1;
}
config->fmPath = strdup(p);
ListAddTail(&g_firmwares, &config->list);
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册