Compare commits

..

6 Commits

Author SHA1 Message Date
openharmony_ci
bf19a69b3c !981 非安全函数整改-合入monthly
Merge pull request !981 from xuxinyu/cherry-pick-1661483487
2022-08-27 09:14:35 +00:00
xuxinyu
ddb8c8f2ca fixed e0b4fcb from https://gitee.com/xuiny/kernel_liteos_a/pulls/971
test: replace unsecure function with secure function

Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ie120ffa529798f0f087ddfcd34f5d9c5802b6766
2022-08-26 03:11:31 +00:00
openharmony_ci
f86ead69d2 !980 style: shell脚本中不同函数使用不同变量
Merge pull request !980 from Hongjin Li/cherry-pick-1661394099
2022-08-25 10:48:34 +00:00
Hongjin Li
fc761badd0 fixed 69f3bf3 from https://gitee.com/hongjin-li/kernel_liteos_a/pulls/979
style: using different variable in different functions

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I814dcccefcd6248ea32cae94bfde567f3077c7cd
2022-08-25 02:21:39 +00:00
openharmony_ci
38a9313a1b !970 style: 编译构建告警优化-合入monthly0816
Merge pull request !970 from Hongjin Li/cherry-pick-1661258027
2022-08-24 03:35:49 +00:00
Hongjin Li
7fc770192d fixed 660b314 from https://gitee.com/hongjin-li/kernel_liteos_a/pulls/969
style: string format in python

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: Ie84a97ca5e0250991aa774b737eb7787e27d80af
2022-08-23 12:33:48 +00:00
234 changed files with 782 additions and 786 deletions

View File

@@ -180,8 +180,7 @@ static void LmsStrcpyTest(void)
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb";
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n",
(int)strlen(testStr) + 1);
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
strcpy(buf, testStr);
free(buf);
printf("\n-------- LmsStrcpyTest End --------\n");

View File

@@ -62,7 +62,7 @@ int main(int argc, char **argv)
PerfStop(fd);
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
if (size == 0) {
if (size <= 0) {
goto EXIT:
}

View File

@@ -49,7 +49,7 @@ ShellCB *OsGetShellCb()
return g_shellCB;
}
static void ShellDeinit(ShellCB *shellCB)
void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@@ -65,23 +65,27 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
return ret;
goto OUT;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@@ -144,7 +148,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
return SH_NOK;
goto ERR_OUT1;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@@ -172,9 +176,7 @@ int main(int argc, char **argv)
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
goto ERR_OUT3;
}
ShellEntry(shellCB);

View File

@@ -1437,8 +1437,10 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
{
s32_t iSockNum = TFTP_NULL_INT32;
u32_t ulSrcStrLen;
u32_t lDestStrLen;
u32_t ulSize;
u32_t ulRecvSize = TFTP_NULL_UINT32;
s32_t iErrCode;
u32_t ulErrCode;
u16_t usReadReq;
u16_t usTempServPort;

View File

@@ -70,7 +70,7 @@ static void TraceRead(int fd, size_t size)
{
ssize_t i;
ssize_t len;
if (size == 0) {
if (size <= 0) {
return;
}

View File

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

View File

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

View File

@@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
ret = VnodeLookup(diskName, &blkDriver, 0);
if (ret < 0) {
VnodeDrop();
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
ret = ENOENT;
goto DISK_FIND_ERROR;
}
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -1409,7 +1409,7 @@ DWORD fattime_format(time_t time)
ftime |= ((DWORD)((st.tm_year > YEAR_OFFSET) ? (st.tm_year - YEAR_OFFSET) : 0)) << FTIME_YEAR_OFFSET;
ftime <<= FTIME_DATE_OFFSET;
ftime |= (DWORD)st.tm_sec / SEC_MULTIPLIER;
ftime = (DWORD)st.tm_sec / SEC_MULTIPLIER;
ftime |= ((DWORD)st.tm_min) << FTIME_MIN_OFFSET;
ftime |= ((DWORD)st.tm_hour) << FTIME_HR_OFFSET;
@@ -2167,7 +2167,7 @@ int fatfs_symlink(struct Vnode *parentVnode, struct Vnode **newVnode, const char
ssize_t fatfs_readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
{
int ret;
FRESULT res;
FRESULT res = FR_OK;
DWORD clust;
QWORD sect;
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);

View File

@@ -2311,7 +2311,7 @@ diff -Nupr old/fs/jffs2/erase.c new/fs/jffs2/erase.c
diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
--- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800
+++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800
@@ -9,335 +9,30 @@
@@ -9,325 +9,34 @@
* For licensing information, see the file 'LICENCE' in this directory.
*
*/
@@ -2336,35 +2336,32 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata);
-static int jffs2_readpage (struct file *filp, struct page *pg);
-
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
-{
- struct inode *inode = filp->f_mapping->host;
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- int ret;
-
- ret = file_write_and_wait_range(filp, start, end);
- if (ret)
- return ret;
- inode_lock(inode);
- /* Trigger GC to flush any pending writes for this inode */
- jffs2_flush_wbuf_gc(c, inode->i_ino);
- inode_unlock(inode);
+static unsigned char gc_buffer[PAGE_SIZE]; //avoids malloc when user may be under memory pressure
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
- return 0;
-}
-const struct file_operations jffs2_file_operations =
+unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
+ struct jffs2_inode_info *f,
+ unsigned long offset,
+ unsigned long *priv)
{
- struct inode *inode = filp->f_mapping->host;
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+ /* FIXME: This works only with one file system mounted at a time */
int ret;
-
- ret = file_write_and_wait_range(filp, start, end);
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
if (ret)
- return ret;
-
- inode_lock(inode);
- /* Trigger GC to flush any pending writes for this inode */
- jffs2_flush_wbuf_gc(c, inode->i_ino);
- inode_unlock(inode);
-
- return 0;
-}
-
-const struct file_operations jffs2_file_operations =
-{
- .llseek = generic_file_llseek,
- .open = generic_file_open,
- .read_iter = generic_file_read_iter,
@@ -2398,8 +2395,9 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- unsigned char *pg_buf;
- int ret;
-
+ /* FIXME: This works only with one file system mounted at a time */
int ret;
- jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
- __func__, inode->i_ino, pg->index << PAGE_SHIFT);
-
@@ -2438,15 +2436,18 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
-{
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
- int ret;
-
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
+ if (ret)
+ return ERR_PTR(ret);
- mutex_lock(&f->sem);
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
- mutex_unlock(&f->sem);
- return ret;
+ return ERR_PTR(ret);
+ return gc_buffer;
}
-
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata)
@@ -2457,15 +2458,20 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- struct page *pg;
- struct inode *inode = mapping->host;
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- pgoff_t index = pos >> PAGE_SHIFT;
- uint32_t pageofs = index << PAGE_SHIFT;
- int ret = 0;
-
- pg = grab_cache_page_write_begin(mapping, index, flags);
- if (!pg)
- return -ENOMEM;
- *pagep = pg;
-
- jffs2_dbg(1, "%s()\n", __func__);
-
- if (pageofs > inode->i_size) {
- /* Make new hole frag from old EOF to new page */
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- struct jffs2_raw_inode ri;
- struct jffs2_full_dnode *fn;
- uint32_t alloc_len;
@@ -2476,7 +2482,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
- if (ret)
- goto out_err;
- goto out_page;
-
- mutex_lock(&f->sem);
- memset(&ri, 0, sizeof(ri));
@@ -2506,7 +2512,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- ret = PTR_ERR(fn);
- jffs2_complete_reservation(c);
- mutex_unlock(&f->sem);
- goto out_err;
- goto out_page;
- }
- ret = jffs2_add_full_dnode_to_inode(c, f, fn);
- if (f->metadata) {
@@ -2521,7 +2527,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- jffs2_free_full_dnode(fn);
- jffs2_complete_reservation(c);
- mutex_unlock(&f->sem);
- goto out_err;
- goto out_page;
- }
- jffs2_complete_reservation(c);
- inode->i_size = pageofs;
@@ -2529,19 +2535,6 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- }
-
- /*
- * While getting a page and reading data in, lock c->alloc_sem until
- * the page is Uptodate. Otherwise GC task may attempt to read the same
- * page in read_cache_page(), which causes a deadlock.
- */
- mutex_lock(&c->alloc_sem);
- pg = grab_cache_page_write_begin(mapping, index, flags);
- if (!pg) {
- ret = -ENOMEM;
- goto release_sem;
- }
- *pagep = pg;
-
- /*
- * Read in the page if it wasn't already present. Cannot optimize away
- * the whole page write case until jffs2_write_end can handle the
- * case of a short-copy.
@@ -2550,20 +2543,19 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- mutex_lock(&f->sem);
- ret = jffs2_do_readpage_nolock(inode, pg);
- mutex_unlock(&f->sem);
- if (ret) {
- unlock_page(pg);
- put_page(pg);
- goto release_sem;
- }
- if (ret)
- goto out_page;
- }
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
-
-release_sem:
- mutex_unlock(&c->alloc_sem);
-out_err:
- return ret;
-}
-
-out_page:
- unlock_page(pg);
- put_page(pg);
- return ret;
+ /* Do nothing */
}
-static int jffs2_write_end(struct file *filp, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *pg, void *fsdata)
@@ -2661,8 +2653,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- unlock_page(pg);
- put_page(pg);
- return writtenlen > 0 ? writtenlen : ret;
+ /* Do nothing */
}
-}
diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
--- old/fs/jffs2/fs.c 2022-05-09 17:22:53.000000000 +0800
+++ new/fs/jffs2/fs.c 2022-05-10 16:13:37.830000000 +0800

View File

@@ -780,6 +780,7 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen;
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
cnt = 0;
LOS_MuxUnlock(&g_jffs2FsLock);
return -EFAULT;
}

View File

@@ -62,9 +62,8 @@ static struct ProcDirEntry g_procRootDirEntry = {
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pn)
{
if (len != pn->nameLen) {
if (len != pn->nameLen)
return 0;
}
return !strncmp(name, pn->name, len);
}
@@ -388,9 +387,8 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
void ProcFreeEntry(struct ProcDirEntry *pn)
{
if (atomic_dec_and_test(&pn->count)) {
if (atomic_dec_and_test(&pn->count))
FreeProcEntry(pn);
}
}
static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)

View File

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

View File

@@ -581,8 +581,8 @@ static OsBcacheBlock *AllocNewBlock(OsBcache *bc, BOOL read, UINT64 num)
DelBlock(bc, prefer);
}
if (prefer->used) { /* do not combine with next check */
MergeSyncBlocks(bc, prefer); /* prefer->used may be changed here */
if (prefer->used) {
MergeSyncBlocks(bc, prefer);
}
if (prefer->used) {

View File

@@ -160,7 +160,7 @@ typedef int VfsHashCmp(struct Vnode *vnode, void *arg);
int VnodesInit(void);
int VnodeDevInit(void);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
int VnodeFree(struct Vnode *vnode);
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags);

View File

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

View File

@@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = {
.unlink = ErrorFopUnlink,
};
static struct Mount* GetDevMountPoint(const struct Vnode *dev)
static struct Mount* GetDevMountPoint(struct Vnode *dev)
{
struct Mount *mnt = NULL;
LIST_HEAD *mntList = GetMountList();
@@ -394,7 +394,7 @@ static void FilePreClose(struct file *filep, const struct file_operations_vfs *o
}
}
static void FileDisableAndClean(const struct Mount *mnt)
static void FileDisableAndClean(struct Mount *mnt)
{
struct filelist *flist = &tg_filelist;
struct file *filep = NULL;
@@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode)
vnode->fop = &g_errorFileOps;
}
static void VnodeTryFreeAll(const struct Mount *mount)
static void VnodeTryFreeAll(struct Mount *mount)
{
struct Vnode *vnode = NULL;
struct Vnode *nextVnode = NULL;

View File

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

View File

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

View File

@@ -66,6 +66,7 @@ static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov
} else {
writepart = bytestowrite - ret;
curbuf += writepart;
totallen -= writepart;
break;
}
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -344,7 +344,7 @@ int osShellCmdMount(int argc, const char **argv)
filessystemtype = (argc >= 4) ? (char *)argv[3] : NULL; /* 4: specify fs type, 3: fs type */
mountfalgs = (argc >= 5) ? get_mountflags((const char *)argv[4]) : 0; /* 4: usr option */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data, 6: six args needed for data */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data */
if (strcmp(argv[1], "0") == 0) {
ret = mount((const char *)NULL, fullpath, filessystemtype, mountfalgs, data);
@@ -384,7 +384,7 @@ int osShellCmdMount(int argc, const char **argv)
}
mountfalgs = (argc >= 4) ? get_mountflags((const char *)argv[3]) : 0; /* 3: usr option */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data, 5: number of args needed for data */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data */
if (strcmp(argv[0], "0") == 0) {
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
@@ -761,6 +761,11 @@ static int os_shell_cmd_do_rmdir(const char *pathname)
}
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
size_t fullpath_buf_size = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
if (fullpath_buf_size <= 0) {
PRINTK("buffer size is invalid!\n");
(void)closedir(d);
return -1;
}
fullpath = (char *)malloc(fullpath_buf_size);
if (fullpath == NULL) {
PRINTK("malloc failure!\n");

View File

@@ -70,7 +70,7 @@ VOID OsVmPhysDump(VOID);
VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount);
INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region);
VOID OsDumpPte(VADDR_T vaddr);
LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space);
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space);
CHAR *OsArchFlagsToStr(const UINT32 archFlags);
#ifdef __cplusplus

View File

@@ -193,7 +193,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB);
LosFilePage *OsPageCacheAlloc(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosFilePage *OsFindGetEntry(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr);
LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty);
VOID OsFileCacheFlush(struct page_mapping *mapping);
@@ -208,7 +208,7 @@ VOID OsDeletePageCacheLru(LosFilePage *page);
VOID OsPageRefDecNoLock(LosFilePage *page);
VOID OsPageRefIncLocked(LosFilePage *page);
int OsTryShrinkMemory(size_t nPage);
VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, int off, int len);
VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, int off, int len);
#ifdef LOSCFG_DEBUG_VERSION
VOID ResetPageCacheHitInfo(int *try, int *hit);

View File

@@ -96,7 +96,7 @@ UINT32 LOS_RwlockDestroy(LosRwlock *rwlock)
return LOS_OK;
}
STATIC UINT32 OsRwlockCheck(const LosRwlock *rwlock)
STATIC UINT32 OsRwlockCheck(LosRwlock *rwlock)
{
if (rwlock == NULL) {
return LOS_EINVAL;

View File

@@ -78,6 +78,7 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
/* delete tmpinfo from tmpList. */
*prevHook = tmpInfoNode->next;
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
tmpInfoNode = *prevHook;
break;
}
prevHook = &tmpInfoNode->next;

View File

@@ -918,7 +918,7 @@ STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size)
return LOS_OK;
}
STATIC UINT32 OsMemPoolDelete(const VOID *pool)
STATIC UINT32 OsMemPoolDelete(VOID *pool)
{
UINT32 ret = LOS_NOK;
VOID *nextPool = NULL;

View File

@@ -271,7 +271,7 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
{
UINT32 intSave;
INT32 depth;
enum LockDepErrType checkResult;
enum LockDepErrType checkResult = LOCKDEP_SUCCESS;
VOID *requestAddr = (VOID *)__builtin_return_address(1);
LosTaskCB *current = OsCurrTaskGet();
LosTaskCB *owner = NULL;

View File

@@ -146,6 +146,7 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
LosVmSpace *space = NULL;
LOS_DL_LIST *spaceList = NULL;
UINT32 UProcessUsed = 0;
UINT32 pmTmp;
if (actualPm == NULL) {
return 0;
@@ -166,7 +167,8 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
if (space == LOS_GetKVmSpace()) {
continue;
}
UProcessUsed += OsUProcessPmUsage(space, NULL, NULL);
(VOID)OsUProcessPmUsage(space, NULL, &pmTmp);
UProcessUsed += pmTmp;
}
(VOID)LOS_MuxRelease(vmSpaceListMux);
@@ -206,12 +208,15 @@ UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
PADDR_T paddr;
STATUS_T ret;
INT32 shareRef;
UINT32 pmSize = 0;
if (sharePm != NULL) {
*sharePm = 0;
}
if (actualPm != NULL) {
*actualPm = 0;
}
ret = LOS_MuxAcquire(&space->regionMux);
if (ret != 0) {
return 0;
@@ -235,23 +240,22 @@ UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
if (sharePm != NULL) {
*sharePm += PAGE_SIZE;
}
pmSize += PAGE_SIZE / shareRef;
if (actualPm != NULL) {
*actualPm += PAGE_SIZE / shareRef;
}
} else {
pmSize += PAGE_SIZE;
if (actualPm != NULL) {
*actualPm += PAGE_SIZE;
}
}
}
RB_SCAN_SAFE_END(&oldVmSpace->regionRbTree, pstRbNode, pstRbNodeNext)
(VOID)LOS_MuxRelease(&space->regionMux);
if (actualPm != NULL) {
*actualPm = pmSize;
}
return pmSize;
return *actualPm;
}
LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space)
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space)
{
UINT32 pid;
UINT32 intSave;
@@ -301,7 +305,7 @@ UINT32 OsCountRegionPages(LosVmSpace *space, LosVmMapRegion *region, UINT32 *pss
}
if (pssPages != NULL) {
*pssPages = (UINT32)(pss + 0.5); /* 0.5, for page alignment */
*pssPages = (UINT32)(pss + 0.5);
}
return regionPages;

View File

@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
page->n_maps++;
}
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr)
LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
{
LosMapInfo *info = NULL;
const LOS_DL_LIST *immap = &page->i_mmap;
LOS_DL_LIST *immap = &page->i_mmap;
LOS_DL_LIST_FOR_EACH_ENTRY(info, immap, LosMapInfo, node) {
if ((info->archMmu == archMmu) && (info->vaddr == vaddr) && (info->page == page)) {
@@ -214,7 +214,7 @@ VOID OsVmmFileRemove(LosVmMapRegion *region, LosArchMmu *archMmu, VM_OFFSET_T pg
return;
}
VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, INT32 off, INT32 len)
VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, INT32 off, INT32 len)
{
if (region != NULL) {
OsSetPageDirty(fpage->vmPage);

View File

@@ -233,7 +233,7 @@ LosVmSpace *OsCreateUserVmSpace(VOID)
return space;
}
STATIC BOOL OsVmSpaceParamCheck(const LosVmSpace *vmSpace)
STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace)
{
if (vmSpace == NULL) {
return FALSE;

View File

@@ -297,7 +297,7 @@ int OsTryShrinkMemory(size_t nPage)
LosFilePage *fpage = NULL;
LosFilePage *fnext = NULL;
if (nPage == 0) {
if (nPage <= 0) {
nPage = VM_FILEMAP_MIN_SCAN;
}

View File

@@ -166,7 +166,7 @@ MMAP_DONE:
STATUS_T LOS_UnMMap(VADDR_T addr, size_t size)
{
if ((addr <= 0) || (size == 0)) {
if ((addr <= 0) || (size <= 0)) {
return -EINVAL;
}

View File

@@ -404,7 +404,7 @@ STATIC VOID EchoToTerminal(CONSOLE_CB *consoleCB, struct file *filep, const stru
{
if (consoleCB->consoleTermios.c_lflag & ECHO) {
if (ch == '\b') {
(VOID)fops->write(filep, "\b \b", 3); // 3: length of "\b \b"
(VOID)fops->write(filep, "\b \b", 3);
} else {
(VOID)fops->write(filep, &ch, EACH_CHAR);
}
@@ -709,6 +709,7 @@ STATIC ssize_t DoWrite(CirBufSendCB *cirBufSendCB, CHAR *buffer, size_t bufLen)
{
INT32 cnt;
size_t written = 0;
size_t toWrite = bufLen;
UINT32 intSave;
#ifdef LOSCFG_SHELL_DMESG
@@ -729,6 +730,7 @@ STATIC ssize_t DoWrite(CirBufSendCB *cirBufSendCB, CHAR *buffer, size_t bufLen)
if (cnt <= 0) {
break;
}
toWrite -= cnt;
written += cnt;
}
LOS_SpinUnlockRestore(&g_consoleWriteSpinLock, intSave);
@@ -1534,15 +1536,7 @@ STATIC ssize_t WriteToTerminal(const CONSOLE_CB *consoleCB, const CHAR *buffer,
fd = consoleCB->fd;
ret = fs_getfilep(fd, &filep);
if (ret < 0) {
ret = -EPERM;
goto ERROUT;
}
ret = GetFilepOps(filep, &privFilep, &fileOps);
if (ret != ENOERR) {
ret = -EINVAL;
goto ERROUT;
}
if ((fileOps == NULL) || (fileOps->write == NULL)) {
ret = EFAULT;

View File

@@ -87,6 +87,7 @@ STATIC VOID InitLevelCall(const CHAR *name, const UINT32 level, struct ModuleIni
LOS_SpinUnlock(&g_initLock);
if (module->hook != NULL) {
#ifdef LOS_INIT_DEBUG
ret = LOS_OK;
startNsec = LOS_CurrNanosec();
ret = (UINT32)module->hook();
endNsec = LOS_CurrNanosec();

View File

@@ -51,7 +51,7 @@ STATIC BOOL g_srandInit;
STATIC INT32 OsELFOpen(const CHAR *fileName, INT32 oflags)
{
INT32 ret;
INT32 ret = -LOS_NOK;
INT32 procFd;
procFd = AllocProcessFd();

View File

@@ -233,8 +233,14 @@ static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
{
struct timespec now = {0};
(void)clock_gettime(CLOCK_REALTIME, &now);
struct timespec now;
int ret;
ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
PRINTK("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
return;
}
header->len = len;
header->pid = LOS_GetCurrProcessID();

View File

@@ -124,8 +124,8 @@ ATTRIBUTE_NO_SANITIZE_ADDRESS void LmsSetShadowValue(uintptr_t startAddr, uintpt
uint32_t startOffset;
uint32_t endOffset;
unsigned char shadowValueMask;
unsigned char shadowValue;
char shadowValueMask;
char shadowValue;
/* endAddr - 1, then we mark [startAddr, endAddr) to value */
LmsMem2Shadow(startAddr, &shadowStart, &startOffset);
@@ -266,7 +266,7 @@ ATTRIBUTE_NO_SANITIZE_ADDRESS void LmsPrintMemInfo(uintptr_t addr)
}
}
LMS_OUTPUT_INFO("|\t[0x%x | %2u]: ", shadowAddr, shadowOffset);
LMS_OUTPUT_INFO("|\t[0x%x | %2d]: ", shadowAddr, shadowOffset);
for (int x = 0; x < printX; x += LMS_MEM_BYTES_PER_SHADOW_CELL) {
LmsGetShadowValue(dumpAddr + x, &shadowValue);
@@ -339,7 +339,7 @@ ATTRIBUTE_NO_SANITIZE_ADDRESS static void LmsPrintErrInfo(LmsAddrInfo *info, uin
break;
}
LMS_OUTPUT_INFO("Shadow memory address: [0x%x : %u] Shadow memory value: [%u] \n", info->shadowAddr,
LMS_OUTPUT_INFO("Shadow memory address: [0x%x : %d] Shadow memory value: [%d] \n", info->shadowAddr,
info->shadowOffset, info->shadowValue);
LMS_OUTPUT_INFO("\n");

View File

@@ -289,7 +289,7 @@ STATIC UINT32 OsPerfCollectData(Event *event, PerfSampleData *data, PerfRegs *re
* return TRUE if user haven't specified any taskId(which is supposed
* to instrument the whole system)
*/
STATIC INLINE BOOL OsFilterId(UINT32 id, const UINT32 *ids, UINT8 idsNr)
STATIC INLINE BOOL OsFilterId(UINT32 id, UINT32 *ids, UINT8 idsNr)
{
UINT32 i;
if (!idsNr) {

View File

@@ -300,7 +300,7 @@ UINT32 LOS_PmRegister(LOS_PmNodeType type, VOID *node)
return LOS_EINVAL;
}
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, const LosPmDevice *device)
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, LosPmDevice *device)
{
LOS_SpinLock(&g_pmSpin);
if (pm->device == device) {

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -342,7 +342,7 @@ int print_netif(struct netif *netif, char *print_buf, unsigned int buf_len)
buf_len -= (unsigned int)ret;
ret = snprintf_s(tmp, buf_len, (buf_len - 1), " MTU:%d %s", netif->mtu,
(netif->flags & NETIF_FLAG_UP) ? "Running" : "Stop");
netif->flags & NETIF_FLAG_UP ? "Running" : "Stop");
if ((ret <= 0) || ((unsigned int)ret >= buf_len))
goto out;
tmp += ret;
@@ -356,8 +356,7 @@ int print_netif(struct netif *netif, char *print_buf, unsigned int buf_len)
buf_len -= (unsigned int)ret;
}
ret = snprintf_s(tmp, buf_len, (buf_len - 1), " %s\n",
(netif->flags & NETIF_FLAG_LINK_UP) ? "Link UP" : "Link Down");
ret = snprintf_s(tmp, buf_len, (buf_len - 1), " %s\n", netif->flags & NETIF_FLAG_LINK_UP ? "Link UP" : "Link Down");
if ((ret <= 0) || ((unsigned int)ret >= buf_len))
goto out;
tmp += ret;
@@ -2175,6 +2174,8 @@ u32_t osShellPing6(int argc, const char **argv)
/* Setting the start time of the entire ping task for statistics */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &first);
nsent = 0;
for (nsent = 0; nsent < ping6_params.pingcount; nsent++) {
/* capture the start tick to calculate rtt */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &start);
@@ -3018,8 +3019,8 @@ int netstat_netconn_sendq(struct netconn *conn)
#if PF_PKT_SUPPORT
case NETCONN_PKT_RAW:
retVal = 0; /* always be 0 as frame send to driver directly */
break;
#endif
break;
case NETCONN_UDP:
retVal = netstat_udp_sendq(conn->pcb.udp);
break;
@@ -3168,6 +3169,7 @@ void netstat_internal(void *ctx)
}
/* For listen PCBs */
recvQlen = 0;
sendQlen = 0;
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
@@ -3667,7 +3669,7 @@ u32_t netdebug_sock(int argc, const char **argv)
int idx;
u32_t ret = LOS_NOK;
if (argc == 2) { /* 2: Number of command parameters */
if (argc == 2) {
if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */
for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) {
@@ -3675,9 +3677,10 @@ u32_t netdebug_sock(int argc, const char **argv)
}
ret = LOS_OK;
}
} else if (argc == 3) { /* 3: Number of command parameters */
} else if (argc == 3) {
if (!strcmp("-d", argv[1])) {
idx = atoi(argv[2]); /* 2: netdebug sock -d <idx> */
/* netdebug sock -d <idx> */
idx = atoi(argv[2]);
if (idx >= 0) {
debug_socket_info(idx, 1, 1);
ret = LOS_OK;
@@ -3794,9 +3797,8 @@ u32_t osShellIpDebug(int argc, const char **argv)
PRINTK("%-50s ", acIPv6Addr);
if (snprintf_s(aclladdr, sizeof(aclladdr), sizeof(aclladdr) - 1, "%02X:%02X:%02X:%02X:%02X:%02X",
neighbor_cache[i].lladdr[0], neighbor_cache[i].lladdr[1], /* 0, 1, member number */
neighbor_cache[i].lladdr[2], neighbor_cache[i].lladdr[3], /* 2, 3, member number */
neighbor_cache[i].lladdr[4], neighbor_cache[i].lladdr[5]) < 0) { /* 4, 5, member number */
neighbor_cache[i].lladdr[0], neighbor_cache[i].lladdr[1], neighbor_cache[i].lladdr[2],
neighbor_cache[i].lladdr[3], neighbor_cache[i].lladdr[4], neighbor_cache[i].lladdr[5]) < 0) {
return LOS_NOK;
}
PRINTK("%-25s ", aclladdr);

View File

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

View File

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

View File

@@ -34,8 +34,8 @@
#if LWIP_PERF
#define PERF_START do {} while (0) /* something to do */
#define PERF_STOP(x) do {} while (0) /* something to do */
#define PERF_START do {/* something to do */} while (0)
#define PERF_STOP(x) do {/* something to do */} while (0)
#endif

View File

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

View File

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

View File

@@ -116,8 +116,8 @@ static UINT16 GetFreeVid(VOID)
for (i = 0; i < mapMaxNum; i++) {
num = idMap->bitMap[i];
for (j = 0; j < INT_BIT_COUNT; j++) {
if ((num & (1U << j)) == 0) {
num |= 1U << j;
if ((num & (1 << j)) == 0) {
num |= 1 << j;
idMap->bitMap[i] = num;
return (INT_BIT_COUNT * i + j);
}
@@ -160,7 +160,7 @@ static VOID ReleaseVid(UINT16 vid)
a = vid >> INT_BIT_SHIFT;
b = vid & (INT_BIT_COUNT - 1);
idMap->bitMap[a] &= ~(1U << b);
idMap->bitMap[a] &= ~(1 << b);
/* shrink bit map */
if (mapMaxNum > 1) {

View File

@@ -34,9 +34,9 @@
#include "los_typedef.h"
#include "los_process_pri.h"
#define INT_BIT_COUNT 32U
#define INT_BIT_SHIFT 5U
#define VID_MAP_MAX_NUM 32U
#define INT_BIT_COUNT 32
#define INT_BIT_SHIFT 5
#define VID_MAP_MAX_NUM 32
#define MAX_INVALID_TIMER_VID (VID_MAP_MAX_NUM * INT_BIT_COUNT)

View File

@@ -145,7 +145,7 @@ INT32 CmdLog(INT32 argc, const CHAR **argv)
}
} else if (!strncmp(argv[0], "module", strlen(argv[0]) + 1)) {
module = strtoul(argv[1], &p, 0);
if ((*p != 0) || (module > MODULE4)) {
if ((*p != 0) || (module > MODULE4) || (module < MODULE0)) {
PRINTK("log %s can't access %s\n", argv[0], argv[1]);
PRINTK("not support yet\n");
return -1;

View File

@@ -329,7 +329,7 @@ END:
LITE_OS_SEC_TEXT_MINOR UINT32 ShellEntry(UINTPTR param)
{
CHAR ch;
INT32 n;
INT32 n = 0;
ShellCB *shellCB = (ShellCB *)param;
CONSOLE_CB *consoleCB = OsGetConsoleByID((INT32)shellCB->consoleID);

View File

@@ -425,7 +425,7 @@ STATIC VOID OsBufFullWrite(const CHAR *dst, UINT32 logLen)
STATIC VOID OsWriteTailToHead(const CHAR *dst, UINT32 logLen)
{
UINT32 writeLen;
UINT32 writeLen = 0;
UINT32 bufSize = g_logBufSize;
UINT32 logSize = g_dmesgInfo->logSize;
UINT32 tail = g_dmesgInfo->logTail;

View File

@@ -83,10 +83,6 @@ int GetFullpath(int fd, const char *path, char **fullpath)
fd = GetAssociatedSystemFd(fd);
}
ret = fs_getfilep(fd, &file);
if (ret < 0) {
ret = -EPERM;
goto OUT;
}
if (file) {
ret = stat(file->f_path, &bufRet);
if (!ret) {

View File

@@ -109,7 +109,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
{
int ret;
struct itimerval svalue;
struct itimerval sovalue = { 0 };
struct itimerval sovalue;
if (value == NULL) {
errno = EINVAL;
@@ -137,7 +137,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
int SysGetiTimer(int which, struct itimerval *value)
{
int ret;
struct itimerval svalue = { 0 };
struct itimerval svalue;
if (value == NULL) {
errno = EINVAL;
@@ -189,7 +189,7 @@ int SysTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
int SysTimerGettime(timer_t timerID, struct itimerspec *value)
{
int ret;
struct itimerspec svalue = { 0 };
struct itimerspec svalue;
if (value == NULL) {
errno = EINVAL;
@@ -213,7 +213,7 @@ int SysTimerSettime(timer_t timerID, int flags, const struct itimerspec *value,
{
int ret;
struct itimerspec svalue;
struct itimerspec soldValue = { 0 };
struct itimerspec soldValue;
if (value == NULL) {
errno = EINVAL;
@@ -285,7 +285,7 @@ int SysClockSettime(clockid_t clockID, const struct timespec *tp)
int SysClockGettime(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp = { 0 };
struct timespec stp;
if (tp == NULL) {
errno = EINVAL;
@@ -308,7 +308,7 @@ int SysClockGettime(clockid_t clockID, struct timespec *tp)
int SysClockGetres(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp = { 0 };
struct timespec stp;
if (tp == NULL) {
errno = EINVAL;
@@ -356,7 +356,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{
int ret;
struct timespec srqtp;
struct timespec srmtp = { 0 };
struct timespec srmtp;
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT;
@@ -384,7 +384,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
clock_t SysTimes(struct tms *buf)
{
clock_t ret;
struct tms sbuf = { 0 };
struct tms sbuf;
if (buf == NULL) {
errno = EFAULT;
@@ -436,7 +436,7 @@ int SysClockGettime64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp = { 0 };
struct timespec64 stp;
if (tp == NULL) {
errno = EINVAL;
@@ -463,7 +463,7 @@ int SysClockGetres64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp = { 0 };
struct timespec64 stp;
if (tp == NULL) {
errno = EINVAL;
@@ -525,7 +525,7 @@ int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value)
{
int ret;
struct itimerspec val;
struct itimerspec64 svalue = { 0 };
struct itimerspec64 svalue;
if (value == NULL) {
errno = EINVAL;
@@ -584,7 +584,6 @@ int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *val
}
if (oldValue != NULL) {
(void)memset_s(&soldValue, sizeof(struct itimerspec64), 0, sizeof(struct itimerspec64));
soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec;
soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec;
soldValue.it_value.tv_sec = oldVal.it_value.tv_sec;

View File

@@ -49,13 +49,13 @@ static VOID NestingPrioHigh(INT32 irq, VOID *data)
UINT64 curTime;
curTime = LOS_CurrNanosec();
g_recordTime[g_saveIndex] = curTime - g_intPendTime;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime);
dprintf("%lld\n", curTime - g_intPendTime);
dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]);
g_saveIndex++;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
}
static VOID DumpResult()

View File

@@ -48,9 +48,8 @@ static VOID SwtmrF01(VOID)
g_eventMask = g_eventMask | (1 << g_testCount);
if (g_testCount > 17) { // g_testCount > 17, do noting return
if (g_testCount > 17) // g_testCount > 17, do noting return
return;
}
ret = LOS_EventWrite(&g_event, g_eventMask);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);

View File

@@ -104,9 +104,9 @@ static UINT32 Testcase(VOID)
TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
if ((g_ret1 + g_ret2 == 0xff) && (TestAbs(g_ret1, g_ret2) == 0xff)) {
if ((g_ret1 + g_ret2 == 0xff) && (TestAbs(g_ret1, g_ret2) == 0xff))
ICUNIT_GOTO_EQUAL(1, 1, g_ret1, EXIT);
} else {
else {
ICUNIT_GOTO_EQUAL(1, 0, g_ret1, EXIT);
}
PRINT_DEBUG("ret1=0x%x,ret2=0x%x\n", g_ret1, g_ret2);

View File

@@ -39,9 +39,8 @@ extern "C" {
static UINT32 TaskF02(VOID)
{
UINT32 ret = OS_ERROR, cpupUse;
UINT32 ret, cpupUse;
g_cpupTestCount++;
// 2, Here, assert that g_cpupTestCount is equal to the expected value.
ICUNIT_GOTO_EQUAL(g_cpupTestCount, 2, g_cpupTestCount, EXIT);
cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);

View File

@@ -39,10 +39,9 @@ extern "C" {
static UINT32 TaskF01(VOID)
{
UINT32 ret = OS_ERROR;
UINT32 ret;
UINT32 cpupUse;
g_cpupTestCount++;
ICUNIT_GOTO_EQUAL(g_cpupTestCount, 1, g_cpupTestCount, EXIT);
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE0);

View File

@@ -76,7 +76,7 @@ static void Task01(void)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ret = memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2;
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04;
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
taskInitParam.pcName = "SmpCpup005_task04";

View File

@@ -105,9 +105,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh3, NULL, PthreadF03, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
while (g_testCount < 6) { // 6, wait until g_testCount is equal to 6.
while (g_testCount < 6) // 6, wait until g_testCount is equal to 6.
sleep(1);
}
ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, here assert the result.

View File

@@ -75,9 +75,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM) {
while (g_startNum < THREAD_NUM)
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently

View File

@@ -80,9 +80,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM) {
while (g_startNum < THREAD_NUM)
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently

View File

@@ -87,9 +87,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM) {
while (g_startNum < THREAD_NUM)
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently

View File

@@ -76,9 +76,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM) {
while (g_startNum < THREAD_NUM)
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently

View File

@@ -79,9 +79,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
}
while (g_startNum < THREAD_NUM) {
while (g_startNum < THREAD_NUM)
usleep(100); // 100, delay for Timing control.
}
/*
* Acquire the mutex to make sure that all waiters are currently

View File

@@ -75,9 +75,8 @@ static UINT32 Testcase(VOID)
rc = pthread_create(&thread1, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
while (!g_t1Start) { /* wait for thread1 started */
while (!g_t1Start) /* wait for thread1 started */
usleep(100); // 100, delay for Timing control.
}
/* acquire the mutex released by pthread_cond_wait() within thread 1 */
rc = pthread_mutex_lock(&g_td.mutex);

View File

@@ -114,9 +114,8 @@ static void *PthreadF02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
break;
}
}
g_lowDone = 1;
EXIT:

View File

@@ -115,9 +115,8 @@ static void *PthreadF02(void *tmp)
clock_gettime(CLOCK_REALTIME, &startTime);
while (1) {
clock_gettime(CLOCK_REALTIME, &currentTime);
if (PthreadTimeF01(currentTime, startTime) > RUNTIME) {
if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
break;
}
}
g_lowDone = 1;
EXIT:

View File

@@ -58,9 +58,8 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
/* Make sure the thread was created before we join it. */
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
sleep(1);
}
ret = pthread_join(newTh, &valuePtr);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -77,9 +77,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_testCount == 0) {
while (g_testCount == 0)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -76,9 +76,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == 0) {
while (g_pthreadSem == 0)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -51,9 +51,8 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
sleep(1);
}
pthread_testcancel();
@@ -74,9 +73,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -48,9 +48,8 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
sleep(1);
}
pthread_testcancel();
@@ -70,9 +69,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -48,9 +48,8 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
sleep(1);
}
pthread_testcancel();
@@ -71,9 +70,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -48,9 +48,8 @@ static VOID *PthreadF01(VOID *argument)
g_pthreadSem = PTHREAD_INMAIN_TEST;
while (g_pthreadSem == PTHREAD_INMAIN_TEST) {
while (g_pthreadSem == PTHREAD_INMAIN_TEST)
sleep(1);
}
pthread_testcancel();
@@ -72,9 +71,8 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
while (g_pthreadSem == PTHREAD_INTHREAD_TEST) {
while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
sleep(1);
}
ret = pthread_cancel(newTh);
ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);

View File

@@ -202,11 +202,10 @@ iUINT32 ICunitInit(void)
iUINT32 ICunitRunSingle(ICUNIT_CASE_S *psubCase)
{
if ((g_isSpinorInit == FALSE) && (psubCase->testcase_module == TEST_JFFS)) {
if ((g_isSpinorInit == FALSE) && (psubCase->testcase_module == TEST_JFFS))
dprintf("****** Jffs is not support ! ****** \n");
} else {
else
ICunitRunF(psubCase);
}
return (iUINT32)ICUNIT_SUCCESS;
}

View File

@@ -315,9 +315,8 @@ VOID TestTestHwiDelete(unsigned int irq, VOID *devId)
{
HwiIrqParam stuwIrqPara;
if (OS_INT_ACTIVE) {
if (OS_INT_ACTIVE)
return;
}
stuwIrqPara.swIrq = irq;
stuwIrqPara.pDevId = devId;

View File

@@ -55,7 +55,7 @@ static int Testcase(void)
handle = dlopen(LIBCSO_REAL_PATH, RTLD_NOW);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = reinterpret_cast<int (*)(int)>(dlsym(handle, SYMBOL_TO_FIND));
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ICUNIT_GOTO_EQUAL(func, SYMBOL_TO_MATCH, func, EXIT);
@@ -65,7 +65,7 @@ static int Testcase(void)
handle = dlopen(LIBCSO_RELATIVE_PATH, RTLD_NOW);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = reinterpret_cast<int (*)(int)>(dlsym(handle, SYMBOL_TO_FIND));
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = dlclose(handle);

View File

@@ -33,12 +33,12 @@
static int TestCase(void)
{
int ret;
int *test = NULL;
int status = 0;
int *test = NULL; // for trggering an exception
pid_t pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
*test = 0x1;
exit(0);
}
@@ -54,7 +54,7 @@ static int TestCase(void)
pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
*test = 0x1;
exit(0);
}

View File

@@ -35,17 +35,18 @@
static int TestThread(void)
{
int *test = nullptr;
int ret;
int *test = nullptr; // For triggering an exceptioin
pid_t pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
*test = 0x1;
while (1) {
}
}
*test = 0x1; // Deliberately trigger an exceptioin
*test = 0x1;
ret = waitpid(pid, NULL, 0);
ICUNIT_ASSERT_EQUAL(ret, pid, ret);
@@ -55,6 +56,7 @@ static int TestThread(void)
static int TestCase(void)
{
int *test = nullptr;
int count = 5;
int status = 0;
int ret;

View File

@@ -41,7 +41,7 @@ static int TestCase(void)
wchar_t res2[] = L"abcdmngh";
wchar_t *p, *pnew;
pnew = static_cast<wchar_t *>(malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1))));
pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
ICUNIT_ASSERT_NOT_EQUAL(pnew, NULL, pnew);
p = wmempcpy(pnew, res, wcslen(res));

View File

@@ -91,7 +91,7 @@ VOID *ShmWriteFunc(VOID *ptr)
shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
shm = shmat(shmid, nullptr, 0);
shm = shmat(shmid, (void *)0, 0);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
printf("Memory attached at %p\n", shm);

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -31,46 +31,39 @@
#include "it_test_shm.h"
#define SHMID_MAX 192
#define SHM_FLAG 0777
static int Testcase(VOID)
{
int shmid[SHMID_MAX + 1] = {-1};
int ret;
int i;
struct shm_info shmInfo;
int leftShmIds;
ret = shmctl(0, SHM_INFO, reinterpret_cast<struct shmid_ds *>(&shmInfo));
ICUNIT_ASSERT_EQUAL(ret, SHMID_MAX, ret);
leftShmIds = SHMID_MAX - shmInfo.used_ids;
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, SHM_FLAG | IPC_CREAT); // 0x1234: a key used to create shared memory
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
for (i = 0; i < leftShmIds; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
for (i = 0; i < SHMID_MAX; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
}
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]);
shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[SHMID_MAX], -1, shmid[SHMID_MAX]);
for (i = 0; i < leftShmIds; i++) {
for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
}
for (i = 0; i < leftShmIds; i++) {
for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
}

View File

@@ -55,6 +55,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT);
ret = shmctl(shmid, SHM_STAT, &ds);
// ICUNIT_GOTO_EQUAL(ret, 0x10000, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT);
@@ -69,7 +70,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT); // 128: expected value of shmseg
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT);
ret = shmdt(shm);

View File

@@ -49,13 +49,13 @@ static int Testcase(VOID)
shm = shmat(shmid, NULL, SHM_REMAP);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, reinterpret_cast<const void *>(0x100), 0);
shm = shmat(shmid, (const void *)0x100, 0);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shm, reinterpret_cast<void *>(-1), shm);
ICUNIT_ASSERT_NOT_EQUAL(shm, (void *)-1, shm);
ret = shmdt(reinterpret_cast<const void *>(0x100));
ret = shmdt((const void *)0x100);
ICUNIT_ASSERT_EQUAL(ret, -1, shmid);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);

View File

@@ -42,14 +42,14 @@ static int Testcase(VOID)
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
remap = shared;
shared = shmat(shmid, remap, SHM_REMAP);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);

View File

@@ -47,7 +47,7 @@ static int Testcase(void)
ret = fork();
if (ret == 0) {
usleep(100000);
if ((shared = static_cast<char *>(shmat(shmid, 0, 0))) == reinterpret_cast<void *>(-1)) {
if ((shared = (char *)shmat(shmid, 0, 0)) == (void *)-1) {
printf("child : error: shmat()\n");
exit(1);
}
@@ -72,8 +72,8 @@ static int Testcase(void)
pid = ret;
usleep(50000);
shared = static_cast<char *>(shmat(shmid, 0, 0));
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
shared = (char *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = strncpy_s(shared, memSize, testStr, sizeof(testStr));
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -42,11 +42,11 @@ static int Testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
shared = shmat(shmid, 0, SHM_RDONLY);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);

View File

@@ -88,14 +88,14 @@ static int Testcase(void)
int ret;
int pid;
void *ptr = reinterpret_cast<void *>(signal(SIGTERM, ExitChildren));
void *ptr = (void *)signal(SIGTERM, ExitChildren);
ICUNIT_ASSERT_NOT_EQUAL(ptr, NULL, ptr);
shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
g_shmptr = (int *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, reinterpret_cast<int *>(-1), g_shmptr);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, (int *)-1, g_shmptr);
*g_shmptr = 0;

View File

@@ -43,9 +43,9 @@ static int testcase(void)
shmfd = shm_open("test_1", O_RDWR | O_CREAT | O_EXCL, 0644);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = static_cast<char *>(malloc(pageSize));
writebuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = static_cast<char *>(malloc(pageSize));
readbuf = (char*)malloc(pageSize);
ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT);
(void)memset_s(writebuf, pageSize, 0xf, pageSize);

View File

@@ -49,9 +49,9 @@ static int testcase(void)
shmfd = shm_open("test_2", O_RDONLY | O_CREAT, 00664);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = static_cast<char *>(malloc(pageSize));
writebuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = static_cast<char *>(malloc(pageSize));
readbuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
(void)memset_s(writebuf, pageSize, 0xf, pageSize);

View File

@@ -45,7 +45,7 @@ static int Testcase(void)
ret = fork();
if (ret == 0) {
shared = (int *)shmat(shmid, NULL, 0);
if (shared == reinterpret_cast<int *>(-1)) {
if (shared == (int *)-1) {
exit(1);
}
*shared = 2;
@@ -55,7 +55,7 @@ static int Testcase(void)
} else {
usleep(20000);
shared = (int *)shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<int *>(-1), shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, (int *)-1, shared);
ICUNIT_ASSERT_EQUAL(*shared, 2, *shared);

View File

@@ -71,7 +71,7 @@ static int Testcase(void)
printf("err: malloc size invalid\n");
return -1;
}
buf = static_cast<char *>(malloc(pageSize));
buf = (char *)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
(void)memset_s(buf, pageSize, 0xf, pageSize);

View File

@@ -49,7 +49,7 @@ static int Testcase(void)
fd = open(file, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
invalueAddr = reinterpret_cast<void *>(VALIDE_ADDR | ADDR_OFFSET);
invalueAddr = (void *)(VALIDE_ADDR | ADDR_OFFSET);
mem = mmap(invalueAddr, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);

View File

@@ -40,26 +40,24 @@ static int Testcase(void)
const char *str = "Hi, OHOS.";
/* sigprocmask 内核系统调用接口通过arch_copy_from_user拷贝用户参数 */
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(1), &oldset);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)1, &oldset);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR), &oldset);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, &oldset);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
/* sigprocmask 内核系统调用接口通过arch_copy_to_user将内核参数拷贝至用户 */
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR), reinterpret_cast<sigset_t *>(1));
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)1);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(INVALID_USER_VADDR));
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)INVALID_USER_VADDR);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(const_cast<char *>(str)));
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)str);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);

View File

@@ -53,7 +53,7 @@ static int Testcase(VOID)
fd = open(MOUSE_DEV_PATH, O_RDWR, 0666);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
buf = static_cast<char *>(malloc(MOUSE_DATA_LEN));
buf = (char *)malloc(MOUSE_DATA_LEN);
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
ret = memset_s(buf, MOUSE_DATA_LEN, 0, MOUSE_DATA_LEN);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -51,7 +51,7 @@ static int Testcase(VOID)
fd = open(STORAGE_DEV_PATH, O_RDWR, 0666);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
buf = static_cast<char *>(malloc(STORAGE_DATA_LEN));
buf = (char *)malloc(STORAGE_DATA_LEN);
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
ret = memset_s(buf, STORAGE_DATA_LEN, 0, STORAGE_DATA_LEN);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -62,24 +62,26 @@ static int LiteIpcTest(void)
/* testing mmap liteipc mem pool with different size and flag */
retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
//retptr = mmap(nullptr, 0, PROT_READ, MAP_PRIVATE, fd, 0);
//ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0); // 4096: length of mapped memory
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, 4095, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
/* testing read/write api */
char buf[10] = {0};
ret = read(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ret = write(fd, buf, 10); // 10: size of buf
ret = write(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
/* before set cms, testing ioctl cmd */
@@ -94,7 +96,7 @@ static int LiteIpcTest(void)
sleep(2);
/* after set cms, testing set cms cmd */
ret = ioctl(fd, IPC_SET_CMS, 200); // 200: use 200 for set cms cmd testing
ret = ioctl(fd, IPC_SET_CMS, 200);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
exit(0);
@@ -119,7 +121,7 @@ static int TestCase(void)
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
retptr = mmap(nullptr, 16 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ret = ioctl(fd, IPC_SET_CMS, 0);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
ret = ioctl(fd, IPC_SET_CMS, 200);

View File

@@ -65,7 +65,7 @@ static int CallTestServiceLoop(uint32_t id)
ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
@@ -141,7 +141,7 @@ static int TestServiceLoop(void)
ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

Some files were not shown because too many files have changed in this diff Show More