From a26e7bd6323288be21676ac9d8e8beccb74a1209 Mon Sep 17 00:00:00 2001 From: Kristoffer Ellersgaard Koch Date: Wed, 1 Mar 2023 14:33:46 +0100 Subject: usbreset: Allow idProduct and idVendor to be 0 idProduct at least, is valid as 0, and I guess idVendor can typically be left at 0 while developing some new usb thing. Signed-off-by: Kristoffer Ellersgaard Koch --- usbreset.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usbreset.c b/usbreset.c index 0fcba41..68f87cb 100644 --- a/usbreset.c +++ b/usbreset.c @@ -65,6 +65,8 @@ static struct usbentry *parse_devlist(DIR *d) } while (!isdigit(e->d_name[0]) || strchr(e->d_name, ':')); memset(&dev, 0, sizeof(dev)); + dev.vendor_id = -1; + dev.product_id = -1; attr = sysfs_attr(e->d_name, "busnum"); if (attr) @@ -90,7 +92,7 @@ static struct usbentry *parse_devlist(DIR *d) if (attr) strcpy(dev.product_name, attr); - if (dev.bus_num && dev.dev_num && dev.vendor_id && dev.product_id) + if (dev.bus_num && dev.dev_num && dev.vendor_id >= 0 && dev.product_id >= 0) return &dev; return NULL; -- cgit v1.2.1