summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-01-07 18:05:42 +0800
committerGitHub <[email protected]>2019-01-07 18:05:42 +0800
commit3dd0ebe6e7d8d0ad7605269ef8fffd66a8029931 (patch)
tree061872604b61531dc3faaf9e42e3634ff61ce7c5 /components
parentd113eb07f5157696275a508f991e1b837a1506f7 (diff)
parent18dfb50e9b9469b2e36e7fa9ee9abf5d48108dbb (diff)
Merge pull request #2158 from armink/lts-v3.1.x
Lts v3.1.x
Diffstat (limited to 'components')
-rw-r--r--components/dfs/src/dfs.c9
-rw-r--r--components/libc/compilers/armlibc/stubs.c5
-rw-r--r--components/libc/compilers/newlib/syscalls.c4
-rw-r--r--components/net/at/at_socket/at_socket.c40
-rw-r--r--components/utilities/ulog/backend/console_be.c3
-rw-r--r--components/utilities/ulog/ulog.c2
6 files changed, 45 insertions, 18 deletions
diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c
index cf0b2b0ef9..12ae8e9d95 100644
--- a/components/dfs/src/dfs.c
+++ b/components/dfs/src/dfs.c
@@ -18,6 +18,10 @@
#include <lwp.h>
#endif
+#ifdef RT_USING_DFS_DEVFS
+#include <libc.h>
+#endif
+
/* Global variables */
const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX];
struct dfs_filesystem filesystem_table[DFS_FILESYSTEMS_MAX];
@@ -212,6 +216,11 @@ struct dfs_fd *fd_get(int fd)
struct dfs_fd *d;
struct dfs_fdtable *fdt;
+#ifdef RT_USING_DFS_DEVFS
+ if ((0 <= fd) && (fd <= 2))
+ fd = libc_stdio_get_console();
+#endif
+
fdt = dfs_fdtable_get();
fd = fd - DFS_FD_OFFSET;
if (fd < 0 || fd >= fdt->maxfd)
diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c
index 6e9f13d143..820daeff39 100644
--- a/components/libc/compilers/armlibc/stubs.c
+++ b/components/libc/compilers/armlibc/stubs.c
@@ -270,7 +270,10 @@ long _sys_flen(FILEHANDLE fh)
int _sys_istty(FILEHANDLE fh)
{
- return 0;
+ if((STDIN <= fh) && (fh <= STDERR))
+ return 1;
+ else
+ return 0;
}
int remove(const char *filename)
diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c
index e4cda478cb..759feafe67 100644
--- a/components/libc/compilers/newlib/syscalls.c
+++ b/components/libc/compilers/newlib/syscalls.c
@@ -9,6 +9,8 @@
#include <reent.h>
#include <sys/errno.h>
#include <sys/time.h>
+#include <stdio.h>
+
#include <rtthread.h>
#ifdef RT_USING_DFS
@@ -218,7 +220,7 @@ _ssize_t
_write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
{
#ifndef RT_USING_DFS
- if (fd == 0)
+ if (fileno(stdout) == fd)
{
rt_device_t console;
diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c
index 3925f0f57c..cccb35ae1a 100644
--- a/components/net/at/at_socket/at_socket.c
+++ b/components/net/at/at_socket/at_socket.c
@@ -572,10 +572,16 @@ __exit:
if (result < 0)
{
- at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
+ if (sock != RT_NULL)
+ {
+ at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
+ }
}
- at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
+ if (sock)
+ {
+ at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
+ }
return result;
}
@@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit:
- if (recv_len > 0)
+ if (sock != RT_NULL)
{
- result = recv_len;
- at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
- errno = 0;
- if (!rt_slist_isempty(&sock->recvpkt_list))
+ if (recv_len > 0)
{
- at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
+ result = recv_len;
+ at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
+ errno = 0;
+ if (!rt_slist_isempty(&sock->recvpkt_list))
+ {
+ at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
+ }
+ else
+ {
+ at_do_event_clean(sock, AT_EVENT_RECV);
+ }
}
else
{
- at_do_event_clean(sock, AT_EVENT_RECV);
+ at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
- else
- {
- at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
- }
return result;
}
@@ -807,7 +816,10 @@ __exit:
if (result < 0)
{
- at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
+ if (sock != RT_NULL)
+ {
+ at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
+ }
}
else
{
diff --git a/components/utilities/ulog/backend/console_be.c b/components/utilities/ulog/backend/console_be.c
index b2ed3d565d..04b0d91add 100644
--- a/components/utilities/ulog/backend/console_be.c
+++ b/components/utilities/ulog/backend/console_be.c
@@ -45,12 +45,13 @@ void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level
int ulog_console_backend_init(void)
{
+ ulog_init();
console.output = ulog_console_backend_output;
ulog_backend_register(&console, "console", RT_TRUE);
return 0;
}
-INIT_COMPONENT_EXPORT(ulog_console_backend_init);
+INIT_PREV_EXPORT(ulog_console_backend_init);
#endif /* ULOG_BACKEND_USING_CONSOLE */
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c
index 186154c7c9..b813678ecd 100644
--- a/components/utilities/ulog/ulog.c
+++ b/components/utilities/ulog/ulog.c
@@ -149,7 +149,7 @@ size_t ulog_strcpy(size_t cur_len, char *dst, const char *src)
while (*src != 0)
{
/* make sure destination has enough space */
- if (cur_len++ <= ULOG_LINE_BUF_SIZE)
+ if (cur_len++ < ULOG_LINE_BUF_SIZE)
{
*dst++ = *src++;
}