Skip to content

Commit 0ccdf91

Browse files
committed
2 parents cbeda02 + 472597c commit 0ccdf91

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

microcom.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ int main(int argc, char *argv[])
211211
char *logfile = NULL;
212212

213213
struct option long_options[] = {
214-
{ "help", no_argument, 0, 'h' },
215-
{ "port", required_argument, 0, 'p'},
216-
{ "speed", required_argument, 0, 's'},
217-
{ "telnet", required_argument, 0, 't'},
218-
{ "can", required_argument, 0, 'c'},
219-
{ "debug", no_argument, 0, 'd' },
220-
{ "force", no_argument, 0, 'f' },
221-
{ "logfile", required_argument, 0, 'l'},
222-
{ "listenonly", no_argument, 0, 'o'},
223-
{ "answerback", required_argument, 0, 'a'},
224-
{ "version", no_argument, 0, 'v' },
225-
{ 0, 0, 0, 0},
214+
{ "help", no_argument, NULL, 'h' },
215+
{ "port", required_argument, NULL, 'p'},
216+
{ "speed", required_argument, NULL, 's'},
217+
{ "telnet", required_argument, NULL, 't'},
218+
{ "can", required_argument, NULL, 'c'},
219+
{ "debug", no_argument, NULL, 'd' },
220+
{ "force", no_argument, NULL, 'f' },
221+
{ "logfile", required_argument, NULL, 'l'},
222+
{ "listenonly", no_argument, NULL, 'o'},
223+
{ "answerback", required_argument, NULL, 'a'},
224+
{ "version", no_argument, NULL, 'v' },
225+
{ },
226226
};
227227

228228
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[])
302302
exit(1);
303303
}
304304

305-
current_flow = FLOW_NONE;
306-
if (ios->set_speed(ios, current_speed))
307-
exit(EXIT_FAILURE);
305+
ret = ios->set_speed(ios, current_speed);
306+
if (ret)
307+
goto cleanup_ios;
308308

309+
current_flow = FLOW_NONE;
309310
ios->set_flow(ios, current_flow);
310311

311312
if (!listenonly) {
@@ -329,10 +330,11 @@ int main(int argc, char *argv[])
329330
/* run the main program loop */
330331
ret = mux_loop(ios);
331332

332-
ios->exit(ios);
333-
334333
if (!listenonly)
335334
tcsetattr(STDIN_FILENO, TCSANOW, &sots);
336335

336+
cleanup_ios:
337+
ios->exit(ios);
338+
337339
exit(ret ? 1 : 0);
338340
}

0 commit comments

Comments
 (0)