summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLostCivilization <[email protected]>2023-05-01 12:45:16 +0800
committerGitHub <[email protected]>2023-05-01 00:45:16 -0400
commit9a432c7413501a1158df9b7e2ce5a664cdff066a (patch)
tree826356e284d88b7db9ab117fb10059ab8918f41a /examples
parent106f635552923632f8d1ab67c0ddafd2496f4289 (diff)
[HUST CSE][utest] fix the NULL pointer error
Diffstat (limited to 'examples')
-rw-r--r--examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c b/examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
index b3dfd092f7..3eaac44c65 100644
--- a/examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
+++ b/examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
@@ -24,13 +24,16 @@ static int chdir_entry(void)
printf("error\n");
}
ptr = getcwd(buf, size);
- printf("ptr %s\n",ptr);
-
+
if (ptr == NULL)
{
printf("error\n");
}
- printf("old curr dir is %s\n", ptr);
+ else
+ {
+ printf("ptr %s\n",ptr);
+ printf("old curr dir is %s\n", ptr);
+ }
mkdir(NEW_CURR_DIR, 0x777);
chdir(NEW_CURR_DIR);
@@ -40,7 +43,11 @@ static int chdir_entry(void)
{
printf("error\n");
}
- printf("new curr dir is %s\n", ptr);
+ else
+ {
+ printf("new curr dir is %s\n", ptr);
+ }
+
}
free(buf);
return 0;