image_read returns size_t, so 0 when error or end of file
This commit is contained in:
1 parent
17c6aefdcb
commit
26099e9536
3 files changed
+6
-5
No files matched your search
+3
-3
@@ -128,7 +128,7 @@ struct xloader_msg xloader_msg_create(uint32_t type, struct image * image) {
|
||||
if ( need > sizeof(buffer) )
|
||||
need = sizeof(buffer);
|
||||
ret = image_read(image, buffer, need);
|
||||
if ( ret < 0 )
|
||||
if ( ret == 0 )
|
||||
break;
|
||||
msg.crc1 = crc32(buffer, ret, msg.crc1);
|
||||
readed += ret;
|
||||
@@ -188,7 +188,7 @@ static int send_2nd(usb_dev_handle * udev, struct image * image) {
|
||||
if ( need > sizeof(buffer) )
|
||||
need = sizeof(buffer);
|
||||
ret = image_read(image, buffer, need);
|
||||
if ( ret < 0 )
|
||||
if ( ret == 0 )
|
||||
break;
|
||||
if ( usb_bulk_write(udev, WRITE_DEV, (char *)buffer, ret, WRITE_TIMEOUT) != ret )
|
||||
ERROR_RETURN("Sending 2nd X-Loader image failed", -1);
|
||||
@@ -230,7 +230,7 @@ static int send_secondary(usb_dev_handle * udev, struct image * image) {
|
||||
if ( need > sizeof(buffer) )
|
||||
need = sizeof(buffer);
|
||||
ret = image_read(image, buffer, need);
|
||||
if ( ret < 0 )
|
||||
if ( ret == 0 )
|
||||
break;
|
||||
if ( usb_bulk_write(udev, WRITE_DEV, (char *)buffer, ret, WRITE_TIMEOUT) != ret )
|
||||
ERROR_RETURN("Sending Secondary image failed", -1);
|
||||
|
||||
+2
-2
@@ -457,7 +457,7 @@ int fiasco_write_to_file(struct fiasco * fiasco, const char * file) {
|
||||
image_seek(image, 0);
|
||||
while ( 1 ) {
|
||||
size = image_read(image, buf, sizeof(buf));
|
||||
if ( size < 1 )
|
||||
if ( size == 0 )
|
||||
break;
|
||||
WRITE_OR_FAIL(file, fd, buf, size);
|
||||
}
|
||||
@@ -543,7 +543,7 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) {
|
||||
image_seek(image, 0);
|
||||
while ( 1 ) {
|
||||
size = image_read(image, buf, sizeof(buf));
|
||||
if ( size < 1 )
|
||||
if ( size == 0 )
|
||||
break;
|
||||
WRITE_OR_FAIL(name, fd, buf, size);
|
||||
}
|
||||
|
||||
@@ -419,6 +419,7 @@ enum image_type image_type_from_data(struct image * image) {
|
||||
|
||||
unsigned char buf[512];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
image_seek(image, 0);
|
||||
image_read(image, buf, sizeof(buf));
|
||||
|
||||
|
||||
Reference in new issue
Block a user