summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-12-24 17:59:36 +0100
committerHarald Welte <laforge@gnumonks.org>2016-12-24 17:59:36 +0100
commit1514f34dcfed3a8c46678861c488f7dbde856957 (patch)
tree9c3b6b265a9fb5a68ab3a130d4d0a944a0544d3f /src
parentd2510459a8b5f4ae0ee3740dd36ca1c4abd290b6 (diff)
serial.c: file descriptor '0' is a valid value
if stdin/stdout/stderr are all closed by our environment, it may very well be that opening a serial port returns fd == 0. Change-Id: Ifd9670260883a35da0629369e0d49e467d5b4d72
Diffstat (limited to 'src')
-rw-r--r--src/serial.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/serial.c b/src/serial.c
index 6316e459..05bdc86e 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -59,7 +59,7 @@
int
osmo_serial_init(const char *dev, speed_t baudrate)
{
- int rc, fd=0, v24, flags;
+ int rc, fd=-1, v24, flags;
struct termios tio;
/* Use nonblock as the device might block otherwise */
@@ -122,7 +122,7 @@ osmo_serial_init(const char *dev, speed_t baudrate)
return fd;
error:
- if (fd)
+ if (fd >= 0)
close(fd);
return rc;
}