diff options
| author | 2008-08-04 13:08:44 +0200 | |
|---|---|---|
| committer | 2008-08-04 23:02:47 -0700 | |
| commit | fe2cb86652d8f2038df64f2cb5985dd1088db051 (patch) | |
| tree | 167bdf9a6292da0b35358d73915910d8ecd638b2 | |
| parent | 279222bdb5b8a0ae430a2f553659407f9c8c2236 (diff) | |
| download | libimobiledevice-fe2cb86652d8f2038df64f2cb5985dd1088db051.tar.gz libimobiledevice-fe2cb86652d8f2038df64f2cb5985dd1088db051.tar.bz2 | |
Print strerror of negated return values after failed usb_bulk_write/read.
Signed-off-by: Matt Colyer <matt@colyer.name>
| -rw-r--r-- | src/iphone.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/iphone.c b/src/iphone.c index 6833e4c..5aefbf6 100644 --- a/src/iphone.c +++ b/src/iphone.c | |||
| @@ -87,14 +87,15 @@ iPhone *get_iPhone() { | |||
| 87 | if (bytes < 20 && debug) { | 87 | if (bytes < 20 && debug) { |
| 88 | printf("get_iPhone(): libusb did NOT send enough!\n"); | 88 | printf("get_iPhone(): libusb did NOT send enough!\n"); |
| 89 | if (bytes < 0) { | 89 | if (bytes < 0) { |
| 90 | printf("get_iPhone(): libusb gave me the error: %s\n", usb_strerror()); | 90 | printf("get_iPhone(): libusb gave me the error %d: %s (%s)\n", |
| 91 | bytes, usb_strerror(), strerror(-bytes)); | ||
| 91 | } | 92 | } |
| 92 | } | 93 | } |
| 93 | bytes = usb_bulk_read(phone->device, BULKIN, (char*)version, sizeof(*version), 800); | 94 | bytes = usb_bulk_read(phone->device, BULKIN, (char*)version, sizeof(*version), 800); |
| 94 | if (bytes < 20) { | 95 | if (bytes < 20) { |
| 95 | free_iPhone(phone); | 96 | free_iPhone(phone); |
| 96 | if (debug) printf("get_iPhone(): Invalid version message -- header too short.\n"); | 97 | if (debug) printf("get_iPhone(): Invalid version message -- header too short.\n"); |
| 97 | if (debug && bytes < 0) printf("get_iPhone(): libusb error message: %s\n", usb_strerror()); | 98 | if (debug && bytes < 0) printf("get_iPhone(): libusb error message %d: %s (%s)\n", usb_strerror(), strerror(-bytes)); |
| 98 | return NULL; | 99 | return NULL; |
| 99 | } else { | 100 | } else { |
| 100 | if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) { | 101 | if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) { |
| @@ -149,7 +150,7 @@ int send_to_phone(iPhone *phone, char *data, int datalen) { | |||
| 149 | if (debug) printf("noooo...?\n"); | 150 | if (debug) printf("noooo...?\n"); |
| 150 | if (bytes < datalen) { | 151 | if (bytes < datalen) { |
| 151 | if(debug && bytes < 0) | 152 | if(debug && bytes < 0) |
| 152 | printf("send_to_iphone(): libusb gave me the error: %s\n", usb_strerror()); | 153 | printf("send_to_iphone(): libusb gave me the error %d: %s\n", bytes, usb_strerror(), strerror(-bytes)); |
| 153 | return -1; | 154 | return -1; |
| 154 | } else { | 155 | } else { |
| 155 | return bytes; | 156 | return bytes; |
| @@ -173,7 +174,7 @@ int recv_from_phone(iPhone *phone, char *data, int datalen) { | |||
| 173 | bytes = usb_bulk_read(phone->device, BULKIN, data, datalen, 3500); | 174 | bytes = usb_bulk_read(phone->device, BULKIN, data, datalen, 3500); |
| 174 | if(bytes < 0) | 175 | if(bytes < 0) |
| 175 | { | 176 | { |
| 176 | if(debug) printf("recv_from_iphone(): libusb gave me the error: %s\n", usb_strerror()); | 177 | if(debug) printf("recv_from_iphone(): libusb gave me the error %d: %s (%s)\n", bytes, usb_strerror(), strerror(-bytes)); |
| 177 | return -1; | 178 | return -1; |
| 178 | } | 179 | } |
| 179 | return bytes; | 180 | return bytes; |
