Both patches seem quite reasonable to me.
Merged.
Cheers,
Jason.
On 04/30/2018 06:34 AM, Heinrich Schuchardt wrote:
If the baud rate cannot be set provide an error message and abort.
Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de>
---
agent-proxy-rs232.c | 32 +++++++++++++++++++++++---------
agent-proxy.c | 3 ++-
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/agent-proxy-rs232.c b/agent-proxy-rs232.c
index 79dde9e..768fd55 100644
--- a/agent-proxy-rs232.c
+++ b/agent-proxy-rs232.c
@@ -152,27 +152,39 @@ static int rate_to_code(int rate)
static int get_tty_state(unsigned int sock, struct hardwire_ttystate *state)
{
#ifdef HAVE_TERMIOS
- if (tcgetattr(sock, &state->termios) < 0)
+ if (tcgetattr(sock, &state->termios) < 0) {
+ perror("tcgetattr failed");
return -1;
+ }
return 0;
#endif
#ifdef HAVE_TERMIO
- if (ioctl(sock, TCGETA, &state->termio) < 0)
+ if (ioctl(sock, TCGETA, &state->termio) < 0) {
+ perror("ioctl failed");
return -1;
+ }
return 0;
#endif
#ifdef HAVE_SGTTY
- if (ioctl(sock, TIOCGETP, &state->sgttyb) < 0)
+ if (ioctl(sock, TIOCGETP, &state->sgttyb) < 0) {
+ perror("ioctl failed");
return -1;
- if (ioctl(sock, TIOCGETC, &state->tc) < 0)
+ }
+ if (ioctl(sock, TIOCGETC, &state->tc) < 0) {
+ perror("ioctl failed");
return -1;
- if (ioctl(sock, TIOCGLTC, &state->ltc) < 0)
+ }
+ if (ioctl(sock, TIOCGLTC, &state->ltc) < 0) {
+ perror("ioctl failed");
return -1;
- if (ioctl(sock, TIOCLGET, &state->lmode) < 0)
+ }
+ if (ioctl(sock, TIOCLGET, &state->lmode) < 0) {
+ perror("ioctl failed");
return -1;
+ }
return 0;
#endif
@@ -213,14 +225,16 @@ int setbaudrate(int sock, int baud)
int baud_code = rate_to_code(baud);
if (baud_code < 0) {
- /* The baud rate was not valid.
- A warning has already been issued. */
+ /* The baud rate was not valid. */
+ fprintf(stderr, "Invalid baud rate\n");
errno = EINVAL;
return -1;
}
- if (get_tty_state(sock, &state))
+ if (get_tty_state(sock, &state)) {
+ fprintf(stderr, "Cannot get tty state\n");
return -1;
+ }
#ifdef HAVE_TERMIOS
cfsetospeed(&state.termios, baud_code);
diff --git a/agent-proxy.c b/agent-proxy.c
index a2d7706..d0a43bd 100644
--- a/agent-proxy.c
+++ b/agent-proxy.c
@@ -673,7 +673,8 @@ static int setup_remote_port(struct port_st *rport, char
*host, char *port)
}
if (baudinfo) {
- setbaudrate(rport->sock, atoi(baudinfo));
+ if (setbaudrate(rport->sock, atoi(baudinfo)))
+ return 1;
}
setstopbits(rport->sock, "1");
setcondefaults(rport->sock);
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport