From 814b646d17fb3219b2b832be9d5df676a881614e Mon Sep 17 00:00:00 2001 From: zhiweih Date: Mon, 27 Jul 2020 23:09:26 +0800 Subject: Specify date string length in FINSH date command. libc ctime returns a fixed 25 character string without a NULL terminator. Print it without specifying length in FINSH date command prints extra contents and could potentially be dangerous. --- components/drivers/rtc/rtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components') diff --git a/components/drivers/rtc/rtc.c b/components/drivers/rtc/rtc.c index e17c0fe7dd..682515ce98 100644 --- a/components/drivers/rtc/rtc.c +++ b/components/drivers/rtc/rtc.c @@ -179,7 +179,7 @@ void list_date(void) time_t now; now = time(RT_NULL); - rt_kprintf("%s\n", ctime(&now)); + rt_kprintf("%.*s\n", 25, ctime(&now)); } FINSH_FUNCTION_EXPORT(list_date, show date and time.) @@ -194,7 +194,7 @@ static void date(uint8_t argc, char **argv) time_t now; /* output current time */ now = time(RT_NULL); - rt_kprintf("%s", ctime(&now)); + rt_kprintf("%.*s", 25, ctime(&now)); } else if (argc >= 7) { -- cgit v1.3.1 From b2a9b8308e45364dda9b288af4c754db724683ed Mon Sep 17 00:00:00 2001 From: tangweikang Date: Tue, 4 Aug 2020 11:01:22 +0800 Subject: [components][usb] word error : PROERTY -> PROPERTY --- components/drivers/include/drivers/usb_common.h | 18 +++++++++--------- components/drivers/usb/usbdevice/class/winusb.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'components') diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index c26d83391e..4d85a85e35 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -435,15 +435,15 @@ typedef struct usb_os_proerty * usb_os_proerty_t; // 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN) // 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK) // 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ) -#define USB_OS_PROERTY_TYPE_REG_SZ 0x01UL -#define USB_OS_PROERTY_TYPE_REG_EXPAND_SZ 0x02UL -#define USB_OS_PROERTY_TYPE_REG_BINARY 0x03UL -#define USB_OS_PROERTY_TYPE_REG_DWORD_LITTLE_ENDIAN 0x04UL -#define USB_OS_PROERTY_TYPE_REG_DWORD_BIG_ENDIAN 0x05UL -#define USB_OS_PROERTY_TYPE_REG_LINK 0x06UL -#define USB_OS_PROERTY_TYPE_REG_MULTI_SZ 0x07UL - -#define USB_OS_PROERTY_DESC(PropertyDataType,PropertyName,PropertyData) \ +#define USB_OS_PROPERTY_TYPE_REG_SZ 0x01UL +#define USB_OS_PROPERTY_TYPE_REG_EXPAND_SZ 0x02UL +#define USB_OS_PROPERTY_TYPE_REG_BINARY 0x03UL +#define USB_OS_PROPERTY_TYPE_REG_DWORD_LITTLE_ENDIAN 0x04UL +#define USB_OS_PROPERTY_TYPE_REG_DWORD_BIG_ENDIAN 0x05UL +#define USB_OS_PROPERTY_TYPE_REG_LINK 0x06UL +#define USB_OS_PROPERTY_TYPE_REG_MULTI_SZ 0x07UL + +#define USB_OS_PROPERTY_DESC(PropertyDataType,PropertyName,PropertyData) \ {\ .dwSize = sizeof(struct usb_os_proerty)-sizeof(const char *)*2\ +sizeof(PropertyName)*2+sizeof(PropertyData)*2,\ diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index bf4b353d73..729e39f663 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -121,7 +121,7 @@ const static char* _ustring[] = ALIGN(4) struct usb_os_proerty winusb_proerty[] = { - USB_OS_PROERTY_DESC(USB_OS_PROERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID), + USB_OS_PROPERTY_DESC(USB_OS_PROPERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID), }; ALIGN(4) -- cgit v1.3.1 From ba5f2a5bb63950a9360de6910d4c07f4fa80a3fb Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Tue, 4 Aug 2020 15:10:43 +0800 Subject: Update Kconfig Change I2C configuration hierarchy --- components/drivers/Kconfig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'components') diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 4ebde15125..6dffd9d5ea 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -95,12 +95,11 @@ if RT_USING_I2C config RT_USING_I2C_BITOPS bool "Use GPIO to simulate I2C" default y -endif - -if RT_USING_I2C_BITOPS - config RT_I2C_BITOPS_DEBUG - bool "Use simulate I2C debug message" - default n + if RT_USING_I2C_BITOPS + config RT_I2C_BITOPS_DEBUG + bool "Use simulate I2C debug message" + default n + endif endif config RT_USING_PIN -- cgit v1.3.1 From 719b71a0155cc5053a238ca004d8c8ff73a5a989 Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Tue, 4 Aug 2020 15:11:48 +0800 Subject: Update Kconfig --- components/drivers/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'components') diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 6dffd9d5ea..471f68054f 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -95,6 +95,7 @@ if RT_USING_I2C config RT_USING_I2C_BITOPS bool "Use GPIO to simulate I2C" default y + if RT_USING_I2C_BITOPS config RT_I2C_BITOPS_DEBUG bool "Use simulate I2C debug message" -- cgit v1.3.1 From f7ba4a63413cf6a0d64ea03f7cb63eb58d1ad099 Mon Sep 17 00:00:00 2001 From: Meco <920369182@qq.com> Date: Wed, 5 Aug 2020 02:47:27 +0800 Subject: 增加条件编译,防止RT_USING_DFS没有定义时 _sys_flen()出现编译警告:stat变量定义但没有被调用 的问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/armlibc/stubs.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'components') diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c index b6ffb37b0f..8acde16495 100644 --- a/components/libc/compilers/armlibc/stubs.c +++ b/components/libc/compilers/armlibc/stubs.c @@ -9,6 +9,8 @@ * 2013-11-24 aozima fixed _sys_read()/_sys_write() issues. * 2014-08-03 bernard If using msh, use system() implementation * in msh. + * 2020-08-05 Meco Man fixed _sys_flen() compiling-warning when + * RT_USING_DFS is not defined */ #include @@ -265,7 +267,9 @@ RT_WEAK void _sys_exit(int return_code) */ long _sys_flen(FILEHANDLE fh) { +#ifdef RT_USING_DFS struct stat stat; +#endif if (fh < STDERR) return -1; -- cgit v1.3.1 From 576475f14f66e3bc73fcef434ca51bb37420d49d Mon Sep 17 00:00:00 2001 From: Meco <920369182@qq.com> Date: Wed, 5 Aug 2020 09:28:10 +0800 Subject: change format --- components/libc/compilers/armlibc/stubs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'components') diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c index 8acde16495..b4cc13799e 100644 --- a/components/libc/compilers/armlibc/stubs.c +++ b/components/libc/compilers/armlibc/stubs.c @@ -269,16 +269,14 @@ long _sys_flen(FILEHANDLE fh) { #ifdef RT_USING_DFS struct stat stat; -#endif - + if (fh < STDERR) return -1; -#ifndef RT_USING_DFS - return -1; -#else fstat(fh, &stat); return stat.st_size; +#else + return -1; #endif } -- cgit v1.3.1 From 27a6ebf4b1f5be57661c7c6152ec3efc96a14855 Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Wed, 5 Aug 2020 10:06:20 +0800 Subject: Update Kconfig --- components/drivers/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'components') diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig index 471f68054f..457b8751fe 100755 --- a/components/drivers/Kconfig +++ b/components/drivers/Kconfig @@ -97,10 +97,10 @@ if RT_USING_I2C default y if RT_USING_I2C_BITOPS - config RT_I2C_BITOPS_DEBUG - bool "Use simulate I2C debug message" - default n - endif + config RT_I2C_BITOPS_DEBUG + bool "Use simulate I2C debug message" + default n + endif endif config RT_USING_PIN -- cgit v1.3.1 From ad3e6d889854f646fcfb1abc618d5fa3e1140b4e Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 7 Aug 2020 08:51:22 +0800 Subject: [DFS] clean the unnecessary checking --- components/dfs/src/dfs_fs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'components') diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 476e47fc06..c21b914727 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -129,7 +129,7 @@ const char *dfs_filesystem_get_mounted_path(struct rt_device *device) for (iter = &filesystem_table[0]; iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) { - /* fint the mounted device */ + /* find the mounted device */ if (iter->ops == NULL) continue; else if (iter->dev_id == device) { @@ -321,7 +321,7 @@ int dfs_mount(const char *device_name, if (rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR) != RT_EOK) { - /* The underlaying device has error, clear the entry. */ + /* The underlying device has error, clear the entry. */ dfs_lock(); memset(fs, 0, sizeof(struct dfs_filesystem)); @@ -568,8 +568,7 @@ int dfs_unmount_device(rt_device_t dev) iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) { /* check if the PATH is mounted */ - if ((iter->dev_id->parent.name != NULL) - && (strcmp(iter->dev_id->parent.name, dev->parent.name) == 0)) + if (strcmp(iter->dev_id->parent.name, dev->parent.name) == 0) { fs = iter; break; -- cgit v1.3.1