This is an automated email from the ASF dual-hosted git repository. aguettouche pushed a commit to branch releases/10.0 in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 501a09e309aec51aa1e6f5bf9ebc89f43758f2a3 Author: Juha Niskanen <[email protected]> AuthorDate: Mon Oct 19 18:43:09 2020 +0300 system/cu: do not exit directly from getopt loop, bad in flat builds Signed-off-by: Juha Niskanen <[email protected]> --- system/cu/cu.h | 3 ++- system/cu/cu_main.c | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/system/cu/cu.h b/system/cu/cu.h index d73e437..9ca6c78 100644 --- a/system/cu/cu.h +++ b/system/cu/cu.h @@ -49,7 +49,8 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Configuration ***********************************************************/ + +/* Configuration ************************************************************/ #ifndef CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE # define CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE "/dev/ttyS0" diff --git a/system/cu/cu_main.c b/system/cu/cu_main.c index b053d28..d914284 100644 --- a/system/cu/cu_main.c +++ b/system/cu/cu_main.c @@ -214,7 +214,7 @@ errout: return rc; } -static int retrive_termios(int fd) +static int retrieve_termios(int fd) { tcsetattr(fd, TCSANOW, &g_tio_dev); if (fd_std_tty >= 0) @@ -241,10 +241,11 @@ static void print_help(void) " -?: This help\n", #ifdef CONFIG_SERIAL_TERMIOS CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE, - CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD); + CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD #else - CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE); + CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE #endif + ); } static void print_escape_help(void) @@ -300,6 +301,7 @@ int main(int argc, FAR char *argv[]) int bcmd; int start_of_line = 1; int exitval = EXIT_FAILURE; + bool badarg = false; /* Initialize global data */ @@ -338,24 +340,33 @@ int main(int argc, FAR char *argv[]) break; case 'c': - nocrlf = 1; - break; + nocrlf = 1; + break; #endif case 'f': - nobreak = 1; - break; + nobreak = 1; + break; case 'h': case '?': print_help(); - return EXIT_SUCCESS; + badarg = true; + exitval = EXIT_SUCCESS; + break; default: - return EXIT_FAILURE; + badarg = true; + exitval = EXIT_FAILURE; + break; } } + if (badarg) + { + return exitval; + } + /* Open the serial device for writing */ g_cu.outfd = open(devname, O_WRONLY); @@ -435,6 +446,7 @@ int main(int argc, FAR char *argv[]) ret = pthread_create(&g_cu.listener, &attr, cu_listener, (pthread_addr_t)0); + pthread_attr_destroy(&attr); if (ret != 0) { fprintf(stderr, "cu_main: Error in thread creation: %d\n", ret); @@ -499,7 +511,6 @@ int main(int argc, FAR char *argv[]) } pthread_cancel(g_cu.listener); - pthread_attr_destroy(&attr); exitval = EXIT_SUCCESS; /* Error exits */ @@ -508,7 +519,7 @@ errout_with_fds: close(g_cu.infd); #ifdef CONFIG_SERIAL_TERMIOS errout_with_outfd_retrieve: - retrive_termios(g_cu.outfd); + retrieve_termios(g_cu.outfd); #endif errout_with_outfd: close(g_cu.outfd);
