diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-09-15 11:31:00 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2012-09-15 23:29:32 +0100 |
commit | 75b94b24cf2a7b082b7fe1d493ebbdc3c999f910 (patch) | |
tree | 1249e500dbce4ffb9b635f1ee436097daf177aca | |
parent | 9d50e95028c6cada096b821eb9872539efced402 (diff) | |
download | libusb-75b94b24cf2a7b082b7fe1d493ebbdc3c999f910.tar.gz |
Core: Make libusb_error_name also handle transfer status codes
Note that for the code 0 which means success resp. completed we have an
overlap in the codes. This is not a problem since normally one would not
call libusb_error_name on success / normal completion.
-rw-r--r-- | libusb/core.c | 26 | ||||
-rw-r--r-- | libusb/libusb.h | 3 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/libusb/core.c b/libusb/core.c index 3964e3d..097870f 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1881,17 +1881,17 @@ void usbi_log(struct libusb_context *ctx, enum libusb_log_level level, /** \ingroup misc * Returns a constant NULL-terminated string with the ASCII name of a libusb - * error code. The caller must not free() the returned string. + * error or transfer status code. The caller must not free() the returned + * string. * - * \param error_code The \ref libusb_error code to return the name of. + * \param error_code The \ref libusb_error or libusb_transfer_status code to + * return the name of. * \returns The error name, or the string **UNKNOWN** if the value of - * error_code is not a known error code. + * error_code is not a known error / status code. */ DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_error_name(int error_code) { switch (error_code) { - case LIBUSB_SUCCESS: - return "LIBUSB_SUCCESS"; case LIBUSB_ERROR_IO: return "LIBUSB_ERROR_IO"; case LIBUSB_ERROR_INVALID_PARAM: @@ -1918,6 +1918,22 @@ DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_error_name(int error_code) return "LIBUSB_ERROR_NOT_SUPPORTED"; case LIBUSB_ERROR_OTHER: return "LIBUSB_ERROR_OTHER"; + + case LIBUSB_TRANSFER_ERROR: + return "LIBUSB_TRANSFER_ERROR"; + case LIBUSB_TRANSFER_TIMED_OUT: + return "LIBUSB_TRANSFER_TIMED_OUT"; + case LIBUSB_TRANSFER_CANCELLED: + return "LIBUSB_TRANSFER_CANCELLED"; + case LIBUSB_TRANSFER_STALL: + return "LIBUSB_TRANSFER_STALL"; + case LIBUSB_TRANSFER_NO_DEVICE: + return "LIBUSB_TRANSFER_NO_DEVICE"; + case LIBUSB_TRANSFER_OVERFLOW: + return "LIBUSB_TRANSFER_OVERFLOW"; + + case 0: + return "LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED"; default: return "**UNKNOWN**"; } diff --git a/libusb/libusb.h b/libusb/libusb.h index ae00c53..b166126 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -820,6 +820,9 @@ enum libusb_transfer_status { /** Device sent more data than requested */ LIBUSB_TRANSFER_OVERFLOW, + + /* NB! Remember to update libusb_error_name() + when adding new status codes here. */ }; /** \ingroup asyncio diff --git a/libusb/version_nano.h b/libusb/version_nano.h index d739262..dc44fe4 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10566 +#define LIBUSB_NANO 10567 |