mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-28 14:11:29 +01:00
tools: kwboot: Fix kwboot_xm_sendblock() function when kwboot_tty_recv() fails
When kwboot_tty_recv() fails or times out, it does not set the `c` variable to NAK. The variable is then compared, while it holds either an undefined value or a value from previous iteration. Set `c` to NAK so that the other side will try to resend current block, and remove the now unnecessary break. In other failure cases return immediately. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
a050a862a7
commit
00a1deed1c
@ -380,12 +380,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block)
|
|||||||
do {
|
do {
|
||||||
rc = kwboot_tty_send(fd, block, sizeof(*block));
|
rc = kwboot_tty_send(fd, block, sizeof(*block));
|
||||||
if (rc)
|
if (rc)
|
||||||
break;
|
return rc;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
rc = kwboot_tty_recv(fd, &c, 1, blk_rsp_timeo);
|
rc = kwboot_tty_recv(fd, &c, 1, blk_rsp_timeo);
|
||||||
if (rc)
|
if (rc) {
|
||||||
break;
|
if (errno != ETIMEDOUT)
|
||||||
|
return rc;
|
||||||
|
c = NAK;
|
||||||
|
}
|
||||||
|
|
||||||
if (c != ACK && c != NAK && c != CAN)
|
if (c != ACK && c != NAK && c != CAN)
|
||||||
printf("%c", c);
|
printf("%c", c);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user