提交 ebfe310e 编写于 作者: S sun_fan

init: fix codedex

Signed-off-by: Nsun_fan <sun_fan1@hoperun.com>
上级 1cca6020
......@@ -31,7 +31,7 @@ int32_t StartDynamicProcess(const char *name)
return -1;
}
if (SetParameter("ohos.ctl.start", name) != 0) {
HILOG_ERROR(LOG_CORE, "Set param for %{public}s failed.\n", name);
HILOG_ERROR(LOG_CORE, "Set param for {public}%s failed.\n", name);
return -1;
}
return 0;
......@@ -44,7 +44,7 @@ int32_t StopDynamicProcess(const char *name)
return -1;
}
if (SetParameter("ohos.ctl.stop", name) != 0) {
HILOG_ERROR(LOG_CORE, "Set param for %{public}s failed.\n", name);
HILOG_ERROR(LOG_CORE, "Set param for {public}%s failed.\n", name);
return -1;
}
return 0;
......
......@@ -45,7 +45,7 @@ int DoReboot(const char *option)
}
return 0;
}
int length = strlen(option);
size_t length = strlen(option);
if (length > MAX_REBOOT_OPTION_SIZE) {
INIT_LOGE("Reboot option \" %s \" is too large, overflow", option);
return -1;
......
......@@ -32,7 +32,9 @@ int main(int argc, char* argv[])
printf("%s", USAGE_INFO);
return 0;
}
if (argv[1] == NULL) {
return -1;
}
if (argc == REBOOT_CMD_NUMBER && strcmp(argv[1], "shutdown") != 0 &&
strcmp(argv[1], "updater") != 0 &&
strcmp(argv[1], "flash") != 0 &&
......
......@@ -67,7 +67,9 @@ int main(int argc, char** argv)
ServiceControlUsage();
return -1;
}
if (argv[0] == NULL) {
return -1;
}
char serviceCtl[SERVICE_CONTROL_MAX_SIZE];
if (strcmp(argv[0], "start_service") == 0) {
if (strncpy_s(serviceCtl, sizeof(serviceCtl), "ohos.ctl.start", sizeof(serviceCtl) - 1) != EOK) {
......
......@@ -83,7 +83,7 @@ void EnableDevKmsg(void)
if (fd < 0) {
return;
}
char *kmsgStatus = "on";
const char *kmsgStatus = "on";
write(fd, kmsgStatus, strlen(kmsgStatus) + 1);
close(fd);
fd = -1;
......
......@@ -230,7 +230,7 @@ static void WriteCommon(const char *file, char *buffer, int flags, mode_t mode)
size_t totalSize = strlen(buffer);
size_t written = WriteAll(fd, buffer, totalSize);
if (written != totalSize) {
INIT_LOGE("Write %lu bytes to file failed", totalSize, file);
INIT_LOGE("Write %lu bytes to file %s failed", totalSize, file);
}
close(fd);
}
......@@ -389,8 +389,6 @@ static void DoCopyInernal(const char *source, const char *target)
int srcFd = open(source, O_RDONLY | O_CLOEXEC, S_IRUSR | S_IWUSR);
if (srcFd < 0) {
INIT_LOGE("Open \" %s \" failed, err = %d", source, errno);
close(srcFd);
srcFd = -1;
return;
}
......@@ -1155,6 +1153,7 @@ static void DoMakeDevice(const char *cmdContent, int maxArg)
unsigned int major = strtoul(ctx->argv[0], NULL, DECIMAL_BASE);
unsigned int minor = strtoul(ctx->argv[1], NULL, DECIMAL_BASE);
if (major == 0 || minor == 0) {
FreeCmd(ctx);
return;
}
dev_t deviceId = makedev(major, minor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册