未验证 提交 b54448d8 编写于 作者: O openharmony_ci 提交者: Gitee

!1072 修复代码静态检查(0812)

Merge pull request !1072 from cheng_jinsong/codex
......@@ -292,7 +292,7 @@ FstabItem *FindFstabItemForPath(Fstab fstab, const char *path)
return item;
}
static char *GetFstabFile(char *fileName, int size)
static char *GetFstabFile(char *fileName, size_t size)
{
if (InUpdaterMode() == 1) {
if (strncpy_s(fileName, size, "/etc/fstab.updater", strlen("/etc/fstab.updater")) != 0) {
......
......@@ -31,7 +31,7 @@ static int main_cmd(BShellHandle shell, int argc, char **argv)
CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, argv[1]);
} else if (argc == DUMP_SERVICE_BOOTEVENT_CMD_ARGS) {
printf("dump service bootevent info \n");
int serviceNameLen = strlen(argv[1]) + strlen(argv[2]) + 2; // 2 is \0 and #
size_t serviceNameLen = strlen(argv[1]) + strlen(argv[2]) + 2; // 2 is \0 and #
char *serviceBootevent = (char *)calloc(1, serviceNameLen);
BEGET_ERROR_CHECK(sprintf_s(serviceBootevent, serviceNameLen, "%s#%s", argv[1], argv[2]) >= 0,
return 0, "dumpservice arg create failed");
......
......@@ -26,7 +26,7 @@
#define BOOT_EVENT_PARA_PREFIX "bootevent."
#define BOOT_EVENT_PARA_PREFIX_LEN 10
#define BOOT_EVENT_TIMESTAMP_MAX_LEN 50
static int bootEventNum = 0;
static int g_bootEventNum = 0;
enum {
BOOTEVENT_FORK,
......@@ -116,9 +116,9 @@ static void BootEventParaFireByName(const char *paramName)
}
INIT_CHECK_ONLY_RETURN(clock_gettime(CLOCK_MONOTONIC,
&(((BOOT_EVENT_PARAM_ITEM *)found)->timestamp[BOOTEVENT_READY])) == 0);
bootEventNum--;
g_bootEventNum--;
// Check if all boot event params are fired
if (bootEventNum > 0) {
if (g_bootEventNum > 0) {
return;
}
// All parameters are fired, set boot completed now ...
......@@ -144,7 +144,7 @@ static void ServiceParseBootEventHook(SERVICE_PARSE_CTX *serviceParseCtx)
INIT_LOGI("Add service bootevent failed %s", serviceParseCtx->serviceName);
return;
}
bootEventNum++;
g_bootEventNum++;
return;
}
......@@ -157,7 +157,7 @@ static void ServiceParseBootEventHook(SERVICE_PARSE_CTX *serviceParseCtx)
INIT_LOGI("Add service bootevent failed %s", serviceParseCtx->serviceName);
continue;
}
bootEventNum++;
g_bootEventNum++;
}
}
......
......@@ -102,11 +102,11 @@ int InitAddClearServiceHook(ServiceHook hook)
return HookMgrAddEx(GetBootStageHookMgr(), &info);
}
static int CmdClear_(int id, const char *name, int argc, const char **argv)
static int CmdClear(int id, const char *name, int argc, const char **argv)
{
SERVICE_INFO_CTX ctx = {0};
ctx.reserved = argc >= 1 ? argv[0] : NULL;
PLUGIN_LOGI("CmdClear_ %s cmd: %s", name, ctx.reserved);
PLUGIN_LOGI("CmdClear %s cmd: %s", name, ctx.reserved);
InitGroupNode *node = GetNextGroupNode(NODE_TYPE_SERVICES, NULL);
while (node != NULL) {
......@@ -123,7 +123,7 @@ static int CmdClear_(int id, const char *name, int argc, const char **argv)
static int ParamSetBootEventHook(const HOOK_INFO *hookInfo, void *cookie)
{
AddCmdExecutor("clear", CmdClear_);
AddCmdExecutor("clear", CmdClear);
return 0;
}
......
......@@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef STARTUP_INIT_PARAM_HOOK_
#define STARTUP_INIT_PARAM_HOOK_
#ifndef STARTUP_INIT_PARAM_HOOK
#define STARTUP_INIT_PARAM_HOOK
#include <stdio.h>
#include <stdint.h>
......
......@@ -242,7 +242,7 @@ INIT_INNER_API int GetParamSecurityAuditData(const char *name, int type, ParamAu
}
static int CreateCtrlInfo(ServiceCtrlInfo **ctrlInfo, const char *cmd, uint32_t offset,
uint8_t ctrlParam, const char *format, ...)
uint8_t ctrlParam, const char *format, ...)
{
*ctrlInfo = calloc(1, sizeof(ServiceCtrlInfo));
PARAM_CHECK(ctrlInfo != NULL, return -1, "Failed to alloc memory %s", cmd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册