[PATCH] Verify sending of completion packet
Tormod Volden
lists.tormod at gmail.com
Sun Nov 7 18:51:10 CET 2010
From: Tormod Volden <debian.tormod at gmail.com>
If the completion packet is not received properly it is not
sure anything will be written.
Return the total number of bytes written.
Remove a stray perror.
Remove a trailing newline.
---
Hi,
More patches for dfu-util. I hope they do not drown in Russion spam :)
Tormod
src/sam7dfu.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/sam7dfu.c b/src/sam7dfu.c
index d839952..177ba7b 100644
--- a/src/sam7dfu.c
+++ b/src/sam7dfu.c
@@ -104,7 +104,6 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface,
if (ret < 0) {
perror(fname);
goto out_close;
- perror(fname);
}
if (st.st_size <= 0 /* + DFU_HDR */) {
@@ -164,8 +163,10 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface,
/* send one zero sized download request to signalize end */
ret = dfu_download(usb_handle, interface, 0, NULL);
- if (ret >= 0)
- ret = bytes_sent;
+ if (ret < 0) {
+ fprintf(stderr, "Error sending completion packet\n");
+ goto out_close;
+ }
printf("] finished!\n");
fflush(stdout);
@@ -206,7 +207,7 @@ out_close:
out_free:
free(buf);
- return ret;
+ return bytes_sent;
}
void sam7dfu_init()
@@ -215,4 +216,3 @@ void sam7dfu_init()
dfu_init( 5000 );
}
-
--
1.7.0.4
More information about the devel
mailing list