From 011eb615bc036dececaafbf5d3526c508e0b61e2 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sun, 11 Feb 2018 13:56:30 +0800 Subject: [PATCH 1/4] [Kernel] Correct the comments of DBG_ENABLE macro. --- include/rtdbg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rtdbg.h b/include/rtdbg.h index 637390a1cd..26e289eff6 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -32,15 +32,15 @@ * header file. * * #define DBG_SECTION_NAME "[ MOD]" - * #define DEBUG_ENABLE // enable debug macro - * #define DEBUG_LEVEL DBG_INFO - * #include // must after of DEBUG_ENABLE or some other options + * #define DBG_ENABLE // enable debug macro + * #define DBG_LEVEL DBG_INFO + * #include // must after of DEBUG_ENABLE or some other options * * Then in your C/C++ file, you can use dbg_log macro to print out logs: * dbg_log(DBG_INFO, "this is a log!\n"); * * Or if you want to use different color for different kinds log, you can - * #define DEBUG_COLOR + * #define DBG_COLOR */ #ifndef RT_DBG_H__ From 780c09e3e452568e7befb26c0ffd4ae7f6d1a0cb Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sun, 11 Feb 2018 13:57:51 +0800 Subject: [PATCH 2/4] [libc] Fix the O_CREAT issue. libc_stdio_set_console/newlib uses fopen to open console device, which has O_CREAT flag and cause fault. --- components/dfs/filesystems/devfs/devfs.c | 4 +--- components/libc/compilers/newlib/stdio.c | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 4f2f0ebcd9..4694b96c85 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -19,6 +19,7 @@ * * Change Logs: * Date Author Notes + * 2018-02-11 Bernard Ignore O_CREAT flag in open. */ #include @@ -137,9 +138,6 @@ int dfs_device_fs_open(struct dfs_fd *file) rt_err_t result; rt_device_t device; - if (file->flags & O_CREAT) - return -EINVAL; - /* open root directory */ if ((file->path[0] == '/') && (file->path[1] == '\0') && (file->flags & O_DIRECTORY)) diff --git a/components/libc/compilers/newlib/stdio.c b/components/libc/compilers/newlib/stdio.c index f28383818d..9a225622b5 100644 --- a/components/libc/compilers/newlib/stdio.c +++ b/components/libc/compilers/newlib/stdio.c @@ -81,7 +81,9 @@ int libc_stdio_set_console(const char* device_name, int mode) _GLOBAL_REENT->__sdidinit = 1; } - return fileno(std_console); + if (std_console) return fileno(std_console); + + return -1; } int libc_stdio_get_console(void) { From 3f931c0df4bb38673c9689c6858f6c6bb299e860 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sun, 11 Feb 2018 13:58:03 +0800 Subject: [PATCH 3/4] [C++] Fix the compiling warning issue --- components/cplusplus/Thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/cplusplus/Thread.cpp b/components/cplusplus/Thread.cpp index 4d2d8a59ea..a01bd95e4b 100644 --- a/components/cplusplus/Thread.cpp +++ b/components/cplusplus/Thread.cpp @@ -6,7 +6,7 @@ Thread::Thread(rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick, const char *name) -: _entry(RT_NULL), started(false) +: _entry(RT_NULL), _param(RT_NULL), started(false) { rt_event_init(&_event, name, 0); @@ -24,7 +24,7 @@ Thread::Thread(void (*entry)(void *p), rt_uint8_t priority, rt_uint32_t tick, const char *name) -: _entry(RT_NULL), started(false), _param(p) +: _entry(RT_NULL), _param(p), started(false) { rt_event_init(&_event, name, 0); From 43cc01742fc5cce22ccd2037ba80216c5207fc6a Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sun, 11 Feb 2018 13:58:20 +0800 Subject: [PATCH 4/4] [libc] cleanup code. --- components/libc/compilers/dlib/libc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/libc/compilers/dlib/libc.c b/components/libc/compilers/dlib/libc.c index fe219537e3..fa977ab399 100644 --- a/components/libc/compilers/dlib/libc.c +++ b/components/libc/compilers/dlib/libc.c @@ -36,7 +36,7 @@ int libc_system_init(void) { -#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) +#if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS) rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -50,10 +50,11 @@ int libc_system_init(void) } #endif -#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT +#if defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT) pthread_system_init(); #endif return 0; } INIT_COMPONENT_EXPORT(libc_system_init); +