X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=examples%2Ffind_all.c;h=936a82447056fdbb9a1c2cfdc18210399b43bd8d;hp=9f5d61c6311d5192186f99cdf672853c73b37974;hb=579b006f4873fa72c73d372660d158061497bcc9;hpb=6db32169ce93f0ec8e5a9b2c299760509ff1ef44 diff --git a/examples/find_all.c b/examples/find_all.c index 9f5d61c..936a824 100644 --- a/examples/find_all.c +++ b/examples/find_all.c @@ -1,20 +1,29 @@ -/* - Example for ftdi_usb_find_all() +/* find_all.c + + Example for ftdi_usb_find_all() + + This program is distributed under the GPL, version 2 */ #include +#include #include -int main(int argc, char **argv) +int main(void) { int ret, i; struct ftdi_context ftdic; struct ftdi_device_list *devlist, *curdev; char manufacturer[128], description[128]; - ftdi_init(&ftdic); + if (ftdi_init(&ftdic) < 0) + { + fprintf(stderr, "ftdi_init failed\n"); + return EXIT_FAILURE; + } - if((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6001)) < 0) { + if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6001)) < 0) + { fprintf(stderr, "ftdi_usb_find_all failed: %d (%s)\n", ret, ftdi_get_error_string(&ftdic)); return EXIT_FAILURE; } @@ -22,9 +31,11 @@ int main(int argc, char **argv) printf("Number of FTDI devices found: %d\n", ret); i = 0; - for (curdev = devlist; curdev != NULL; i++) { + for (curdev = devlist; curdev != NULL; i++) + { printf("Checking device: %d\n", i); - if((ret = ftdi_usb_get_strings(&ftdic, curdev->dev, &manufacturer, 128, description, 128, NULL, 0)) < 0) { + if ((ret = ftdi_usb_get_strings(&ftdic, curdev->dev, manufacturer, 128, description, 128, NULL, 0)) < 0) + { fprintf(stderr, "ftdi_usb_get_strings failed: %d (%s)\n", ret, ftdi_get_error_string(&ftdic)); return EXIT_FAILURE; }