fix: M核代码告警清零

【背景】定期M核代码告警清零。

【修改方案】
根据工具扫描结果,对代码告警进行更改。

【影响】
对现有的产品编译不会有影响。

re #I4386N
Signed-off-by: wangchen <253227059@qq.com>
This commit is contained in:
wangchen 2021-07-30 18:34:08 +08:00
parent 3b37750f37
commit cb5f862eaf
11 changed files with 27 additions and 35 deletions

View File

@ -331,7 +331,7 @@ ssize_t read(int fd, void *buf, size_t nbyte)
errno = EINVAL; errno = EINVAL;
return FS_FAILURE; return FS_FAILURE;
} }
if (nbyte > 1024) { if (nbyte > 1024) { /* 1024, max random_size */
nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */ nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
} }
struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte}; struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};

View File

@ -41,7 +41,7 @@ struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0};
static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0}; static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0};
struct dirent g_nameValue; struct dirent g_nameValue;
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a","/b","/c"}; static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a", "/b", "/c"};
LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd) LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
{ {

View File

@ -242,7 +242,7 @@ static void getifaddrs_internal(struct getifaddrs_arg *arg)
if_storage = new_ifaddrs_storage(); if_storage = new_ifaddrs_storage();
if (if_storage == NULL) { if (if_storage == NULL) {
lwip_freeifaddrs( lwip_freeifaddrs(
*(arg->ifap)); /* ifap is assigned to NULL in getifaddrs, so garbage value will not be there */ *(arg->ifap)); /* ifap is assigned to NULL in getifaddrs, so garbage value will not be there */
arg->ret = ENOMEM; arg->ret = ENOMEM;
goto RETURN; goto RETURN;
} }

View File

@ -102,10 +102,10 @@ int print_netif(struct netif *netif, char *print_buf, unsigned int buf_len)
if (buf_len < 1) { if (buf_len < 1) {
goto out; goto out;
} }
if(netif->link_layer_type == LOOPBACK_IF){ if (netif->link_layer_type == LOOPBACK_IF) {
ret = snprintf_s(tmp, buf_len, (buf_len-1), "%s\t", netif->name); ret = snprintf_s(tmp, buf_len, (buf_len - 1), "%s\t", netif->name);
} else { } else {
ret = snprintf_s(tmp, buf_len, (buf_len-1), "%s%u\t", netif->name, netif->num); ret = snprintf_s(tmp, buf_len, (buf_len - 1), "%s%u\t", netif->name, netif->num);
} }
if ((ret <= 0) || ((unsigned int)ret >= buf_len)) if ((ret <= 0) || ((unsigned int)ret >= buf_len))
@ -329,11 +329,11 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
u32_t iecho_len; u32_t iecho_len;
s16_t ip_hlen; s16_t ip_hlen;
u32_t forever; u32_t forever;
u32_t i = 0; u32_t i;
u32_t succ_cnt = 0; u32_t succ_cnt = 0;
u32_t failed_cnt = 0; u32_t failed_cnt = 0;
struct timespec start, end; struct timespec start, end;
long timout_ms = 0; long timout_ms;
struct pollfd pfd; struct pollfd pfd;
long rtt; long rtt;
int ret = 0; int ret = 0;

View File

@ -190,7 +190,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCmdAscendingInsert(CmdItemNode *cmd)
} }
for (cmdItem = LOS_DL_LIST_ENTRY((&cmdInfo.cmdList.list)->pstPrev, CmdItemNode, list); for (cmdItem = LOS_DL_LIST_ENTRY((&cmdInfo.cmdList.list)->pstPrev, CmdItemNode, list);
&cmdItem->list != &(cmdInfo.cmdList.list);) { &cmdItem->list != &(cmdInfo.cmdList.list); ) {
cmdNext = LOS_DL_LIST_ENTRY(cmdItem->list.pstPrev, CmdItemNode, list); cmdNext = LOS_DL_LIST_ENTRY(cmdItem->list.pstPrev, CmdItemNode, list);
if (&cmdNext->list != &(cmdInfo.cmdList.list)) { if (&cmdNext->list != &(cmdInfo.cmdList.list)) {
if ((strncmp(cmdItem->cmd->cmdKey, cmd->cmd->cmdKey, strlen(cmd->cmd->cmdKey)) >= 0) && if ((strncmp(cmdItem->cmd->cmdKey, cmd->cmd->cmdKey, strlen(cmd->cmd->cmdKey)) >= 0) &&

View File

@ -78,7 +78,7 @@ char *GetCmdName(const char *cmdline, unsigned int len)
/* Scan the 'cmdline' string for command */ /* Scan the 'cmdline' string for command */
/* Notice: Command string must not have any special name */ /* Notice: Command string must not have any special name */
for (tmpStr = cmdline, loop = 0; (*tmpStr != '\0') && (loop < len);) { for (tmpStr = cmdline, loop = 0; (*tmpStr != '\0') && (loop < len); ) {
/* If reach a double quotes, switch the quotes matching status */ /* If reach a double quotes, switch the quotes matching status */
if (*tmpStr == '\"') { if (*tmpStr == '\"') {
SWITCH_QUOTES_STATUS(quotes); SWITCH_QUOTES_STATUS(quotes);
@ -114,12 +114,10 @@ int ShellCmdExec(const char *msgName, const char *cmdString)
} }
uintRet = ShellMsgTypeGet(&cmdParsed, msgName); uintRet = ShellMsgTypeGet(&cmdParsed, msgName);
if (uintRet != LOS_OK) { if (uintRet != LOS_OK) {
PRINTK("%s:command not found\n", msgName); PRINTK("%s:command not found\n", msgName);
return -EFAULT; return -EFAULT;
} else { } else {
(void)OsCmdExec(&cmdParsed, (char *)cmdString); (void)OsCmdExec(&cmdParsed, (char *)cmdString);
} }
return 0; return 0;

View File

@ -88,11 +88,11 @@ static char *StrNormalizePath(char *fullpath)
while (*src != '\0') { while (*src != '\0') {
if (*src == '.') { if (*src == '.') {
if (*(src + 1) == '/') { if (*(src + 1) == '/') {
src += 2; src += 2; /* 2, sizeof "./" */
continue; continue;
} else if (*(src + 1) == '.') { } else if (*(src + 1) == '.') {
if ((*(src + 2) == '/') || (*(src + 2) == '\0')) { if ((*(src + 2) == '/') || (*(src + 2) == '\0')) { /* 2, 2, offset to check */
src += 2; src += 2; /* 2, sizeof offset */
} else { } else {
while ((*src != '\0') && (*src != '/')) { while ((*src != '\0') && (*src != '/')) {
*dest++ = *src++; *dest++ = *src++;
@ -174,7 +174,7 @@ static char *VfsNotAbsolutePath(const char *directory, const char *filename, cha
/* 2: The position of the path character: / and the end character /0 */ /* 2: The position of the path character: / and the end character /0 */
if ((namelen > 1) && (filename[0] == '.') && (filename[1] == '/')) { if ((namelen > 1) && (filename[0] == '.') && (filename[1] == '/')) {
filename += 2; filename += 2; /* 2, sizeof "./" */
} }
fullpath = (char *)malloc(strlen(directory) + namelen + 2); fullpath = (char *)malloc(strlen(directory) + namelen + 2);
@ -184,8 +184,7 @@ static char *VfsNotAbsolutePath(const char *directory, const char *filename, cha
return (char *)NULL; return (char *)NULL;
} }
/* join path and file name */ /* 2, sizeof "./", join path and file name */
ret = snprintf_s(fullpath, strlen(directory) + namelen + 2, strlen(directory) + namelen + 1, ret = snprintf_s(fullpath, strlen(directory) + namelen + 2, strlen(directory) + namelen + 1,
"%s/%s", directory, filename); "%s/%s", directory, filename);
if (ret < 0) { if (ret < 0) {
@ -213,7 +212,6 @@ static char *VfsNormalizeFullpath(const char *directory, const char *filename, c
/* it's a absolute path, use it directly */ /* it's a absolute path, use it directly */
fullpath = strdup(filename); /* copy string */ fullpath = strdup(filename); /* copy string */
if (fullpath == NULL) { if (fullpath == NULL) {
*pathname = NULL; *pathname = NULL;
SetErrno(ENOMEM); SetErrno(ENOMEM);
@ -246,8 +244,7 @@ int VfsNormalizePath(const char *directory, const char *filename, char **pathnam
return -EINVAL; return -EINVAL;
} }
/* 2: The position of the path character: / and the end character /0 */ /* 2, The position of the path character: / and the end character /0 */
if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) { if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) {
return -ENAMETOOLONG; return -ENAMETOOLONG;
} }

View File

@ -50,10 +50,10 @@ extern "C" {
* @version 1.0 * @version 1.0
*/ */
typedef enum { typedef enum {
/** The timer is not allowed to wake up the RTOS. */ /** The timer is not allowed to wake up the RTOS. */
osTimerRousesIgnore = 0, osTimerRousesIgnore = 0,
/** The timer is allowed to wake up the RTOS. */ /** The timer is allowed to wake up the RTOS. */
osTimerRousesAllow = 1 osTimerRousesAllow = 1
} osTimerRouses_t; } osTimerRouses_t;
/** /**
@ -61,10 +61,10 @@ typedef enum {
* *
*/ */
typedef enum { typedef enum {
/** The timer ignores alignment. */ /** The timer ignores alignment. */
osTimerAlignIgnore = 0, osTimerAlignIgnore = 0,
/** The timer allows alignment. */ /** The timer allows alignment. */
osTimerAlignAllow = 1 osTimerAlignAllow = 1
} osTimerAlign_t; } osTimerAlign_t;
osTimerId_t osTimerExtNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr, osTimerId_t osTimerExtNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr,

View File

@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif

View File

@ -29,7 +29,6 @@
extern VOID HalHwiInit(VOID); extern VOID HalHwiInit(VOID);
#define INITIAL_MSTATUS ( MSTATUS_MPP | MSTATUS_MPIE | MSTATUS_FS_INITIAL) #define INITIAL_MSTATUS ( MSTATUS_MPP | MSTATUS_MPIE | MSTATUS_FS_INITIAL)
#define ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) #define ALIGN_DOWN(size, align) ((size) & ~((align) - 1))
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -71,13 +71,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
HWI_PROC_FUNC handler, HWI_PROC_FUNC handler,
HWI_ARG_T arg) HWI_ARG_T arg)
{ {
if (hwiNum > SOC_INT_MAX){ if (hwiNum > SOC_INT_MAX) {
return OS_ERRNO_HWI_NUM_INVALID; return OS_ERRNO_HWI_NUM_INVALID;
} }
if (mode > ECLIC_VECTOR_INTERRUPT){ if (mode > ECLIC_VECTOR_INTERRUPT) {
return OS_ERRNO_HWI_MODE_INVALID; return OS_ERRNO_HWI_MODE_INVALID;
} }
if (arg > ECLIC_NEGTIVE_EDGE_TRIGGER){ if (arg > ECLIC_NEGTIVE_EDGE_TRIGGER) {
return OS_ERRNO_HWI_ARG_INVALID; return OS_ERRNO_HWI_ARG_INVALID;
} }