bugfix: saving errno of ioctl() call in a temporary variable to prevent overwriting by following avrdude_message() call

This commit is contained in:
Shunichi Wakabayashi 2022-09-25 16:46:10 +09:00
parent f17a012325
commit 2a64e78c7b
1 changed files with 3 additions and 2 deletions

View File

@ -93,9 +93,10 @@ static int linuxspi_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, u
errno = 0; errno = 0;
ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr); ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr);
if (ret != len) { if (ret != len) {
int ioctl_errno = errno;
avrdude_message(MSG_INFO, "\n%s: unable to send SPI message", progname); avrdude_message(MSG_INFO, "\n%s: unable to send SPI message", progname);
if (errno) if (ioctl_errno)
avrdude_message(MSG_INFO, ". %s", strerror(errno)); avrdude_message(MSG_INFO, ". %s", strerror(ioctl_errno));
avrdude_message(MSG_INFO, "\n"); avrdude_message(MSG_INFO, "\n");
} }