Compare commits

..

48 Commits

Author SHA1 Message Date
openharmony_ci
e46f96de46 !1170 挑单swtmr遍历不全导致的用例问题到3.2
Merge pull request !1170 from wangchen/0726_32
2023-07-29 01:55:55 +00:00
wangchen
82f06317c5 Fix: 挑单swtmr遍历不全导致的用例问题到3.2
Close #I7O084
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-07-26 09:54:00 +08:00
openharmony_ci
379aa8dd27 !1130 【同步到monthly_20221018分支】fix:修复内核调用栈解析脚本bug
Merge pull request !1130 from zhangdengyu/cherry-pick-1677501665
2023-03-06 04:17:04 +00:00
zhangdengyu
3b2c37aa66 fixed f924cc7 from https://gitee.com/zhangdengyu/kernel_liteos_a/pulls/1129
fix:修复内核调用栈解析脚本bug

方案描述:
1、修复内核调用栈解析脚本parse_mem_info.sh的bug,将多余符号(`)去除

BREAKING CHANGE:
无

Close:#I6I6BA

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I0b0d7e5f6e79313e5f517f89395f4195883cfe06
2023-02-27 12:41:06 +00:00
openharmony_ci
f7dbd27a33 !1111 Fix : 删除冗余函数挑单到monthly_20221018分支
Merge pull request !1111 from yinjiaming/cherry-pick-1675760069
2023-02-09 02:01:05 +00:00
yinjiaming
0b3430e574 fixed d17bc9d from https://gitee.com/hgbveiu743/kernel_liteos_a/pulls/1109
fix:删除冗余的函数
代码扫描工具发现代码中有被注释的多余函数,现删除。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I26980061390924d53c77e467b2cab2f56b192a82
2023-02-07 08:54:29 +00:00
openharmony_ci
518d448a2f !1093 Fix : 内核告警清理挑单到monthly_20221018
Merge pull request !1093 from yinjiaming/cherry-pick-1672881303
2023-01-06 11:29:40 +00:00
yinjiaming
05b07a29fe fixed ebc3f30 from https://gitee.com/hgbveiu743/kernel_liteos_a/pulls/1089
fix:修复codecheck扫描出的告警
给宏定义中的参数加上了括号,删除了多余的函数声明

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I8853f6a9717ede96578cd674b83b716c8e63f0d8
2023-01-05 01:15:05 +00:00
openharmony_ci
2bef65046a !1081 fix: 【挑单】codecheck问题清零
Merge pull request !1081 from zhushengle/cherry-pick-1669685670
2022-11-29 03:20:11 +00:00
zhushengle
205df75f15 fixed 8d980de from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1078
fix: codecheck问题清零

1.shell初始化异常流程double free
2.los_disk_init中冗余初始化
3.OsKProcessPmUsage 中OsUProcessPmUsage异常退出时,存在使用未初始化的变量
4.HiLogHeadInit异常推出后,存在使用未初始化的变量
5.api_shell.c 中存在冗余初始化

fix #I63H5G

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: If17d8ed1e6f2276e20fbce24b32de169bfd22e54
2022-11-29 01:34:30 +00:00
openharmony_ci
85f1c9e0ca !1067 【挑单】time相关系统调用内核栈信息泄露排查
Merge pull request !1067 from zhushengle/cherry-pick-1668158211
2022-11-14 03:24:57 +00:00
zhushengle
c04ff6b10f fixed 0b05a46 from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1061
task: time相关系统调用内核栈信息泄露排查

解决方案:
    在涉及从内核拷贝数据到用户态的场景时,先将内核的数据进行清零操作,再填充内核数据
Close #I60M1P

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia61d4e39b9e190accea477ff5b361e41d0eed2af
2022-11-11 09:16:52 +00:00
openharmony_ci
1b61489512 !1048 Fix : 内核告警清理挑单到monthly 分支
Merge pull request !1048 from yinjiaming/cherry-pick-1666774395
2022-10-27 14:24:41 +00:00
yinjiaming
29c459e045 fixed 8d55bb1 from https://gitee.com/hgbveiu743/kernel_liteos_a/pulls/1046
fix: 内核告警清理
【背景】
内核告警清理

【修改方案】
删去了多余的空格,更改了魔数字

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iba21be6cb23027dfb369576847d7d21e85f936b4
2022-10-26 08:53:15 +00:00
openharmony_ci
e7daa28200 !1025 清除一些静态检查工具发现的问题
Merge pull request !1025 from Far/master
2022-10-17 01:39:02 +00:00
Far
987a722d2d fix: 修复一些静态检查工具发现的问题
Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2b93259d55a9eb1a9dfd5887fd7821c15274bb7f
2022-10-15 17:36:45 +08:00
openharmony_ci
ccdfa72431 !1016 修复执行测试用例执行时间过长等问题
Merge pull request !1016 from 夏不白/fix_unittest
2022-10-12 06:29:16 +00:00
openharmony_ci
557a71c1c3 !1020 jffs2.patch 文件适配LTS补丁升级
Merge pull request !1020 from 闻飞/master
2022-10-08 11:28:25 +00:00
wenfei
569aecb6ea jffs2.patch update
Signed-off-by: wenfei <wenfei9@huawei.com>
2022-09-30 11:23:29 +08:00
xiacong
8c0b7d0f38 <fix>
修复测试用例不过的问题

<body>
1.修复执行liteos_a_basic_unittest.bin时间过长的问题
2.修复测试shm系列系统调用函数用例失败的问题

Signed-off-by: xiacong <xiacong4@huawei.com>
Change-Id: Iabc541cb1c0e97dac0fe13aaeb98e85404e5bf6f
Signed-off-by: xiacong <xiacong4@huawei.com>
2022-09-28 17:24:14 +08:00
openharmony_ci
c488817b32 !1008 修复内核告警信息
Merge pull request !1008 from zhangdengyu/fix_preferused
2022-09-26 12:52:00 +00:00
openharmony_ci
43d47a27e3 !1011 fix: 修复shell_lk.c告警清零带来的逻辑修改
Merge pull request !1011 from 夏不白/module_fix
2022-09-26 11:22:57 +00:00
xiacong
a83f916298 <fix>
恢复告警清零带来的逻辑改变

Signed-off-by: xiacong <xiacong4@huawei.com>
Change-Id: I8d34d2b9c43ea54e5474cbddcde0048658cbb891
Signed-off-by: xiacong <xiacong4@huawei.com>
2022-09-26 17:29:08 +08:00
zhangdengyu
8dbfd3846e fix: 修复告警
Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-26 17:08:56 +08:00
openharmony_ci
f34762c105 !1001 修复函数返回错误等问题
Merge pull request !1001 from zhangdengyu/fix_tsacn
2022-09-25 06:42:18 +00:00
zhangdengyu
043e84dfcb fix:修复函数返回错误等问题
Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-25 10:09:29 +08:00
openharmony_ci
453c376198 !997 Fix : 内核告警清理
Merge pull request !997 from yinjiaming/fix
2022-09-22 11:33:00 +00:00
yinjiaming
204d7a4abb fix: 内核告警清理
【背景】
内核中经扫描有可以修改的告警之处

【修改方案】
优化了代码的格式

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

re #I5SHM2

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I89be86a8317637f9eb54257131712b5b79f1e454
2022-09-22 16:53:11 +08:00
openharmony_ci
f2861a84bf !987 Fix : 内核告警清理
Merge pull request !987 from yinjiaming/fix
2022-09-21 04:42:42 +00:00
yinjiaming
96b2d557ac fix: 内核告警修复
【背景】
经代码扫描工具检测,内核代码中存在
可以修复的告警

【修改方案】
1.将单语句的if, while等加上括号
2.将C语言风格的类型转换变为C++风格

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7d4a04a8904abb3c33e843049bf15f4386d3efd8
2022-09-21 11:38:51 +08:00
openharmony_ci
ffa11535ca !991 【OpenHarmony开源贡献者计划2022】fix warning: expression result unused
Merge pull request !991 from xiwen1225/void
2022-09-19 03:19:16 +00:00
openharmony_ci
b581207045 !992 【OpenHarmony开源贡献者计划2022】fix warning for signal_test_016.cpp
Merge pull request !992 from queuechen/warn
2022-09-19 02:44:00 +00:00
ookami78
5105249ecf fix warning for signal_test_016.cpp
Signed-off-by: ookami78 <ookami78@mymailcr.com>
2022-09-18 14:21:46 +08:00
cunwen
a61e2cf16e fix warning: expression result unused
Signed-off-by: cunwen <cunwen181168@liuxiuhai.cn>
2022-09-18 11:29:44 +08:00
openharmony_ci
39e25c5220 !989 Fix : 修复测试用例返回值问题
Merge pull request !989 from yinjiaming/dev
2022-09-13 12:38:03 +00:00
yinjiaming
5541965365 fix: 修复测试用例中函数返回值的问题
【背景】
测试用例中有函数的返回值不正确

【修改方案】
将返回值为VOID *的函数的返回值改为
retrun NULL

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

re #I5O3LH

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I6d3ce9efbe9afe14b1e9dd12538b80e69928fd71
2022-09-09 15:28:22 +08:00
openharmony_ci
edd2223083 !983 【OpenHarmony开源贡献者计划2022】删除未使用的变量 count
Merge pull request !983 from leijiawei/master
2022-09-06 06:20:52 +00:00
openharmony_ci
22392965b5 !947 Fix : 版权头时间更新
Merge pull request !947 from yinjiaming/dev
2022-09-06 02:55:30 +00:00
yinjiaming
d906bb91ea fix: 版权头时间更新问题
【背景】
一些代码文件经过修改后需要更新版权头

【修改方案】
更新了需要更新的版权头时间

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

re #I5LG22

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7963bf6ce5746707bad688dd4c634ae9d72b3c04
2022-09-05 16:03:30 +08:00
leijiawei
51f6a20723 fix warning:unused variable 'count' & add return value
Signed-off-by: leijiawei <18691361562@163.com>
2022-08-31 15:28:27 +08:00
leibanli
325ea29df3 fix warning:unused variable 'count'
Signed-off-by: leijiawei <18691361562@163.com>
2022-08-31 15:01:32 +08:00
leibanli
c2f9f6705f 【openHarmony开源贡献者计划2022】18691361562@163.com
Signed-off-by: leibanli <18691361562@163.com>
2022-08-30 21:53:58 +08:00
openharmony_ci
71e51d8813 !971 非安全函数告警清理
Merge pull request !971 from xuxinyu/function_s
2022-08-26 04:45:29 +00:00
xuxinyu
e0b4fcb23d test: replace unsecure function with secure function
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ie120ffa529798f0f087ddfcd34f5d9c5802b6766
2022-08-25 23:08:58 +08:00
openharmony_ci
7d62d3d62b !979 style: shell脚本中不同函数使用不同变量
Merge pull request !979 from Hongjin Li/dev
2022-08-25 03:32:45 +00:00
Hongjin Li
69f3bf3a2a style: using different variable in different functions
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I814dcccefcd6248ea32cae94bfde567f3077c7cd
2022-08-25 10:16:45 +08:00
openharmony_ci
2590e34346 !969 编译构建规范优化
Merge pull request !969 from Hongjin Li/dev
2022-08-23 12:55:42 +00:00
Hongjin Li
660b314f90 style: string format in python
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: Ie84a97ca5e0250991aa774b737eb7787e27d80af
2022-08-23 20:22:13 +08:00
235 changed files with 787 additions and 783 deletions

View File

@@ -180,7 +180,8 @@ static void LmsStrcpyTest(void)
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb";
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n",
(int)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;
}
void ShellDeinit(ShellCB *shellCB)
static void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@@ -65,27 +65,23 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
goto OUT;
return ret;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
goto OUT;
return ret;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
goto OUT;
return ret;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@@ -148,7 +144,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
goto ERR_OUT1;
return SH_NOK;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@@ -176,7 +172,9 @@ int main(int argc, char **argv)
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
goto ERR_OUT3;
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
}
ShellEntry(shellCB);

View File

@@ -1437,10 +1437,8 @@ 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-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,
* 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-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,
* 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();
ret = ENOENT;
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
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-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,
* 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 = FR_OK;
FRESULT res;
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,325 +9,34 @@
@@ -9,335 +9,30 @@
* For licensing information, see the file 'LICENCE' in this directory.
*
*/
@@ -2336,32 +2336,35 @@ 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
- return 0;
-}
-const struct file_operations jffs2_file_operations =
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
+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,
@@ -2395,9 +2398,8 @@ 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;
+ /* FIXME: This works only with one file system mounted at a time */
int ret;
- int ret;
-
- jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
- __func__, inode->i_ino, pg->index << PAGE_SHIFT);
-
@@ -2436,18 +2438,15 @@ 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)
@@ -2458,20 +2457,15 @@ 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;
@@ -2482,7 +2476,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_page;
- goto out_err;
-
- mutex_lock(&f->sem);
- memset(&ri, 0, sizeof(ri));
@@ -2512,7 +2506,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_page;
- goto out_err;
- }
- ret = jffs2_add_full_dnode_to_inode(c, f, fn);
- if (f->metadata) {
@@ -2527,7 +2521,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_page;
- goto out_err;
- }
- jffs2_complete_reservation(c);
- inode->i_size = pageofs;
@@ -2535,6 +2529,19 @@ 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.
@@ -2543,19 +2550,20 @@ 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)
- goto out_page;
- if (ret) {
- unlock_page(pg);
- put_page(pg);
- goto release_sem;
- }
- }
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
- return ret;
-
-out_page:
- unlock_page(pg);
- put_page(pg);
-release_sem:
- mutex_unlock(&c->alloc_sem);
-out_err:
- 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)
@@ -2653,7 +2661,8 @@ 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,7 +780,6 @@ 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,8 +62,9 @@ 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);
}
@@ -387,8 +388,9 @@ 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-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,
* 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) {
MergeSyncBlocks(bc, prefer);
if (prefer->used) { /* do not combine with next check */
MergeSyncBlocks(bc, prefer); /* prefer->used may be changed here */
}
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 **vnode);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode);
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-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,
* 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(struct Vnode *dev)
static struct Mount* GetDevMountPoint(const 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(struct Mount *mnt)
static void FileDisableAndClean(const 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(struct Mount *mount)
static void VnodeTryFreeAll(const 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-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,
* 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-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,
* are permitted provided that the following conditions are met:

View File

@@ -66,7 +66,6 @@ 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-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,
* 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 */
data = (argc >= 6) ? (char *)argv[5] : NULL; /* 5: usr option data, 6: six args needed for 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 */
data = (argc >= 5) ? (char *)argv[4] : NULL; /* 4: usr option data, 5: number of args needed for data */
if (strcmp(argv[0], "0") == 0) {
ret = mount((const char *)NULL, fullpath, argv[2], mountfalgs, data);
@@ -761,11 +761,6 @@ 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

@@ -583,7 +583,7 @@ STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
{
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[ArchCurrCpuid()].swtmrSortLink;
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
return TRUE;
}

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(LosVmSpace *space);
LosProcessCB *OsGetPIDByAspace(const 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(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const 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, LosVmMapRegion *region, int off, int len);
VOID OsMarkPageDirty(LosFilePage *fpage, const 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(LosRwlock *rwlock)
STATIC UINT32 OsRwlockCheck(const LosRwlock *rwlock)
{
if (rwlock == NULL) {
return LOS_EINVAL;

View File

@@ -78,7 +78,6 @@ 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(VOID *pool)
STATIC UINT32 OsMemPoolDelete(const 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 = LOCKDEP_SUCCESS;
enum LockDepErrType checkResult;
VOID *requestAddr = (VOID *)__builtin_return_address(1);
LosTaskCB *current = OsCurrTaskGet();
LosTaskCB *owner = NULL;

View File

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

View File

@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
page->n_maps++;
}
LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr)
{
LosMapInfo *info = NULL;
LOS_DL_LIST *immap = &page->i_mmap;
const 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, LosVmMapRegion *region, INT32 off, INT32 len)
VOID OsMarkPageDirty(LosFilePage *fpage, const 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(LosVmSpace *vmSpace)
STATIC BOOL OsVmSpaceParamCheck(const 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);
(VOID)fops->write(filep, "\b \b", 3); // 3: length of "\b \b"
} else {
(VOID)fops->write(filep, &ch, EACH_CHAR);
}
@@ -709,7 +709,6 @@ 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
@@ -730,7 +729,6 @@ STATIC ssize_t DoWrite(CirBufSendCB *cirBufSendCB, CHAR *buffer, size_t bufLen)
if (cnt <= 0) {
break;
}
toWrite -= cnt;
written += cnt;
}
LOS_SpinUnlockRestore(&g_consoleWriteSpinLock, intSave);
@@ -1536,7 +1534,15 @@ 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,7 +87,6 @@ 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 = -LOS_NOK;
INT32 ret;
INT32 procFd;
procFd = AllocProcessFd();

View File

@@ -233,14 +233,8 @@ static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
{
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;
}
struct timespec now = {0};
(void)clock_gettime(CLOCK_REALTIME, &now);
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;
char shadowValueMask;
char shadowValue;
unsigned char shadowValueMask;
unsigned 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 | %2d]: ", shadowAddr, shadowOffset);
LMS_OUTPUT_INFO("|\t[0x%x | %2u]: ", 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 : %d] Shadow memory value: [%d] \n", info->shadowAddr,
LMS_OUTPUT_INFO("Shadow memory address: [0x%x : %u] Shadow memory value: [%u] \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, UINT32 *ids, UINT8 idsNr)
STATIC INLINE BOOL OsFilterId(UINT32 id, const 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, LosPmDevice *device)
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, const 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-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,
* 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-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,
* 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-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,
* 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,7 +356,8 @@ 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;
@@ -2174,8 +2175,6 @@ 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);
@@ -3019,8 +3018,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 */
#endif
break;
#endif
case NETCONN_UDP:
retVal = netstat_udp_sendq(conn->pcb.udp);
break;
@@ -3169,7 +3168,6 @@ void netstat_internal(void *ctx)
}
/* For listen PCBs */
recvQlen = 0;
sendQlen = 0;
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
@@ -3669,7 +3667,7 @@ u32_t netdebug_sock(int argc, const char **argv)
int idx;
u32_t ret = LOS_NOK;
if (argc == 2) {
if (argc == 2) { /* 2: Number of command parameters */
if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */
for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) {
@@ -3677,10 +3675,9 @@ u32_t netdebug_sock(int argc, const char **argv)
}
ret = LOS_OK;
}
} else if (argc == 3) {
} else if (argc == 3) { /* 3: Number of command parameters */
if (!strcmp("-d", argv[1])) {
/* netdebug sock -d <idx> */
idx = atoi(argv[2]);
idx = atoi(argv[2]); /* 2: netdebug sock -d <idx> */
if (idx >= 0) {
debug_socket_info(idx, 1, 1);
ret = LOS_OK;
@@ -3797,8 +3794,9 @@ 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], neighbor_cache[i].lladdr[2],
neighbor_cache[i].lladdr[3], neighbor_cache[i].lladdr[4], neighbor_cache[i].lladdr[5]) < 0) {
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 */
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-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,
* 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-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,
* are permitted provided that the following conditions are met:

View File

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

View File

@@ -1,6 +1,6 @@
/*
* 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,
* 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-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,
* 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 & (1 << j)) == 0) {
num |= 1 << j;
if ((num & (1U << j)) == 0) {
num |= 1U << 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] &= ~(1 << b);
idMap->bitMap[a] &= ~(1U << 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 32
#define INT_BIT_SHIFT 5
#define VID_MAP_MAX_NUM 32
#define INT_BIT_COUNT 32U
#define INT_BIT_SHIFT 5U
#define VID_MAP_MAX_NUM 32U
#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) || (module < MODULE0)) {
if ((*p != 0) || (module > MODULE4)) {
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 = 0;
INT32 n;
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 = 0;
UINT32 writeLen;
UINT32 bufSize = g_logBufSize;
UINT32 logSize = g_dmesgInfo->logSize;
UINT32 tail = g_dmesgInfo->logTail;

View File

@@ -83,6 +83,10 @@ 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;
struct itimerval sovalue = { 0 };
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;
struct itimerval svalue = { 0 };
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;
struct itimerspec svalue = { 0 };
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;
struct itimerspec soldValue = { 0 };
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;
struct timespec stp = { 0 };
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;
struct timespec stp = { 0 };
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;
struct timespec srmtp = { 0 };
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;
struct tms sbuf = { 0 };
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;
struct timespec64 stp = { 0 };
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;
struct timespec64 stp = { 0 };
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;
struct itimerspec64 svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -584,6 +584,7 @@ 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,8 +48,9 @@ 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,8 +39,9 @@ extern "C" {
static UINT32 TaskF02(VOID)
{
UINT32 ret, cpupUse;
UINT32 ret = OS_ERROR, 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,9 +39,10 @@ extern "C" {
static UINT32 TaskF01(VOID)
{
UINT32 ret;
UINT32 ret = OS_ERROR;
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,8 +105,9 @@ 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,8 +75,9 @@ 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,8 +80,9 @@ 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,8 +87,9 @@ 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,8 +76,9 @@ 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,8 +79,9 @@ 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,8 +75,9 @@ 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,8 +114,9 @@ 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,8 +115,9 @@ 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,8 +58,9 @@ 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,8 +77,9 @@ 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,8 +76,9 @@ 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,8 +51,9 @@ 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();
@@ -73,8 +74,9 @@ 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,8 +48,9 @@ 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();
@@ -69,8 +70,9 @@ 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,8 +48,9 @@ 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,8 +71,9 @@ 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,8 +48,9 @@ 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,8 +72,9 @@ 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,10 +202,11 @@ 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,8 +315,9 @@ 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 = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
func = reinterpret_cast<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 = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
func = reinterpret_cast<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;
*test = 0x1; // Deliberately trigger an exceptioin
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;
*test = 0x1; // Deliberately trigger an exceptioin
exit(0);
}

View File

@@ -35,18 +35,17 @@
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;
*test = 0x1; // Deliberately trigger an exceptioin
while (1) {
}
}
*test = 0x1;
*test = 0x1; // Deliberately trigger an exceptioin
ret = waitpid(pid, NULL, 0);
ICUNIT_ASSERT_EQUAL(ret, pid, ret);
@@ -56,7 +55,6 @@ 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 = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
pnew = static_cast<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, (void *)0, 0);
shm = shmat(shmid, nullptr, 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-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,
* are permitted provided that the following conditions are met:
@@ -31,39 +31,46 @@
#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;
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
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
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, 0777 | IPC_CREAT);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | 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 < SHMID_MAX; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
for (i = 0; i < leftShmIds; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
}
shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[SHMID_MAX], -1, shmid[SHMID_MAX]);
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]);
for (i = 0; i < SHMID_MAX; i++) {
for (i = 0; i < leftShmIds; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
}
for (i = 0; i < SHMID_MAX; i++) {
for (i = 0; i < leftShmIds; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
}

View File

@@ -55,7 +55,6 @@ 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);
@@ -70,7 +69,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);
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT); // 128: expected value of shmseg
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, (const void *)0x100, 0);
shm = shmat(shmid, reinterpret_cast<const void *>(0x100), 0);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shm, (void *)-1, shm);
ICUNIT_ASSERT_NOT_EQUAL(shm, reinterpret_cast<void *>(-1), shm);
ret = shmdt((const void *)0x100);
ret = shmdt(reinterpret_cast<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, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<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, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<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 = (char *)shmat(shmid, 0, 0)) == (void *)-1) {
if ((shared = static_cast<char *>(shmat(shmid, 0, 0))) == reinterpret_cast<void *>(-1)) {
printf("child : error: shmat()\n");
exit(1);
}
@@ -72,8 +72,8 @@ static int Testcase(void)
pid = ret;
usleep(50000);
shared = (char *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
shared = static_cast<char *>(shmat(shmid, 0, 0));
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<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, (void *)-1, shared);
ICUNIT_ASSERT_EQUAL(shared, reinterpret_cast<void *>(-1), shared);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
shared = shmat(shmid, 0, SHM_RDONLY);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<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 = (void *)signal(SIGTERM, ExitChildren);
void *ptr = reinterpret_cast<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, (int *)-1, g_shmptr);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, reinterpret_cast<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 = (char*)malloc(pageSize);
writebuf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize);
readbuf = static_cast<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 = (char*)malloc(pageSize);
writebuf = static_cast<char *>(malloc(pageSize));
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize);
readbuf = static_cast<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 == (int *)-1) {
if (shared == reinterpret_cast<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, (int *)-1, shared);
ICUNIT_ASSERT_NOT_EQUAL(shared, reinterpret_cast<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 = (char *)malloc(pageSize);
buf = static_cast<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 = (void *)(VALIDE_ADDR | ADDR_OFFSET);
invalueAddr = reinterpret_cast<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,24 +40,26 @@ static int Testcase(void)
const char *str = "Hi, OHOS.";
/* sigprocmask 内核系统调用接口通过arch_copy_from_user拷贝用户参数 */
ret = sigprocmask(SIG_BLOCK, (sigset_t *)1, &oldset);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(1), &oldset);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, &oldset);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<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, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)1);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR), reinterpret_cast<sigset_t *>(1));
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)INVALID_USER_VADDR);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(INVALID_USER_VADDR));
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)str);
ret = sigprocmask(SIG_BLOCK, reinterpret_cast<sigset_t *>(INVALID_USER_VADDR),
reinterpret_cast<sigset_t *>(const_cast<char *>(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 = (char *)malloc(MOUSE_DATA_LEN);
buf = static_cast<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 = (char *)malloc(STORAGE_DATA_LEN);
buf = static_cast<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,26 +62,24 @@ 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((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);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
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);
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);
retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4095, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<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);
ret = write(fd, buf, 10); // 10: size of buf
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
/* before set cms, testing ioctl cmd */
@@ -96,7 +94,7 @@ static int LiteIpcTest(void)
sleep(2);
/* after set cms, testing set cms cmd */
ret = ioctl(fd, IPC_SET_CMS, 200);
ret = ioctl(fd, IPC_SET_CMS, 200); // 200: use 200 for set cms cmd testing
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
exit(0);
@@ -121,7 +119,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((int)(intptr_t)retptr, -1, retptr);
ICUNIT_ASSERT_NOT_EQUAL(static_cast<int>(static_cast<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);

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