summaryrefslogtreecommitdiff
path: root/examples/file
diff options
context:
space:
mode:
authorWayne Lin <[email protected]>2021-07-12 18:17:25 +0800
committerWayne Lin <[email protected]>2021-07-12 18:17:25 +0800
commit735285360929c97d49ed51dbc41dfeec570a35b3 (patch)
tree9c1b5303717e80442037fd43f4144ff67c86bc5c /examples/file
parent978ea520d982ede86feee1f5f08b04bddd6efd1e (diff)
parent19f1c82bc8355879d157805748b23e6dabed701d (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread into nuvoton
Diffstat (limited to 'examples/file')
-rw-r--r--examples/file/listdir.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/file/listdir.c b/examples/file/listdir.c
index 98fbc5ea2c..06c746a642 100644
--- a/examples/file/listdir.c
+++ b/examples/file/listdir.c
@@ -13,7 +13,7 @@
void list_dir(const char* path)
{
- char * fullpath;
+ char * fullpath = RT_NULL;
DIR *dir;
dir = opendir(path);
@@ -57,7 +57,10 @@ void list_dir(const char* path)
rt_kprintf("open %s directory failed\n", path);
}
- rt_free(fullpath);
+ if (RT_NULL != fullpath)
+ {
+ rt_free(fullpath);
+ }
}
#ifdef RT_USING_FINSH
@@ -80,6 +83,6 @@ static void cmd_list_dir(int argc, char *argv[])
}
list_dir(filename);
}
-FINSH_FUNCTION_EXPORT_ALIAS(cmd_list_dir, __cmd_list_dir, list directory);
+MSH_CMD_EXPORT_ALIAS(cmd_list_dir, list_dir, list directory);
#endif /* FINSH_USING_MSH */
#endif /* RT_USING_FINSH */