提交 fdb3703b 编写于 作者: M Mupceet

fix: codex

Signed-off-by: NMupceet <laiguizhong@huawei.com>
上级 6e018620
......@@ -117,9 +117,15 @@ static void *moduleInstall(MODULE_ITEM *module, int argc, const char *argv[])
module->moduleMgr->installArgs.argv = argv;
if (module->moduleMgr->name[0] == '/') {
snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s/%s" MODULE_SUFFIX_D, module->moduleMgr->name, module->name);
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s/%s" MODULE_SUFFIX_D,
module->moduleMgr->name, module->name) < 0) {
return NULL;
}
} else {
snprintf_s(path, sizeof(path), sizeof(path) - 1, "/system/" MODULE_LIB_NAME "/%s/%s" MODULE_SUFFIX_D, module->moduleMgr->name, module->name);
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "/system/" MODULE_LIB_NAME "/%s/%s" MODULE_SUFFIX_D,
module->moduleMgr->name, module->name) < 0) {
return NULL;
}
}
currentInstallArgs = &(module->moduleMgr->installArgs);
......@@ -239,9 +245,13 @@ MODULE_MGR *ModuleMgrScan(const char *modulePath)
}
if (modulePath[0] == '/') {
snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s", modulePath);
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s", modulePath) < 0) {
return NULL;
}
} else {
snprintf_s(path, sizeof(path), sizeof(path) - 1, "/system/" MODULE_LIB_NAME "/%s", modulePath);
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "/system/" MODULE_LIB_NAME "/%s", modulePath) < 0) {
return NULL;
};
}
scanModules(moduleMgr, path);
......
......@@ -249,7 +249,7 @@ static const char *GetOSName(void)
static const char *BuildOSFullName(void)
{
const char release[] = "Release";
char value[OS_FULL_NAME_LEN];
char value[OS_FULL_NAME_LEN] = {0};
const char *releaseType = GetOsReleaseType();
int length;
if ((releaseType == NULL) || (strncmp(releaseType, release, sizeof(release) - 1) == 0)) {
......@@ -291,7 +291,7 @@ static int GetSdkApiLevel(void)
static const char *BuildVersionId(void)
{
char value[VERSION_ID_MAX_LEN];
char value[VERSION_ID_MAX_LEN] = {0};
int len = sprintf_s(value, VERSION_ID_MAX_LEN, "%s/%s/%s/%s/%s/%s/%s/%d/%s/%s",
GetDeviceType(), GetManufacture(), GetBrand(), GetProductSeries(),
......
......@@ -463,16 +463,17 @@ static void DoMount(const struct CmdArgs *ctx)
}
}
static int DoWriteWithMultiArgs(const struct CmdArgs *ctx, int fd) {
static int DoWriteWithMultiArgs(const struct CmdArgs *ctx, int fd)
{
char buf[MAX_CMD_CONTENT_LEN];
/* Write to proc files should be done at once */
buf[0] = '\0';
strcat_s(buf, sizeof(buf), ctx->argv[1]);
INIT_ERROR_CHECK(strcat_s(buf, sizeof(buf), ctx->argv[1]) == 0, return -1, "Failed to format buf");
int idx = 2;
while (idx < ctx->argc) {
strcat_s(buf, sizeof(buf), " ");
strcat_s(buf, sizeof(buf), ctx->argv[idx]);
INIT_ERROR_CHECK(strcat_s(buf, sizeof(buf), " ") == 0, return -1, "Failed to format buf");
INIT_ERROR_CHECK(strcat_s(buf, sizeof(buf), ctx->argv[idx]) == 0, return -1, "Failed to format buf");
idx++;
}
return write(fd, buf, strlen(buf));
......@@ -493,7 +494,7 @@ static void DoWrite(const struct CmdArgs *ctx)
if (fd < 0) {
return;
}
size_t ret;
ssize_t ret;
if (ctx->argc > 2) {
ret = DoWriteWithMultiArgs(ctx, fd);
} else {
......
......@@ -67,7 +67,7 @@ static int moduleMgrCommandsInit(int stage, int prio, void *cookie)
static int loadAutorunModules(int stage, int prio, void *cookie)
{
MODULE_MGR *autorun = ModuleMgrScan("init/autorun");
INIT_LOGI("Load autorun modules return %p", autorun);
INIT_LOGV("Load autorun modules return %p", autorun);
return 0;
}
......
......@@ -324,7 +324,7 @@ static void InitPostHook(const HOOK_INFO *hookInfo)
diff -= (stat->endTime.tv_nsec - stat->startTime.tv_nsec) * 1000;
}
INIT_LOGI("Executing hook [%d:%d:%p] cost [%lld]ms, return %d.",
INIT_LOGV("Executing hook [%d:%d:%p] cost [%lld]ms, return %d.",
hookInfo->stage, hookInfo->prio, hookInfo->hook, diff, hookInfo->retVal);
}
......
......@@ -234,11 +234,11 @@ int RegisterSecurityDacOps(ParamSecurityOps *ops, int isInit)
return ret;
}
static void AddGroupUser(int uid, int gid, int mode, const char *format)
static void AddGroupUser(unsigned int uid, unsigned int gid, int mode, const char *format)
{
ParamAuditData auditData = {0};
char buffer[USER_BUFFER_LEN] = {0};
int ret = sprintf_s(buffer, sizeof(buffer) - 1, "%s.%d.%d", format, gid, uid);
int ret = sprintf_s(buffer, sizeof(buffer) - 1, "%s.%u.%u", format, gid, uid);
PARAM_CHECK(ret >= 0, return, "Failed to format name for %s.%d.%d", format, gid, uid);
auditData.name = buffer;
auditData.dacData.uid = uid;
......
......@@ -75,7 +75,7 @@ void *GetSharedMem(const char *fileName, MemHandle *handle, uint32_t spaceSize,
}
void *areaAddr = (void *)mmap(NULL, spaceSize, prot, MAP_SHARED, fd, 0);
PARAM_CHECK(areaAddr != MAP_FAILED && areaAddr != NULL, close(fd);
return NULL, "Failed to map memory error %d areaAddr %p spaceSize %d", errno, areaAddr, spaceSize);
return NULL, "Failed to map memory error %d spaceSize %d", errno, spaceSize);
close(fd);
return areaAddr;
}
......
......@@ -45,7 +45,7 @@ static int InitWorkSpace_(WorkSpace *workSpace, uint32_t spaceSize, int readOnly
PARAM_CHECK(ret == 0, return -1, "Failed to get file name %s", workSpace->fileName);
void *areaAddr = GetSharedMem(buffer, &workSpace->memHandle, spaceSize, readOnly);
PARAM_CHECK(areaAddr != NULL, return PARAM_CODE_ERROR_MAP_FILE,
"Failed to map memory error %d areaAddr %p spaceSize %d", errno, areaAddr, spaceSize);
"Failed to map memory error %d spaceSize %d", errno, spaceSize);
if (!readOnly) {
workSpace->area = (ParamTrieHeader *)areaAddr;
workSpace->area->trieNodeCount = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册