fix: LiteOS_A BBOX Codex整改
1、判断安全函数的返回值。 Close #I43RQU Signed-off-by: pcwlno1 <qidechun@huawei.com>
This commit is contained in:
parent
d169cad6b4
commit
6a5a0326d2
|
@ -113,10 +113,14 @@ int SaveBasicErrorInfo(const char *filePath, struct ErrorInfo *info)
|
|||
return -1;
|
||||
}
|
||||
(void)memset_s(buf, ERROR_INFO_MAX_LEN, 0, ERROR_INFO_MAX_LEN);
|
||||
(void)snprintf_s(buf, ERROR_INFO_MAX_LEN, ERROR_INFO_MAX_LEN - 1,
|
||||
ERROR_INFO_HEADER_FORMAT, info->event, info->module, info->errorDesc);
|
||||
*(buf + ERROR_INFO_MAX_LEN - 1) = '\0';
|
||||
(void)FullWriteFile(filePath, buf, strlen(buf), 0);
|
||||
if (snprintf_s(buf, ERROR_INFO_MAX_LEN, ERROR_INFO_MAX_LEN - 1,
|
||||
ERROR_INFO_HEADER_FORMAT, info->event, info->module, info->errorDesc) != -1) {
|
||||
*(buf + ERROR_INFO_MAX_LEN - 1) = '\0';
|
||||
(void)FullWriteFile(filePath, buf, strlen(buf), 0);
|
||||
} else {
|
||||
BBOX_PRINT_ERR("buf is not enough or snprintf_s failed!\n");
|
||||
}
|
||||
|
||||
(void)LOS_MemFree(m_aucSysMem1, buf);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -80,10 +80,16 @@ static void FormatErrorInfo(struct ErrorInfo *info,
|
|||
}
|
||||
|
||||
(void)memset_s(info, sizeof(*info), 0, sizeof(*info));
|
||||
(void)strncpy_s(info->event, sizeof(info->event), event, Min(strlen(event), sizeof(info->event) - 1));
|
||||
(void)strncpy_s(info->module, sizeof(info->module), module, Min(strlen(module), sizeof(info->module) - 1));
|
||||
(void)strncpy_s(info->errorDesc, sizeof(info->errorDesc), errorDesc,
|
||||
Min(strlen(errorDesc), sizeof(info->errorDesc) - 1));
|
||||
if (strncpy_s(info->event, sizeof(info->event), event, Min(strlen(event), sizeof(info->event) - 1)) != EOK) {
|
||||
BBOX_PRINT_ERR("info->event is not enough or strncpy_s failed!\n");
|
||||
}
|
||||
if (strncpy_s(info->module, sizeof(info->module), module, Min(strlen(module), sizeof(info->module) - 1)) != EOK) {
|
||||
BBOX_PRINT_ERR("info->module is not enough or strncpy_s failed!\n");
|
||||
}
|
||||
if (strncpy_s(info->errorDesc, sizeof(info->errorDesc), errorDesc,
|
||||
Min(strlen(errorDesc), sizeof(info->errorDesc) - 1)) != EOK) {
|
||||
BBOX_PRINT_ERR("info->errorDesc is not enough or strncpy_s failed!\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
|
@ -351,7 +357,11 @@ int BBoxRegisterModuleOps(struct ModuleOps *ops)
|
|||
return -1;
|
||||
}
|
||||
(void)memset_s(newOps, sizeof(*newOps), 0, sizeof(*newOps));
|
||||
(void)memcpy_s(&newOps->ops, sizeof(newOps->ops), ops, sizeof(*ops));
|
||||
if (memcpy_s(&newOps->ops, sizeof(newOps->ops), ops, sizeof(*ops)) != EOK) {
|
||||
BBOX_PRINT_ERR("newOps->ops is not enough or memcpy_s failed!\n");
|
||||
(void)LOS_MemFree(m_aucSysMem1, newOps);
|
||||
return -1;
|
||||
}
|
||||
if (LOS_SemPend(g_opsListSem, LOS_WAIT_FOREVER) != LOS_OK) {
|
||||
BBOX_PRINT_ERR("Request g_opsListSem failed!\n");
|
||||
(void)LOS_MemFree(m_aucSysMem1, newOps);
|
||||
|
|
Loading…
Reference in New Issue