summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c2
-rw-r--r--components/dfs/filesystems/nfs/dfs_nfs.c2
-rw-r--r--components/dfs/filesystems/romfs/dfs_romfs.c2
-rw-r--r--components/drivers/spi/sfud/src/sfud.c2
-rw-r--r--components/drivers/src/pipe.c12
-rw-r--r--components/finsh/shell.c2
-rw-r--r--components/libc/compilers/common/time.c9
-rw-r--r--components/libc/pthreads/pthread.c21
-rw-r--r--components/net/lwip-2.0.2/src/apps/tftp/tftp_port.c18
-rw-r--r--components/net/lwip-2.1.2/src/apps/tftp/tftp_port.c18
10 files changed, 43 insertions, 45 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index 07b8f62fed..41f99d7b62 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -647,7 +647,7 @@ int dfs_elm_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = (rt_uint8_t)rt_strlen(fn);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
- rt_strncpy(d->d_name, fn, rt_strlen(fn) + 1);
+ rt_strncpy(d->d_name, fn, DFS_PATH_MAX);
index ++;
if (index * sizeof(struct dirent) >= count)
diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c
index e7ad488f7d..284d8d42af 100644
--- a/components/dfs/filesystems/nfs/dfs_nfs.c
+++ b/components/dfs/filesystems/nfs/dfs_nfs.c
@@ -1119,7 +1119,7 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = rt_strlen(name);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
- rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
+ rt_strncpy(d->d_name, name, DFS_PATH_MAX);
index ++;
if (index * sizeof(struct dirent) >= count)
diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c
index 1b2693fc3b..2e9b08cbf6 100644
--- a/components/dfs/filesystems/romfs/dfs_romfs.c
+++ b/components/dfs/filesystems/romfs/dfs_romfs.c
@@ -276,7 +276,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = rt_strlen(name);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
- rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
+ rt_strncpy(d->d_name, name, DFS_PATH_MAX);
/* move to next position */
++ file->pos;
diff --git a/components/drivers/spi/sfud/src/sfud.c b/components/drivers/spi/sfud/src/sfud.c
index e5b03131ff..4078179262 100644
--- a/components/drivers/spi/sfud/src/sfud.c
+++ b/components/drivers/spi/sfud/src/sfud.c
@@ -218,7 +218,7 @@ sfud_err sfud_qspi_fast_read_enable(sfud_flash *flash, uint8_t data_line_width)
break;
case 2:
if (read_mode & DUAL_IO) {
- qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 8, 2);
+ qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 4, 2);
} else if (read_mode & DUAL_OUTPUT) {
qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_OUTPUT_READ_DATA, 1, 1, 8, 2);
} else {
diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c
index 10b880ff7a..236c1ffec7 100644
--- a/components/drivers/src/pipe.c
+++ b/components/drivers/src/pipe.c
@@ -320,7 +320,7 @@ static const struct dfs_file_ops pipe_fops =
};
#endif /* end of RT_USING_POSIX */
-rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
+rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag)
{
rt_pipe_t *pipe = (rt_pipe_t *)device;
rt_err_t ret = RT_EOK;
@@ -348,7 +348,7 @@ __exit:
return ret;
}
-rt_err_t rt_pipe_close (rt_device_t device)
+rt_err_t rt_pipe_close(rt_device_t device)
{
rt_pipe_t *pipe = (rt_pipe_t *)device;
@@ -366,7 +366,7 @@ rt_err_t rt_pipe_close (rt_device_t device)
return RT_EOK;
}
-rt_size_t rt_pipe_read (rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count)
+rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count)
{
uint8_t *pbuf;
rt_size_t read_bytes = 0;
@@ -394,7 +394,7 @@ rt_size_t rt_pipe_read (rt_device_t device, rt_off_t pos, void *buffer, rt_siz
return read_bytes;
}
-rt_size_t rt_pipe_write (rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count)
+rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count)
{
uint8_t *pbuf;
rt_size_t write_bytes = 0;
@@ -531,8 +531,8 @@ int rt_pipe_delete(const char *name)
int pipe(int fildes[2])
{
rt_pipe_t *pipe;
- char dname[8];
- char dev_name[32];
+ char dname[RT_NAME_MAX];
+ char dev_name[RT_NAME_MAX * 4];
static int pipeno = 0;
rt_snprintf(dname, sizeof(dname), "pipe%d", pipeno++);
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 0d41625184..6f1133bf3b 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -831,7 +831,7 @@ int finsh_system_init(void)
__section_end("FSymTab"));
finsh_system_var_init(__section_begin("VSymTab"),
__section_end("VSymTab"));
-#elif defined (__GNUC__) || defined(__TI_COMPILER_VERSION__)
+#elif defined (__GNUC__) || defined(__TI_COMPILER_VERSION__) || defined(__TASKING__)
/* GNU GCC Compiler and TI CCS */
extern const int __fsymtab_start;
extern const int __fsymtab_end;
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 083ae9be6c..83b6ed5672 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -21,10 +21,15 @@
#include <sys/time.h>
#include <rtthread.h>
+
#ifdef RT_USING_DEVICE
#include <rtdevice.h>
#endif
+#define DBG_TAG "TIME"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
/* seconds per day */
#define SPD 24*60*60
@@ -219,6 +224,7 @@ RT_WEAK time_t time(time_t *t)
if(time_now == (time_t)-1)
{
+ LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
}
@@ -246,12 +252,13 @@ int stime(const time_t *t)
}
else
{
+ LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
return -1;
}
return 0;
-
#else
+ LOG_W("Cannot find a RTC device to provide time!");
errno = ENOSYS;
return -1;
#endif /* RT_USING_RTC */
diff --git a/components/libc/pthreads/pthread.c b/components/libc/pthreads/pthread.c
index 8a728c4e99..79104d1fd5 100644
--- a/components/libc/pthreads/pthread.c
+++ b/components/libc/pthreads/pthread.c
@@ -209,6 +209,8 @@ int pthread_create(pthread_t *pid,
/* get pthread data */
ptd = _pthread_get_data(pth_id);
+ RT_ASSERT(ptd != RT_NULL);
+
if (attr != RT_NULL)
{
ptd->attr = *attr;
@@ -299,6 +301,12 @@ int pthread_detach(pthread_t thread)
{
int ret = 0;
_pthread_data_t *ptd = _pthread_get_data(thread);
+ if (ptd == RT_NULL)
+ {
+ /* invalid pthread id */
+ ret = EINVAL;
+ goto __exit;
+ }
rt_enter_critical();
if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED)
@@ -360,6 +368,12 @@ int pthread_join(pthread_t thread, void **value_ptr)
rt_err_t result;
ptd = _pthread_get_data(thread);
+
+ if (ptd == RT_NULL)
+ {
+ return EINVAL; /* invalid pthread id */
+ }
+
if (ptd && ptd->tid == rt_thread_self())
{
/* join self */
@@ -367,7 +381,9 @@ int pthread_join(pthread_t thread, void **value_ptr)
}
if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED)
+ {
return EINVAL; /* join on a detached pthread */
+ }
result = rt_sem_take(ptd->joinable_sem, RT_WAITING_FOREVER);
if (result == RT_EOK)
@@ -662,7 +678,10 @@ int pthread_cancel(pthread_t thread)
/* get posix thread data */
ptd = _pthread_get_data(thread);
- RT_ASSERT(ptd != RT_NULL);
+ if (ptd == RT_NULL)
+ {
+ return EINVAL;
+ }
/* cancel self */
if (ptd->tid == rt_thread_self())
diff --git a/components/net/lwip-2.0.2/src/apps/tftp/tftp_port.c b/components/net/lwip-2.0.2/src/apps/tftp/tftp_port.c
index 129cc7da17..e14e34cfec 100644
--- a/components/net/lwip-2.0.2/src/apps/tftp/tftp_port.c
+++ b/components/net/lwip-2.0.2/src/apps/tftp/tftp_port.c
@@ -1,21 +1,7 @@
/*
- * File : tftp_port.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/net/lwip-2.1.2/src/apps/tftp/tftp_port.c b/components/net/lwip-2.1.2/src/apps/tftp/tftp_port.c
index 129cc7da17..e14e34cfec 100644
--- a/components/net/lwip-2.1.2/src/apps/tftp/tftp_port.c
+++ b/components/net/lwip-2.1.2/src/apps/tftp/tftp_port.c
@@ -1,21 +1,7 @@
/*
- * File : tftp_port.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes