Skip to content

Commit

Permalink
Missing return 1 in gpx_sio_open(). Remove exit() calls in gpx_sio_op…
Browse files Browse the repository at this point in the history
…en() and match style of gpx_sio_open() in winsio.c by returning 0 for errors rathern then exit() for errors.
  • Loading branch information
dcnewman committed May 30, 2015
1 parent 327ab31 commit 42a3c04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/gpx/gpx-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ int gpx_sio_open(Gpx *gpx, const char *filename, speed_t baud_rate,
// open and configure the serial port
if((port = open(filename, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {
perror("Error opening port");
exit(-1);
return 0;
}

if(fcntl(port, F_SETFL, O_RDWR) < 0) {
perror("Setting port descriptor flags");
exit(-1);
return 0;
}

if(tcgetattr(port, &tp) < 0) {
perror("Error getting port attributes");
exit(-1);
return 0;
}

cfmakeraw(&tp);
Expand Down Expand Up @@ -275,18 +275,20 @@ int gpx_sio_open(Gpx *gpx, const char *filename, speed_t baud_rate,

if(tcsetattr(port, TCSANOW, &tp) < 0) {
perror("Error setting port attributes");
exit(-1);
return 0;
}

sleep(2);
if(tcflush(port, TCIOFLUSH) < 0) {
perror("Error flushing port");
exit(-1);
return 0;
}

if(gpx->flag.verboseMode) fprintf(gpx->log, "Communicating via: %s" EOL, filename);
if(sio_port)
*sio_port = port;

return 1;
}
#endif

Expand Down

0 comments on commit 42a3c04

Please sign in to comment.