summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2020-09-19 17:28:10 +0200
committerUwe Kleine-König <uwe@kleine-koenig.org>2020-09-19 17:28:10 +0200
commit0ccdf91d61e0cbff3e9686d19d7929f0aeda00e3 (patch)
treeed348ba8ac1ecaab1dcb69036457d0de82eb1cb6
parentcbeda02ef0b63407f86b0696f91d6be58ba4e070 (diff)
parent472597ccbc83ad5268b8a973a84bdfe5cf3457f0 (diff)
downloadmicrocom-0ccdf91d61e0cbff3e9686d19d7929f0aeda00e3.tar.gz
microcom-0ccdf91d61e0cbff3e9686d19d7929f0aeda00e3.tar.xz
Merge branch 'fixes' of https://github.com/ukleinek/microcom
-rw-r--r--microcom.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/microcom.c b/microcom.c
index 1218ec4..5bda7b4 100644
--- a/microcom.c
+++ b/microcom.c
@@ -211,18 +211,18 @@ int main(int argc, char *argv[])
char *logfile = NULL;
struct option long_options[] = {
- { "help", no_argument, 0, 'h' },
- { "port", required_argument, 0, 'p'},
- { "speed", required_argument, 0, 's'},
- { "telnet", required_argument, 0, 't'},
- { "can", required_argument, 0, 'c'},
- { "debug", no_argument, 0, 'd' },
- { "force", no_argument, 0, 'f' },
- { "logfile", required_argument, 0, 'l'},
- { "listenonly", no_argument, 0, 'o'},
- { "answerback", required_argument, 0, 'a'},
- { "version", no_argument, 0, 'v' },
- { 0, 0, 0, 0},
+ { "help", no_argument, NULL, 'h' },
+ { "port", required_argument, NULL, 'p'},
+ { "speed", required_argument, NULL, 's'},
+ { "telnet", required_argument, NULL, 't'},
+ { "can", required_argument, NULL, 'c'},
+ { "debug", no_argument, NULL, 'd' },
+ { "force", no_argument, NULL, 'f' },
+ { "logfile", required_argument, NULL, 'l'},
+ { "listenonly", no_argument, NULL, 'o'},
+ { "answerback", required_argument, NULL, 'a'},
+ { "version", no_argument, NULL, 'v' },
+ { },
};
while ((opt = getopt_long(argc, argv, "hp:s:t:c:dfl:oi:a:v", long_options, NULL)) != -1) {
@@ -302,10 +302,11 @@ int main(int argc, char *argv[])
exit(1);
}
- current_flow = FLOW_NONE;
- if (ios->set_speed(ios, current_speed))
- exit(EXIT_FAILURE);
+ ret = ios->set_speed(ios, current_speed);
+ if (ret)
+ goto cleanup_ios;
+ current_flow = FLOW_NONE;
ios->set_flow(ios, current_flow);
if (!listenonly) {
@@ -329,10 +330,11 @@ int main(int argc, char *argv[])
/* run the main program loop */
ret = mux_loop(ios);
- ios->exit(ios);
-
if (!listenonly)
tcsetattr(STDIN_FILENO, TCSANOW, &sots);
+cleanup_ios:
+ ios->exit(ios);
+
exit(ret ? 1 : 0);
}