|
NB: this is Francesco Montorsi's patch for libusb_strerror, so not
directly related to the Windows backend, but the xusb test program uses libusb_strerror, so it is required. ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
On Sun, 31 Jan 2010 03:07:00 +0000
Pete Batard <[hidden email]> wrote: +API_EXPORTED const char* libusb_strerror(enum libusb_error errcode) +{ + switch (errcode) + { + case LIBUSB_SUCCESS: + return "Success"; + case LIBUSB_ERROR_IO: + return "Input/output error"; [...] + case LIBUSB_ERROR_OTHER: + return "Other error"; + + default: + return "Unknown error"; + } +} I would prefer to structure the libusb_strerror function a little differently: API_EXPORTED const char* libusb_strerror(enum libusb_error errcode) { switch (errcode) { case LIBUSB_SUCCESS: return "Success"; case LIBUSB_ERROR_IO: return "Input/output error"; [...] case LIBUSB_ERROR_OTHER: return "Other error"; } return "Unknown error"; } This will give the same return value for all input values, but removing the "default:" label will produce a compiler warning if any new LIBUSB_ERROR_* code is added to "enum libusb_error" and it has been forgotten to add a new "case" branch for the new code in the "switch" statement. -- Hans Ulrich Niedermann ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
On 2010.01.31 14:20, Hans Ulrich Niedermann wrote:
> case LIBUSB_ERROR_OTHER: > return "Other error"; > } > return "Unknown error"; > } > > This will give the same return value for all input values, but > removing the "default:" label will produce a compiler warning if any > new LIBUSB_ERROR_* code is added to "enum libusb_error" and it has been > forgotten to add a new "case" branch for the new code in the "switch" > statement. Regards, /Pete ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
and here's v3
Regards, /Pete ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
| Powered by Nabble | Edit this page |
