【背景】内源代码检视问题
【修改方案】 1,按检视意见,进行资源泄露等问题的修改 【影响】 对现有的产品编译不会有影响。 re #I4WV56 Signed-off-by: wangchen <wangchen64@huawei.com>
This commit is contained in:
@@ -82,16 +82,21 @@ static int TestCase(void)
|
||||
printf("fd=%d\n", fd);
|
||||
if (fd == -1) {
|
||||
perror("openls");
|
||||
munmap(p, st.st_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = read(fd, p, st.st_size);
|
||||
if (rc == -1) {
|
||||
perror("read");
|
||||
munmap(p, st.st_size);
|
||||
close(shmFd);
|
||||
return -1;
|
||||
}
|
||||
if (rc != st.st_size) {
|
||||
fputs("Strange situation!\n", stderr);
|
||||
munmap(p, st.st_size);
|
||||
close(shmFd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ static int testcase(void)
|
||||
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
|
||||
|
||||
writebuf = (char*)malloc(pageSize);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
|
||||
readbuf = (char*)malloc(pageSize);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
|
||||
|
||||
memset_s(writebuf, pageSize, 0xf, pageSize);
|
||||
|
||||
count = write(shmfd, writebuf, pageSize);
|
||||
|
||||
@@ -460,6 +460,7 @@ int RemoveDir(const char *dir)
|
||||
ret = sprintf_s(dir_name, sizeof(dir_name), "%s/%s", dir, dp->d_name);
|
||||
if (ret < 0) {
|
||||
perror("sprintf dir_name error");
|
||||
closedir(dirp);
|
||||
return -1;
|
||||
}
|
||||
RemoveDir(dir_name);
|
||||
|
||||
@@ -55,8 +55,6 @@ static int TestCase(void)
|
||||
ret = unlinkat(dirFd, FILEPATH, AT_REMOVEDIR);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
|
||||
|
||||
return JFFS_NO_ERROR;
|
||||
|
||||
EXIT1:
|
||||
close(fd);
|
||||
unlink(DIRPATH);
|
||||
|
||||
@@ -353,7 +353,7 @@ INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceT
|
||||
gettimeofday(&testTime2, 0);
|
||||
perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
|
||||
|
||||
printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, MSECS_PER_SEC / MSECS_PER_SEC);
|
||||
printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, (perTime / USECS_PER_SEC) * MSECS_PER_SEC);
|
||||
|
||||
free(writeBuf);
|
||||
|
||||
@@ -1000,7 +1000,7 @@ public:
|
||||
};
|
||||
#if defined(LOSCFG_USER_TEST_FULL)
|
||||
/* *
|
||||
* @tc.name: IO_TEST_FACCESSAT_001
|
||||
* @tc.name: IO_TEST_FACCESSAT_001
|
||||
* @tc.desc: normal tests for faccessat
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
|
||||
@@ -35,6 +35,7 @@ static UINT32 testcase(VOID)
|
||||
struct mntent* mnt = nullptr;
|
||||
struct mntent* mnt_new = nullptr;
|
||||
FILE *fp = nullptr;
|
||||
FILE *fp2 = nullptr;
|
||||
char *argv[2] = {nullptr};
|
||||
argv[0] = "/etc/fstab";
|
||||
argv[1] = "errors";
|
||||
@@ -45,14 +46,14 @@ static UINT32 testcase(VOID)
|
||||
char *pathList[] = {"/etc/fstab"};
|
||||
char *streamList[] = {(char *)fileWords};
|
||||
int streamLen[] = {sizeof(fileWords)};
|
||||
|
||||
|
||||
int flag = PrepareFileEnv(pathList, streamList, streamLen, 1);
|
||||
if (flag != 0) {
|
||||
printf("error: need some env file, but prepare is not ok");
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
mnt_new = (struct mntent *)malloc(sizeof(struct mntent));
|
||||
mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x";
|
||||
mnt_new->mnt_dir = "/usr1";
|
||||
@@ -64,6 +65,7 @@ static UINT32 testcase(VOID)
|
||||
fp = setmntent("/etc/fstab", "r");
|
||||
if (!fp) {
|
||||
printf("fp=0x%x\n", fp);
|
||||
free(mnt_new);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
@@ -81,7 +83,8 @@ static UINT32 testcase(VOID)
|
||||
|
||||
/* test the addmntent below */
|
||||
fp = setmntent(argv[0], "a");
|
||||
if (fopen("/lib/libc.so", "r")) {
|
||||
fp2 = fopen("/lib/libc.so", "r");
|
||||
if (fp2 != NULL) {
|
||||
printf("aha I found you are OHOS!!!\n");
|
||||
if (addmntent(fp, mnt_new)) {
|
||||
printf("a new mnt is added to %s\n", argv[0]);
|
||||
@@ -91,6 +94,9 @@ static UINT32 testcase(VOID)
|
||||
if (fp != NULL) {
|
||||
endmntent(fp);
|
||||
}
|
||||
if (fp2 != NULL) {
|
||||
fclose(fp2);
|
||||
}
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ static int TestCase(void)
|
||||
{
|
||||
char *name = getlogin();
|
||||
ICUNIT_ASSERT_NOT_EQUAL(name, "USER1", NULL);
|
||||
int ret = getlogin_r(name, sizeof(name));
|
||||
int ret = getlogin_r(name, strlen(name) + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 6, ret);
|
||||
ret = setenv("LOGNAME", "USER1", 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
@@ -39,7 +39,10 @@ struct q {
|
||||
static struct q *New(int i)
|
||||
{
|
||||
struct q *q = (struct q *)malloc(sizeof *q);
|
||||
q->i = i;
|
||||
if (q != NULL) {
|
||||
q->i = i;
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,17 +76,6 @@ HWTEST_F(TimeTimerTest, TimerTest003, TestSize.Level0)
|
||||
TimerTest003();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: TimerTest004
|
||||
* @tc.desc: function for TimeTimerTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
/*HWTEST_F(TimeTimerTest, TimerTest004, TestSize.Level0)
|
||||
{
|
||||
TimerTest004(); // TODO: musl sigaction handler have only one param.
|
||||
}*/
|
||||
|
||||
/* *
|
||||
* @tc.name: TimerTest005
|
||||
* @tc.desc: function for timer_create SIGEV_THREAD.
|
||||
|
||||
Reference in New Issue
Block a user