!928 Fix : 内核告警清理

Merge pull request !928 from yinjiaming/fix
This commit is contained in:
openharmony_ci 2022-08-09 08:37:34 +00:00 committed by Gitee
commit ba23a26f95
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 947 additions and 1151 deletions

View File

@ -478,7 +478,6 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
uint64_t runtime; uint64_t runtime;
UINT32 intSave; UINT32 intSave;
UINT32 tid = GetTidFromClockID(clockID); UINT32 tid = GetTidFromClockID(clockID);
if (OS_TID_CHECK_INVALID(tid)) { if (OS_TID_CHECK_INVALID(tid)) {
return -EINVAL; return -EINVAL;
} }

View File

@ -343,7 +343,8 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co
return FR_OK; return FR_OK;
} }
static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp, BYTE type, const char *target) static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp,
BYTE type, const char *target)
{ {
struct Vnode *vp = NULL; struct Vnode *vp = NULL;
FATFS *fs = (FATFS *)parent->originMount->data; FATFS *fs = (FATFS *)parent->originMount->data;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -244,7 +244,8 @@ extern int chattr(const char *pathname, struct IATTR *attr);
* *
* @retval #0 On success. * @retval #0 On success.
* @retval #-1 On failure with errno set. * @retval #-1 On failure with errno set.
* @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through Nuttx vfs operation.</li> * @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through
* Nuttx vfs operation.</li>
* *
* @par Dependency: * @par Dependency:
* <ul><li>fs.h</li></ul> * <ul><li>fs.h</li></ul>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -682,7 +682,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, const ch
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER); LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_rmdir(parentInode, targetInode, (const unsigned char *)path); ret = jffs2_rmdir(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) { if (ret == 0) {
(void)jffs2_iput(targetInode); (void)jffs2_iput(targetInode);
} }
@ -809,7 +808,6 @@ int VfsJffs2Unlink(struct Vnode *parentVnode, struct Vnode *targetVnode, const c
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER); LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path); ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) { if (ret == 0) {
(void)jffs2_iput(targetInode); (void)jffs2_iput(targetInode);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -154,7 +154,8 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
VnodeHold(); VnodeHold();
LosBufPrintf(buf, "\n=================================================================\n"); LosBufPrintf(buf, "\n=================================================================\n");
LosBufPrintf(buf, "VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n"); LosBufPrintf(buf,
"VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n");
vnodeVirtual = VnodeListProcess(buf, GetVnodeVirtualList()); vnodeVirtual = VnodeListProcess(buf, GetVnodeVirtualList());
vnodeFree = VnodeListProcess(buf, GetVnodeFreeList()); vnodeFree = VnodeListProcess(buf, GetVnodeFreeList());
vnodeActive = VnodeListProcess(buf, GetVnodeActiveList()); vnodeActive = VnodeListProcess(buf, GetVnodeActiveList());

View File

@ -62,7 +62,7 @@ int OsShellCmdWriteProc(int argc, char **argv)
if (argc == WRITEPROC_ARGC) { if (argc == WRITEPROC_ARGC) {
value = argv[0]; value = argv[0];
path = argv[2]; path = argv[2]; // 2: index of path
len = strlen(value) + 1; /* + 1:add the \0 */ len = strlen(value) + 1; /* + 1:add the \0 */
if (strncmp(argv[1], ">>", strlen(">>")) == 0) { if (strncmp(argv[1], ">>", strlen(">>")) == 0) {
if ((realpath(path, realPath) == NULL) || (strncmp(realPath, rootProcDir, strlen(rootProcDir)) != 0)) { if ((realpath(path, realPath) == NULL) || (strncmp(realPath, rootProcDir, strlen(rootProcDir)) != 0)) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:

View File

@ -225,7 +225,6 @@ static char *vfs_normalize_fullpath(const char *directory, const char *filename,
/* 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;
set_errno(ENOMEM); set_errno(ENOMEM);
@ -258,8 +257,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
} }
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (directory == NULL) if (directory == NULL) {
{
spin_lock_irqsave(&curr->files->workdir_lock, lock_flags); spin_lock_irqsave(&curr->files->workdir_lock, lock_flags);
directory = curr->files->workdir; directory = curr->files->workdir;
} }
@ -275,8 +273,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) { if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) {
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE) if (dir_flags == TRUE) {
{
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags); spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
} }
#endif #endif
@ -285,8 +282,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
fullpath = vfs_normalize_fullpath(directory, filename, pathname, namelen); fullpath = vfs_normalize_fullpath(directory, filename, pathname, namelen);
#ifdef VFS_USING_WORKDIR #ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE) if (dir_flags == TRUE) {
{
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags); spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
} }
#endif #endif

View File

@ -155,7 +155,6 @@ int chdir(const char *path)
char *fullpath_bak = NULL; char *fullpath_bak = NULL;
struct stat statBuff; struct stat statBuff;
if (!path) { if (!path) {
set_errno(EFAULT); set_errno(EFAULT);
return -1; return -1;

View File

@ -57,7 +57,6 @@ int utime(const char *path, const struct utimbuf *ptimes)
/* Sanity checks */ /* Sanity checks */
if (path == NULL) { if (path == NULL) {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -239,7 +239,7 @@ BOOL VnodeInUseIter(const struct Mount *mount)
return FALSE; return FALSE;
} }
int VnodeHold() int VnodeHold(void)
{ {
int ret = LOS_MuxLock(&g_vnodeMux, LOS_WAIT_FOREVER); int ret = LOS_MuxLock(&g_vnodeMux, LOS_WAIT_FOREVER);
if (ret != LOS_OK) { if (ret != LOS_OK) {
@ -248,7 +248,7 @@ int VnodeHold()
return ret; return ret;
} }
int VnodeDrop() int VnodeDrop(void)
{ {
int ret = LOS_MuxUnlock(&g_vnodeMux); int ret = LOS_MuxUnlock(&g_vnodeMux);
if (ret != LOS_OK) { if (ret != LOS_OK) {
@ -583,7 +583,7 @@ int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode *
return 0; return 0;
} }
int VnodeDevInit() int VnodeDevInit(void)
{ {
struct Vnode *devNode = NULL; struct Vnode *devNode = NULL;
struct Mount *devMount = NULL; struct Mount *devMount = NULL;
@ -616,7 +616,7 @@ int VnodeGetattr(struct Vnode *vnode, struct stat *buf)
return LOS_OK; return LOS_OK;
} }
struct Vnode *VnodeGetRoot() struct Vnode *VnodeGetRoot(void)
{ {
return g_rootVnode; return g_rootVnode;
} }
@ -697,7 +697,7 @@ LIST_HEAD* GetVnodeActiveList()
return &g_vnodeActiveList; return &g_vnodeActiveList;
} }
int VnodeClearCache() int VnodeClearCache(void)
{ {
struct Vnode *item = NULL; struct Vnode *item = NULL;
struct Vnode *nextItem = NULL; struct Vnode *nextItem = NULL;

View File

@ -1191,7 +1191,6 @@ void lwip_arp_show_internal(struct netif *netif, char *printf_buf, unsigned int
|| (state == ETHARP_STATE_STATIC) || (state == ETHARP_STATE_STATIC)
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
) && arp_table[i].netif) { ) && arp_table[i].netif) {
if (strcmp(netif_get_name(netif), netif_get_name(arp_table[i].netif)) != 0) { if (strcmp(netif_get_name(netif), netif_get_name(arp_table[i].netif)) != 0) {
continue; continue;
} }
@ -1387,7 +1386,7 @@ u32_t lwip_arp(int argc, const char **argv)
goto arp_error; goto arp_error;
} }
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of used parameters
} else if (strcmp("-d", argv[i]) == 0 && (argc > 1)) { } else if (strcmp("-d", argv[i]) == 0 && (argc > 1)) {
/* arp delete */ /* arp delete */
arp_cmd.option = ARP_OPTION_DEL; arp_cmd.option = ARP_OPTION_DEL;
@ -1399,8 +1398,8 @@ u32_t lwip_arp(int argc, const char **argv)
} }
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of used parameters
} else if (strcmp("-s", argv[i]) == 0 && (argc > 2)) { } else if (strcmp("-s", argv[i]) == 0 && (argc > 2)) { // 2: require more than 2 parameters
/* arp add */ /* arp add */
char *digit = NULL; char *digit = NULL;
u32_t macaddrlen = strlen(argv[i + 2]) + 1; u32_t macaddrlen = strlen(argv[i + 2]) + 1;
@ -1452,7 +1451,7 @@ u32_t lwip_arp(int argc, const char **argv)
} }
i += 3; i += 3;
argc -= 3; argc -= 3; // 3: number of used parameters
} else { } else {
goto arp_error; goto arp_error;
} }
@ -1727,7 +1726,7 @@ LWIP_STATIC int osPingFunc(u32_t destip, u32_t cnt, u32_t interval, u32_t data_l
break; break;
} }
intrvl -= 1000; intrvl -= 1000;
sys_msleep(1000); sys_msleep(1000); // 1000: delay 1 s
if (ping_kill == 1) if (ping_kill == 1)
break; break;
} while (intrvl > 0); } while (intrvl > 0);
@ -1819,7 +1818,7 @@ u32_t osShellPing(int argc, const char **argv)
count = ret; count = ret;
count_set = 1; count_set = 1;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: nuber of arguments that has been checked
} else if (strcmp("-t", argv[i]) == 0) { } else if (strcmp("-t", argv[i]) == 0) {
count = 0; /* ping forerver */ count = 0; /* ping forerver */
count_set = 1; count_set = 1;
@ -1834,7 +1833,7 @@ u32_t osShellPing(int argc, const char **argv)
interval = ret; interval = ret;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2:number of arguments that has been checked
} else if (strcmp("-l", argv[i]) == 0 && (argc > 1)) { } else if (strcmp("-l", argv[i]) == 0 && (argc > 1)) {
ret = atoi(argv[i + 1]); ret = atoi(argv[i + 1]);
if (ret < 0 || ret > (int)(LWIP_MAX_UDP_RAW_SEND_SIZE - sizeof(struct icmp_echo_hdr))) { if (ret < 0 || ret > (int)(LWIP_MAX_UDP_RAW_SEND_SIZE - sizeof(struct icmp_echo_hdr))) {
@ -1844,7 +1843,7 @@ u32_t osShellPing(int argc, const char **argv)
} }
data_len = ret; data_len = ret;
i += 2; i += 2;
argc -= 2; argc -= 2; // 2: number of elements has been checked
} else if (strcmp("-k", argv[i]) == 0) { } else if (strcmp("-k", argv[i]) == 0) {
if (ping_taskid > 0) { if (ping_taskid > 0) {
ping_kill = 1; /* stop the current ping task */ ping_kill = 1; /* stop the current ping task */
@ -1896,7 +1895,7 @@ u32_t osShellPing(int argc, const char **argv)
stPingTask.auwArgs[0] = dst_ipaddr.addr; /* network order */ stPingTask.auwArgs[0] = dst_ipaddr.addr; /* network order */
stPingTask.auwArgs[1] = count; stPingTask.auwArgs[1] = count;
stPingTask.auwArgs[2] = interval; stPingTask.auwArgs[2] = interval;
stPingTask.auwArgs[3] = data_len; stPingTask.auwArgs[3] = data_len; // 3: index of data length
ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask); ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask);
if (ret != LOS_OK) { if (ret != LOS_OK) {
PRINTK("ping_task create failed 0x%08x.\n", ret); PRINTK("ping_task create failed 0x%08x.\n", ret);
@ -2311,6 +2310,7 @@ REDUCE_SELECT_TIME:
PRINTK("--- %s ping statistics ---\n", argv[ping6_params.host_index]); PRINTK("--- %s ping statistics ---\n", argv[ping6_params.host_index]);
PRINTK("%d packets transmitted, %d received, %.2f%% packet loss, time %dms\n", PRINTK("%d packets transmitted, %d received, %.2f%% packet loss, time %dms\n",
nsent, nrecieve, (float)(((float)(nsent - nrecieve)) * ((float)(100)) / ((float)(nsent))), nsent, nrecieve, (float)(((float)(nsent - nrecieve)) * ((float)(100)) / ((float)(nsent))),
/* 1000: convert seconds to milliseconds, 1000000: convert nanoseconds to milliseconds */
((last.tv_sec - first.tv_sec) * 1000 + (last.tv_nsec - first.tv_nsec) / 1000000)); ((last.tv_sec - first.tv_sec) * 1000 + (last.tv_nsec - first.tv_nsec) / 1000000));
if (nrecieve) { if (nrecieve) {
/* Display rtt stats only if at least one packet is received */ /* Display rtt stats only if at least one packet is received */
@ -2866,7 +2866,7 @@ int netstat_tcp_recvq(struct tcp_pcb *tpcb)
case NETCONN_UDP_IPV6: case NETCONN_UDP_IPV6:
#endif #endif
case NETCONN_UDP: case NETCONN_UDP:
SYS_ARCH_GET(((unsigned int)conn->recv_avail /*+ conn->lrcv_left*/), retVal); SYS_ARCH_GET(((unsigned int)conn->recv_avail), retVal); // + conn->lrcv_left
break; break;
default: default:
retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */ retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */
@ -2992,7 +2992,7 @@ int netstat_netconn_recvq(const struct netconn *conn)
case NETCONN_PKT_RAW: case NETCONN_PKT_RAW:
#endif #endif
case NETCONN_UDP: case NETCONN_UDP:
SYS_ARCH_GET(((unsigned int)conn->recv_avail /*+ conn->lrcv_left*/), retVal); SYS_ARCH_GET(((unsigned int)conn->recv_avail), retVal); // + conn->lrcv_left
break; break;
default: default:
retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */ retVal = 0; /* ur... very ugly, damn DHCP DNS and SNTP */
@ -3274,7 +3274,7 @@ void netstat_internal(void *ctx)
proto = rpcb->protocol; // raw_proto; proto = rpcb->protocol; // raw_proto;
iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1, iRet = snprintf_s((char *)(entry_buf + entry_buf_offset), entry_buf_len, entry_buf_len - 1,
"%-8s%-12d%-12d%-20s%-20s%-16u%-16d\n", "%-8s%-12d%-12d%-20s%-20s%-16u%-16d\n",
"raw", recvQlen, sendQlen, local_ip_port, remote_ip_port, proto, /*rpcb->hdrincl*/0); "raw", recvQlen, sendQlen, local_ip_port, remote_ip_port, proto, 0); // rpcb->hdrincl
if ((iRet <= 0) || ((u32_t)(iRet) >= entry_buf_len)) { if ((iRet <= 0) || ((u32_t)(iRet) >= entry_buf_len)) {
goto out; goto out;
} }
@ -3297,7 +3297,8 @@ void netstat_internal(void *ctx)
sendQlen = netstat_netconn_sendq(rpcb->recv_arg); sendQlen = netstat_netconn_sendq(rpcb->recv_arg);
for (netif = netif_list; netif != NULL; netif = netif->next) { for (netif = netif_list; netif != NULL; netif = netif->next) {
if (netif_get_index(netif)/*netif->ifindex*/ == rpcb->netif_idx/*index*/) { /* netif->ifindex and index */
if (netif_get_index(netif) == rpcb->netif_idx) {
(void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", netif_get_name(netif)); (void)snprintf_s((char *)netif_name, IFNAMSIZ, IFNAMSIZ - 1, "%s", netif_get_name(netif));
break; break;
} }

View File

@ -803,12 +803,10 @@ static u8_t lwip_ioctl_internal_SIOCSIFHWADDR(struct ifreq *ifr)
} }
#endif #endif
else { else {
/* bring netif down to clear all Neighbor Cache Entry */ /* bring netif down to clear all Neighbor Cache Entry */
(void)netif_set_down(netif); (void)netif_set_down(netif);
ret = netif_set_hwaddr(netif, (const unsigned char *)ifr->ifr_hwaddr.sa_data, netif->hwaddr_len); ret = netif_set_hwaddr(netif, (const unsigned char *)ifr->ifr_hwaddr.sa_data, netif->hwaddr_len);
if (ret != ERR_OK) { if (ret != ERR_OK) {
(void)netif_set_up(netif); (void)netif_set_up(netif);
return err_to_errno(ret); return err_to_errno(ret);
@ -979,7 +977,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFFLAGS(struct ifreq *ifr)
#endif /* LWIP_IGMP || LWIP_IPV6_MLD */ #endif /* LWIP_IGMP || LWIP_IPV6_MLD */
#if LWIP_DHCP #if LWIP_DHCP
//if ((netif->flags & NETIF_FLAG_DHCP) != 0) {
if (dhcp_supplied_address(netif)) { if (dhcp_supplied_address(netif)) {
ifr->ifr_flags = (short)((unsigned short)ifr->ifr_flags | IFF_DYNAMIC); ifr->ifr_flags = (short)((unsigned short)ifr->ifr_flags | IFF_DYNAMIC);
} else { } else {
@ -1090,7 +1087,6 @@ static u8_t lwip_ioctl_internal_SIOCSIFNAME(struct ifreq *ifr)
#endif #endif
netif = netif_find(ifr->ifr_name); netif = netif_find(ifr->ifr_name);
if (netif == NULL) { if (netif == NULL) {
return ENODEV; return ENODEV;
} else if (netif->link_layer_type == LOOPBACK_IF) { } else if (netif->link_layer_type == LOOPBACK_IF) {
@ -1165,7 +1161,6 @@ static u8_t lwip_ioctl_internal_SIOCGIFMTU(struct ifreq *ifr)
/* get netif hw addr */ /* get netif hw addr */
netif = netif_find(ifr->ifr_name); netif = netif_find(ifr->ifr_name);
if (netif == NULL) { if (netif == NULL) {
return ENODEV; return ENODEV;
} else { } else {