diff options
| author | 2010-05-13 07:06:45 -0400 | |
|---|---|---|
| committer | 2010-05-13 07:06:45 -0400 | |
| commit | 5bbd277ce71521a3898697e4c8cb25ed65990f9c (patch) | |
| tree | e786fc44f0be708c12ae85dc5ccf3227a5010135 /src | |
| parent | a2a3537ea24d3cdcc1b210b45695d6eed33ee433 (diff) | |
| download | libirecovery-5bbd277ce71521a3898697e4c8cb25ed65990f9c.tar.gz libirecovery-5bbd277ce71521a3898697e4c8cb25ed65990f9c.tar.bz2 | |
Cleaned up irecv_reset(), and irecv_close() to make sure they were returning error if there really was an error
Diffstat (limited to 'src')
| -rw-r--r-- | src/libirecovery.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index cdb0c53..a5b5c84 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c | |||
| @@ -79,23 +79,21 @@ int irecv_open(irecv_device* device) { | |||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | int irecv_reset(irecv_device* device) { | 81 | int irecv_reset(irecv_device* device) { |
| 82 | if (device != NULL) { | 82 | if (device == NULL || device->handle != NULL) { |
| 83 | if (device->handle != NULL) { | 83 | return IRECV_ERROR_NO_DEVICE; |
| 84 | libusb_reset_device(device->handle); | ||
| 85 | } | ||
| 86 | } | 84 | } |
| 87 | 85 | ||
| 86 | libusb_reset_device(device->handle); | ||
| 88 | return IRECV_SUCCESS; | 87 | return IRECV_SUCCESS; |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | int irecv_close(irecv_device* device) { | 90 | int irecv_close(irecv_device* device) { |
| 92 | if (device != NULL) { | 91 | if (device == NULL || device->handle != NULL) { |
| 93 | if (device->handle != NULL) { | 92 | return IRECV_ERROR_NO_DEVICE; |
| 94 | libusb_close(device->handle); | ||
| 95 | device->handle = NULL; | ||
| 96 | } | ||
| 97 | } | 93 | } |
| 98 | 94 | ||
| 95 | libusb_close(device->handle); | ||
| 96 | device->handle = NULL; | ||
| 99 | return IRECV_SUCCESS; | 97 | return IRECV_SUCCESS; |
| 100 | } | 98 | } |
| 101 | 99 | ||
