init: fix codedex

Signed-off-by: sun_fan <sun_fan1@hoperun.com>
This commit is contained in:
sun_fan
2021-09-28 14:16:49 +08:00
parent 1cca6020f2
commit ebfe310e95
6 changed files with 12 additions and 9 deletions
@@ -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;
+1 -1
View File
@@ -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;
+3 -1
View File
@@ -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) {
+1 -1
View File
@@ -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;
+2 -3
View File
@@ -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);