Skip to content

Commit c0f15a5

Browse files
committed
[component] Sync to master (366e28f).
1 parent 1805aad commit c0f15a5

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
lines changed

components/dfs/src/dfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include <lwp.h>
1919
#endif
2020

21+
#ifdef RT_USING_DFS_DEVFS
22+
#include <libc.h>
23+
#endif
24+
2125
/* Global variables */
2226
const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX];
2327
struct dfs_filesystem filesystem_table[DFS_FILESYSTEMS_MAX];
@@ -212,6 +216,11 @@ struct dfs_fd *fd_get(int fd)
212216
struct dfs_fd *d;
213217
struct dfs_fdtable *fdt;
214218

219+
#ifdef RT_USING_DFS_DEVFS
220+
if ((0 <= fd) && (fd <= 2))
221+
fd = libc_stdio_get_console();
222+
#endif
223+
215224
fdt = dfs_fdtable_get();
216225
fd = fd - DFS_FD_OFFSET;
217226
if (fd < 0 || fd >= fdt->maxfd)

components/libc/compilers/armlibc/stubs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ long _sys_flen(FILEHANDLE fh)
270270

271271
int _sys_istty(FILEHANDLE fh)
272272
{
273-
return 0;
273+
if((STDIN <= fh) && (fh <= STDERR))
274+
return 1;
275+
else
276+
return 0;
274277
}
275278

276279
int remove(const char *filename)

components/libc/compilers/newlib/syscalls.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <reent.h>
1010
#include <sys/errno.h>
1111
#include <sys/time.h>
12+
#include <stdio.h>
13+
1214
#include <rtthread.h>
1315

1416
#ifdef RT_USING_DFS
@@ -218,7 +220,7 @@ _ssize_t
218220
_write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
219221
{
220222
#ifndef RT_USING_DFS
221-
if (fd == 0)
223+
if (fileno(stdout) == fd)
222224
{
223225
rt_device_t console;
224226

components/net/at/at_socket/at_socket.c

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,16 @@ int at_connect(int socket, const struct sockaddr *name, socklen_t namelen)
572572

573573
if (result < 0)
574574
{
575-
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
575+
if (sock != RT_NULL)
576+
{
577+
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
578+
}
576579
}
577580

578-
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
581+
if (sock)
582+
{
583+
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
584+
}
579585

580586
return result;
581587
}
@@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
699705

700706
__exit:
701707

702-
if (recv_len > 0)
708+
if (sock != RT_NULL)
703709
{
704-
result = recv_len;
705-
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
706-
errno = 0;
707-
if (!rt_slist_isempty(&sock->recvpkt_list))
710+
if (recv_len > 0)
708711
{
709-
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
712+
result = recv_len;
713+
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
714+
errno = 0;
715+
if (!rt_slist_isempty(&sock->recvpkt_list))
716+
{
717+
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
718+
}
719+
else
720+
{
721+
at_do_event_clean(sock, AT_EVENT_RECV);
722+
}
710723
}
711724
else
712725
{
713-
at_do_event_clean(sock, AT_EVENT_RECV);
726+
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
714727
}
715728
}
716-
else
717-
{
718-
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
719-
}
720729

721730
return result;
722731
}
@@ -807,7 +816,10 @@ int at_sendto(int socket, const void *data, size_t size, int flags, const struct
807816

808817
if (result < 0)
809818
{
810-
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
819+
if (sock != RT_NULL)
820+
{
821+
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
822+
}
811823
}
812824
else
813825
{

components/utilities/ulog/backend/console_be.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level
4545

4646
int ulog_console_backend_init(void)
4747
{
48+
ulog_init();
4849
console.output = ulog_console_backend_output;
4950

5051
ulog_backend_register(&console, "console", RT_TRUE);
5152

5253
return 0;
5354
}
54-
INIT_COMPONENT_EXPORT(ulog_console_backend_init);
55+
INIT_PREV_EXPORT(ulog_console_backend_init);
5556

5657
#endif /* ULOG_BACKEND_USING_CONSOLE */

components/utilities/ulog/ulog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ size_t ulog_strcpy(size_t cur_len, char *dst, const char *src)
149149
while (*src != 0)
150150
{
151151
/* make sure destination has enough space */
152-
if (cur_len++ <= ULOG_LINE_BUF_SIZE)
152+
if (cur_len++ < ULOG_LINE_BUF_SIZE)
153153
{
154154
*dst++ = *src++;
155155
}

0 commit comments

Comments
 (0)