From: Andrew 'Necromant' Andrianov Date: Sun, 21 Dec 2014 11:26:57 +0000 (+0300) Subject: Do not segfault when no device is present X-Git-Tag: v0.1~21 X-Git-Url: http://git.linex4red.de/pub/pl2303-ft232-gpio.git/commitdiff_plain/13516fc96d4f88897f182212e834869259e6d783 Do not segfault when no device is present Fixes #1 Signed-off-by: Andrew 'Necromant' Andrianov --- diff --git a/main.c b/main.c index f6b1643..f24e40f 100644 --- a/main.c +++ b/main.c @@ -159,8 +159,8 @@ void check_handle(usb_dev_handle **h) /* TODO: Make a proper way to select different PL2303 devices. */ *h = nc_usb_open(I_VENDOR_NUM, I_PRODUCT_NUM, NULL, NULL, NULL); - if (!h) { - fprintf(stderr, "No PL2303 USB device found ;(\n"); + if (!(*h)) { + fprintf(stderr, "No PL2303 USB device %04x:%04x found ;(\n", I_VENDOR_NUM, I_PRODUCT_NUM); exit(1); } @@ -231,9 +231,5 @@ int main(int argc, char* argv[]) } } - return 0; - - //GP0 == LDR - //GP1 == RST }