summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2016-05-16 19:46:23 -0700
committerGary E. Miller <gem@rellim.com>2016-05-16 19:46:23 -0700
commit0435464b5d5e8954cb820db84418aee8df5306e0 (patch)
tree61d944d2d3810d33559813f4b4707e366c88c637 /serial.c
parent6394b4ebd980c92e02748b2285ba097aae42375c (diff)
downloadgpsd-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.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/serial.c b/serial.c
index 6fd7a52b..c6fa27ea 100644
--- a/serial.c
+++ b/serial.c
@@ -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);
}