Show a good example: Always check the return value of ftdi_init
[libftdi] / examples / bitbang_cbus.c
index e3f2a41..1ec574b 100644 (file)
 #include <stdlib.h>
 #include <ftdi.h>
 
-int main(int argc, char **argv)
+int main(void)
 {
     struct ftdi_context ftdic;
-    int f,i;
+    int f;
     unsigned char buf[1];
     unsigned char bitmask;
     unsigned char input[10];
 
-    ftdi_init(&ftdic);
+    if (ftdi_init(&ftdic) < 0)
+    {
+        fprintf(stderr, "ftdi_init failed\n");
+        return EXIT_FAILURE;
+    }
 
     f = ftdi_usb_open(&ftdic, 0x0403, 0x6001);
     if (f < 0 && f != -5)