summaryrefslogtreecommitdiff
path: root/libgps.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-04-21 03:14:03 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-04-21 03:14:03 +0000
commit75002d5d3213992033888256a8671a7c8133db75 (patch)
tree11d4d28c7eb5af7f78bca6e5da18097fdae749ce /libgps.c
parent658b09195bb9ace363edf942992b0e934ef6aa21 (diff)
downloadgpsd-75002d5d3213992033888256a8671a7c8133db75.tar.gz
Make sure gps_poll() will return -1 on a zero read
The idea is to suggest a dropped connection.
Diffstat (limited to 'libgps.c')
-rw-r--r--libgps.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/libgps.c b/libgps.c
index d0c37a9b..8fb5fa22 100644
--- a/libgps.c
+++ b/libgps.c
@@ -437,12 +437,9 @@ int gps_poll(struct gps_data_t *gpsdata)
/* the daemon makes sure that every read is NUL-terminated */
n = read(gpsdata->gps_fd, buf, sizeof(buf)-1);
- if (n < 0) {
- /* error */
+ if (n <= 0) {
+ /* error or nothiung read */
return -1;
- } else if ( n == 0 ) {
- /* nothing read */
- return 0;
}
buf[n] = '\0';