]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-canusb-linux.c
Check whether libusb_init() succeeds, and give up if it doesn't.
[libpcap] / pcap-canusb-linux.c
index 5abfe18ec71f6ec673cd7802467a3259196fe5f2..373f0a98c94af8bd7f65ec961a614963cfc62427 100644 (file)
@@ -96,8 +96,15 @@ int canusb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
     unsigned char buf[96];
     int cnt, i;
     
-    libusb_init(&fdctx);
-        
+    if (libusb_init(&fdctx) != 0) {
+        /*
+         * XXX - if this doesn't just mean "no USB file system mounted",
+         * perhaps we should report a real error rather than just
+         * saying "no CANUSB devices".
+         */
+        return 0;
+    } 
+
     cnt = libusb_get_device_list(fdctx,&devs);
 
     for(i=0;i<cnt;i++)