2013/6/9 Pete Batard <[email protected]>:
> diff --git a/examples/xusb.c b/examples/xusb.c
> index 4e2f6a5..cae3d82 100644
> --- a/examples/xusb.c
> +++ b/examples/xusb.c
> uint16_t endian_test = 0xBE00;
> + char* error_lang = NULL;
@@ -1009,6 +1010,13 @@ int main(int argc, char** argv)
binary_name = argv[++j];
binary_dump = true;
break;
+ case 'l':
+ if ((j+1 >= argc) ||
(argv[j+1][0] == '-') || (argv[j+1][0] == '/')) {
+ printf(" Option -l
requires an ISO 639-1 language parameter");
+ return 1;
+ }
+ error_lang = argv[++j];
+ break;
case 'j':
// OLIMEX ARM-USB-TINY JTAG, 2
channel composite device - 2 interfaces
if (!VID && !PID) {
> r = libusb_init(NULL);
> if (r < 0)
> return r;
> + r = libusb_setlocale(error_lang);
>
Remarks:
- NULL is not a valid parameter for libusb_setlocale(). NULL is used
if no -l parameter is used
- You do not check the value returned by libusb_setlocale()
Proposal:
- call libusb_setlocale() _only_ when the 'l' argument is used
- display the error message if libusb_setlocale() fails
Code proposal:
case 'l':
r = libusb_setlocale(argv[++j]);
if (r != LIBUSB_SUCCESS) {
printf(" Option -l requires an ISO 639-1 language parameter");
return 1;
}
break;
--
Dr. Ludovic Rousseau
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
libusbx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libusbx-devel