From fa800750bc1e885ef11aefe86e5e016884ff1e44 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 18 Sep 2006 22:13:27 +0000 Subject: [PATCH] fix hotplug output: check (a->port & GP_PORT_USB) before reading any USB values git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@9182 67ed7778-7388-44ab-90cf-0a291f65f57c --- packaging/generic/print-camera-list.c | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/packaging/generic/print-camera-list.c b/packaging/generic/print-camera-list.c index da97dceb1..c6bd825ef 100644 --- a/packaging/generic/print-camera-list.c +++ b/packaging/generic/print-camera-list.c @@ -150,28 +150,31 @@ hotplug_camera_func (const func_params_t *params, ?((*params->argv)[0]) :(GP_USB_HOTPLUG_SCRIPT); - if (a->usb_vendor) { /* usb product id may be zero! */ - class = 0; - subclass = 0; - proto = 0; - flags = GP_USB_HOTPLUG_MATCH_VENDOR_ID | GP_USB_HOTPLUG_MATCH_PRODUCT_ID; - usb_vendor = a->usb_vendor; - usb_product = a->usb_product; - } else if (a->usb_class) { - class = a->usb_class; - subclass = a->usb_subclass; - proto = a->usb_protocol; - flags = GP_USB_HOTPLUG_MATCH_INT_CLASS; - if (subclass != -1) - flags |= GP_USB_HOTPLUG_MATCH_INT_SUBCLASS; - else + if (a->port & GP_PORT_USB) { + if (a->usb_vendor) { /* usb product id may be zero! */ + class = 0; subclass = 0; - if (proto != -1) - flags |= GP_USB_HOTPLUG_MATCH_INT_PROTOCOL; - else proto = 0; - usb_vendor = 0; - usb_product = 0; + flags = (GP_USB_HOTPLUG_MATCH_VENDOR_ID + | GP_USB_HOTPLUG_MATCH_PRODUCT_ID); + usb_vendor = a->usb_vendor; + usb_product = a->usb_product; + } else if (a->usb_class) { + class = a->usb_class; + subclass = a->usb_subclass; + proto = a->usb_protocol; + flags = GP_USB_HOTPLUG_MATCH_INT_CLASS; + if (subclass != -1) + flags |= GP_USB_HOTPLUG_MATCH_INT_SUBCLASS; + else + subclass = 0; + if (proto != -1) + flags |= GP_USB_HOTPLUG_MATCH_INT_PROTOCOL; + else + proto = 0; + usb_vendor = 0; + usb_product = 0; + } } else { /* not a USB camera */ return 0;