diff options
author | Stu Grossman <grossman@cygnus> | 1993-04-09 22:14:04 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1993-04-09 22:14:04 +0000 |
commit | 4febd10272e10062f09c8456dacd8cfe970579d8 (patch) | |
tree | a62d659b1948b2e935868ae4eb45364eed913b66 /gdb/ser-unix.c | |
parent | 6a42d1847267d8e1e0539a28528431617de0e70d (diff) | |
download | gdb-4febd10272e10062f09c8456dacd8cfe970579d8.zip gdb-4febd10272e10062f09c8456dacd8cfe970579d8.tar.gz gdb-4febd10272e10062f09c8456dacd8cfe970579d8.tar.bz2 |
* remote.c (remote_open): Use SERIAL_OPEN instead of serial_open.
(putpkt, getpkt): Use new return codes for SERIAL_READCHAR.
* ser-go32.c: Return -1 on most failures, 0 on most successes,
and use new return codes for go32_readchar().
* ser-unix.c: Ditto. Also, move error handling up to caller for
SERIAL_SETBAUDRATE().
* serial.c (serial_open): Internal call, not SERIAL_OPEN to get
to specific routine.
(serial_close): New routine to wrap around device close routine.
serial.h: Clean & document return values more clearly.
Diffstat (limited to 'gdb/ser-unix.c')
-rw-r--r-- | gdb/ser-unix.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index 541e4c2..afe6724 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -47,7 +47,7 @@ hardwire_open(scb, name) { scb->fd = open (name, O_RDWR); if (scb->fd < 0) - return errno; + return -1; return 0; } @@ -145,17 +145,17 @@ hardwire_readchar(scb, timeout) if (numfds <= 0) if (numfds == 0) - return -2; /* Timeout */ + return SERIAL_TIMEOUT; else - return -3; /* Got an error from select */ + return SERIAL_ERROR; /* Got an error from select */ scb->bufcnt = read(scb->fd, scb->buf, BUFSIZ); if (scb->bufcnt <= 0) if (scb->bufcnt == 0) - return EOF; /* 0 chars means end of file */ + return SERIAL_EOF; /* 0 chars means end of file */ else - return -3; /* Got an error from read */ + return SERIAL_ERROR; /* Got an error from read */ scb->bufcnt--; scb->bufp = scb->buf; @@ -220,24 +220,20 @@ hardwire_setbaudrate(scb, rate) struct termios termios; if (tcgetattr (scb->fd, &termios)) - error("hardwire_setbaudrate: tcgetattr failed: %s\n", safe_strerror(errno)); + return -1; cfsetospeed (&termios, rate_to_code (rate)); cfsetispeed (&termios, rate_to_code (rate)); if (tcsetattr (scb->fd, TCSANOW, &termios)) - error ("hardwire_setbaudrate: tcsetattr failed: %s\n", safe_strerror(errno)); - - return 1; + return -1; #endif #ifdef HAVE_TERMIO struct termio termio; if (ioctl (scb->fd, TCGETA, &termio)) - { - fprintf(stderr, "TCGETA failed: %s\n", safe_strerror(errno)); - } + return -1; #ifndef CIBAUD #define CIBAUD CBAUD @@ -247,23 +243,22 @@ hardwire_setbaudrate(scb, rate) termio.c_cflag |= rate_to_code (rate); if (ioctl (scb->fd, TCSETA, &termio)) - { - fprintf(stderr, "TCSETA failed: %s\n", safe_strerror(errno)); - } + return -1; #endif #ifdef HAVE_SGTTY struct sgttyb sgttyb; if (ioctl (scb->fd, TIOCGETP, &sgttyb)) - fprintf (stderr, "TIOCGETP failed: %s\n", safe_strerror (errno)); + return -1; sgttyb.sg_ispeed = rate_to_code (rate); sgttyb.sg_ospeed = rate_to_code (rate); if (ioctl (scb->fd, TIOCSETP, &sgttyb)) - fprintf (stderr, "TIOCSETP failed: %s\n", safe_strerror (errno)); + return -1; #endif + return 0; } static int @@ -299,8 +294,6 @@ hardwire_close(scb) if (scb->fd < 0) return; - SERIAL_RESTORE(scb); - close(scb->fd); scb->fd = -1; } |