From: Antonio Ospite Date: Wed, 10 Jun 2015 09:49:31 +0000 (+0200) Subject: Improve error messages relative to libusb calls failures X-Git-Url: https://git.ao2.it/visomat-utils.git/commitdiff_plain/687aee331eeb10d36367dc6a6c612a5466fc40df?ds=sidebyside Improve error messages relative to libusb calls failures --- diff --git a/src/visomat-data-downloader.c b/src/visomat-data-downloader.c index 8cb99e2..f93757d 100644 --- a/src/visomat-data-downloader.c +++ b/src/visomat-data-downloader.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -319,7 +320,7 @@ int main(void) ret = libusb_init(NULL); if (ret < 0) { - fprintf(stderr, "error (%d): cannot initialize libusb.\n", ret); + fprintf(stderr, "libusb_init failed: %s\n", libusb_error_name(ret)); goto out; } @@ -329,15 +330,17 @@ int main(void) VISOMAT_DEVICE_VID, VISOMAT_DEVICE_PID); if (dev == NULL) { - fprintf(stderr, "error (%d): cannot open device.\n", errno); + fprintf(stderr, "libusb_open failed: %s\n", strerror(errno)); ret = -errno; goto out_libusb_exit; } ret = libusb_set_configuration(dev, VISOMAT_CONFIGURATION); if (ret < 0) { - fprintf(stderr, "error (%d): cannot set configuration %d.\n", - ret, VISOMAT_CONFIGURATION); + fprintf(stderr, "libusb_set_configuration failed: %s\n", + libusb_error_name(ret)); + fprintf(stderr, "Cannot set configuration %hhu\n", + VISOMAT_CONFIGURATION); goto out_libusb_close; } @@ -345,8 +348,10 @@ int main(void) ret = libusb_claim_interface(dev, VISOMAT_INTERFACE); if (ret < 0) { - fprintf(stderr, "error (%d): cannot claim interface %d.\n", - ret, VISOMAT_INTERFACE); + fprintf(stderr, "libusb_claim_interface failed: %s\n", + libusb_error_name(ret)); + fprintf(stderr, "Cannot claim interface %hhu\n", + VISOMAT_INTERFACE); goto out_libusb_close; }