r1152 - trunk/src/host/dfu-util/src
werner at sita.openmoko.org
werner at sita.openmoko.org
Tue Feb 27 21:40:14 CET 2007
Author: werner
Date: 2007-02-27 21:40:11 +0100 (Tue, 27 Feb 2007)
New Revision: 1152
Modified:
trunk/src/host/dfu-util/src/main.c
trunk/src/host/dfu-util/src/sam7dfu.c
Log:
sam7dfu.c (sam7dfu_do_upload, sam7dfu_do_dnload): make error handling more
consistent by printing errors also if system calls fail
main.c (main): exit with non-zero exit status if sam7dfu_do_upload or
sam7dfu_do_dnload fail
Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c 2007-02-27 20:15:03 UTC (rev 1151)
+++ trunk/src/host/dfu-util/src/main.c 2007-02-27 20:40:11 UTC (rev 1152)
@@ -617,12 +617,14 @@
switch (mode) {
case MODE_UPLOAD:
- sam7dfu_do_upload(dif->dev_handle, dif->interface,
- transfer_size, filename);
+ if (sam7dfu_do_upload(dif->dev_handle, dif->interface,
+ transfer_size, filename) < 0)
+ exit(1);
break;
case MODE_DOWNLOAD:
- sam7dfu_do_dnload(dif->dev_handle, dif->interface,
- transfer_size, filename);
+ if (sam7dfu_do_dnload(dif->dev_handle, dif->interface,
+ transfer_size, filename) < 0)
+ exit(1);
break;
default:
fprintf(stderr, "Unsupported mode: %u\n", mode);
Modified: trunk/src/host/dfu-util/src/sam7dfu.c
===================================================================
--- trunk/src/host/dfu-util/src/sam7dfu.c 2007-02-27 20:15:03 UTC (rev 1151)
+++ trunk/src/host/dfu-util/src/sam7dfu.c 2007-02-27 20:40:11 UTC (rev 1152)
@@ -26,6 +26,7 @@
fd = creat(fname, 0644);
if (fd < 0) {
+ perror(fname);
ret = fd;
goto out_free;
}
@@ -74,13 +75,17 @@
fd = open(fname, O_RDONLY);
if (fd < 0) {
+ perror(fname);
ret = fd;
goto out_free;
}
ret = fstat(fd, &st);
- if (ret < 0)
+ if (ret < 0) {
+ perror(fname);
goto out_close;
+ perror(fname);
+ }
if (st.st_size <= 0 /* + DFU_HDR */) {
fprintf(stderr, "File seems a bit too small...\n");
@@ -94,8 +99,10 @@
printf("Starting download: [");
while (bytes_sent < st.st_size /* - DFU_HDR */) {
ret = read(fd, buf, xfer_size);
- if (ret < 0)
+ if (ret < 0) {
+ perror(fname);
goto out_close;
+ }
ret = dfu_download(usb_handle, interface, ret, buf);
if (ret < 0)
goto out_close;
More information about the commitlog
mailing list