drivers: Report correct errno in uart_native_posix driver
This driver carefully saved the errno value from the failing call and then didn't use it in the ERROR report, using the potentially invalid current errno value (which may have been set by the close call). Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
1c2f3c4cef
commit
0970cda906
1 changed files with 8 additions and 5 deletions
|
@ -129,19 +129,19 @@ static int open_tty(struct native_uart_status *driver_data,
|
|||
err_nbr = errno;
|
||||
close(master_pty);
|
||||
ERROR("Could not grant access to the slave PTY side (%i)\n",
|
||||
errno);
|
||||
err_nbr);
|
||||
}
|
||||
ret = unlockpt(master_pty);
|
||||
if (ret == -1) {
|
||||
err_nbr = errno;
|
||||
close(master_pty);
|
||||
ERROR("Could not unlock the slave PTY side (%i)\n", errno);
|
||||
ERROR("Could not unlock the slave PTY side (%i)\n", err_nbr);
|
||||
}
|
||||
slave_pty_name = ptsname(master_pty);
|
||||
if (slave_pty_name == NULL) {
|
||||
err_nbr = errno;
|
||||
close(master_pty);
|
||||
ERROR("Error getting slave PTY device name (%i)\n", errno);
|
||||
ERROR("Error getting slave PTY device name (%i)\n", err_nbr);
|
||||
}
|
||||
/* Set the master PTY as non blocking */
|
||||
flags = fcntl(master_pty, F_GETFL);
|
||||
|
@ -149,7 +149,7 @@ static int open_tty(struct native_uart_status *driver_data,
|
|||
err_nbr = errno;
|
||||
close(master_pty);
|
||||
ERROR("Could not read the master PTY file status flags (%i)\n",
|
||||
errno);
|
||||
err_nbr);
|
||||
}
|
||||
|
||||
ret = fcntl(master_pty, F_SETFL, flags | O_NONBLOCK);
|
||||
|
@ -157,9 +157,11 @@ static int open_tty(struct native_uart_status *driver_data,
|
|||
err_nbr = errno;
|
||||
close(master_pty);
|
||||
ERROR("Could not set the master PTY as non-blocking (%i)\n",
|
||||
errno);
|
||||
err_nbr);
|
||||
}
|
||||
|
||||
(void) err_nbr;
|
||||
|
||||
/*
|
||||
* Set terminal in "raw" mode:
|
||||
* Not canonical (no line input)
|
||||
|
@ -291,6 +293,7 @@ static void np_uart_poll_out(const struct device *dev,
|
|||
* but we do not need the return value for anything.
|
||||
*/
|
||||
ret = write(d->out_fd, &out_char, 1);
|
||||
(void) ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue