diff options
author | Gary E. Miller <gem@rellim.com> | 2016-05-16 19:46:23 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2016-05-16 19:46:23 -0700 |
commit | 0435464b5d5e8954cb820db84418aee8df5306e0 (patch) | |
tree | 61d944d2d3810d33559813f4b4707e366c88c637 /serial.c | |
parent | 6394b4ebd980c92e02748b2285ba097aae42375c (diff) | |
download | gpsd-0435464b5d5e8954cb820db84418aee8df5306e0.tar.gz |
Test return of every tcsetattr() in serial.c
But, as the man page says, a return of success does not mean 100%
success
Diffstat (limited to 'serial.c')
-rw-r--r-- | serial.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -317,9 +317,12 @@ void gpsd_set_speed(struct gps_device_t *session, session->ttyset.c_cflag |= PARENB | PARODD; break; } - if (tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset) != - 0) + if (tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset) != 0) { + gpsd_log(&session->context->errout, LOG_ERROR, + "SER: error setting port attributes: %s\n", + strerror(errno)); return; + } /* * Serious black magic begins here. Getting this code wrong can cause @@ -535,7 +538,11 @@ int gpsd_serial_open(struct gps_device_t *session) if (session->saved_baud != -1) { (void)cfsetispeed(&session->ttyset, (speed_t)session->saved_baud); (void)cfsetospeed(&session->ttyset, (speed_t)session->saved_baud); - (void)tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset); + if (tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset) != 0) { + gpsd_log(&session->context->errout, LOG_ERROR, + "SER: Error setting port attributes: %s\n", + strerror(errno)); + } (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH); } |