SCP: Assure that debug writes that check errno get a correct value
The original solution provided in response to #957 needs to be adjusted to reflect that errno is only guaranteed to be set by fwrite() if an error occurred. otherwise a non zero value may have been set by some other call elsewhere in the program. All other cases where errno is explicitly check in simh, it is only done after receiving a return status from a system call. Fix problem reported in #1108
This commit is contained in:
parent
ff4c7b154e
commit
fa5e0ed157
1 changed files with 1 additions and 1 deletions
2
scp.c
2
scp.c
|
@ -13396,12 +13396,12 @@ static void _debug_fwrite_all (const char *buf, size_t len, FILE *f)
|
||||||
size_t len_written;
|
size_t len_written;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
|
errno = 0;
|
||||||
len_written = fwrite (buf, 1, len, f);
|
len_written = fwrite (buf, 1, len, f);
|
||||||
len -= len_written;
|
len -= len_written;
|
||||||
buf += len_written;
|
buf += len_written;
|
||||||
if (errno == EAGAIN) /* Non blocking file descriptor buffer full? */
|
if (errno == EAGAIN) /* Non blocking file descriptor buffer full? */
|
||||||
sim_os_ms_sleep(10);/* wait a bit to retry */
|
sim_os_ms_sleep(10);/* wait a bit to retry */
|
||||||
errno = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue