From a437ffbf3eed0f5da0a869b7b960a8f1218176d4 Mon Sep 17 00:00:00 2001 From: bernard Date: Tue, 17 Oct 2017 22:24:23 +0800 Subject: [PATCH] [libc] code cleanup for termios. --- components/libc/termios/SConscript | 2 +- components/libc/termios/posix_termios.c | 52 ++++++++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/components/libc/termios/SConscript b/components/libc/termios/SConscript index ef05e688bb..381eb5ad8b 100644 --- a/components/libc/termios/SConscript +++ b/components/libc/termios/SConscript @@ -7,7 +7,7 @@ src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] group = DefineGroup('libc', src, - depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], + depend = ['RT_USING_LIBC', 'RT_USING_POSIX', 'RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/termios/posix_termios.c b/components/libc/termios/posix_termios.c index 4e863ea507..4ec513ef1d 100644 --- a/components/libc/termios/posix_termios.c +++ b/components/libc/termios/posix_termios.c @@ -32,7 +32,7 @@ int tcgetattr(int fd, struct termios *tio) { - /* Get the current serial port settings. */ + /* Get the current serial port settings. */ if (ioctl(fd, TCGETA, tio)) return -1; @@ -41,27 +41,27 @@ int tcgetattr(int fd, struct termios *tio) int tcsetattr(int fd, int act, const struct termios *tio) { - switch (act) - { - case TCSANOW: - /* make the change immediately */ - return (ioctl(fd, TCSETA, (void*)tio)); - case TCSADRAIN: - /* - * Don't make the change until all currently written data - * has been transmitted. - */ - return (ioctl(fd, TCSETAW, (void*)tio)); - case TCSAFLUSH: - /* Don't make the change until all currently written data - * has been transmitted, at which point any received but - * unread data is also discarded. - */ - return (ioctl(fd, TCSETAF, (void*)tio)); - default: - errno = EINVAL; - return (-1); - } + switch (act) + { + case TCSANOW: + /* make the change immediately */ + return (ioctl(fd, TCSETA, (void*)tio)); + case TCSADRAIN: + /* + * Don't make the change until all currently written data + * has been transmitted. + */ + return (ioctl(fd, TCSETAW, (void*)tio)); + case TCSAFLUSH: + /* Don't make the change until all currently written data + * has been transmitted, at which point any received but + * unread data is also discarded. + */ + return (ioctl(fd, TCSETAF, (void*)tio)); + default: + errno = EINVAL; + return (-1); + } } /** @@ -106,7 +106,7 @@ int cfsetispeed(struct termios *tio, speed_t speed) int tcsendbreak(int fd, int dur) { /* nonzero duration is implementation-defined, so ignore it */ - return 0; + return 0; } int tcflush(int fd, int queue) @@ -124,14 +124,14 @@ int tcflow(int fd, int action) */ int tcdrain(int fd) { - return 0; + return 0; } int isatty (int fd) { - struct termios term; + struct termios term; - return tcgetattr (fd, &term) == 0; + return tcgetattr (fd, &term) == 0; } #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -- GitLab