]> git.proxmox.com Git - qemu.git/blobdiff - usb-bsd.c
Don't leak VLANClientState on PCI hot remove
[qemu.git] / usb-bsd.c
index 567aa81d8137244d57f914ecdfe26ef960e038e2..fa4093cc1271ecd2ae59b4a7d5e344c36b364767 100644 (file)
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -68,7 +68,7 @@ static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
     ep = UE_GET_ADDR(ep);
 
     if (dev->ep_fd[ep] < 0) {
-#if __FreeBSD__
+#ifdef __FreeBSD__
         snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
 #else
         snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
@@ -178,7 +178,7 @@ static int usb_host_handle_control(USBDevice *dev,
         req.ucr_flags = USBD_SHORT_XFER_OK;
 
         ret = ioctl(s->devfd, USB_SET_TIMEOUT, &timeout);
-#if (__NetBSD__ || __OpenBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
         if (ret < 0 && errno != EINVAL) {
 #else
         if (ret < 0) {
@@ -321,7 +321,7 @@ USBDevice *usb_host_device_open(const char *devname)
         return NULL;
     }
 
-#if __FreeBSD__
+#ifdef __FreeBSD__
     snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
 #else
     snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]);
@@ -340,8 +340,6 @@ USBDevice *usb_host_device_open(const char *devname)
 
     if (dfd >= 0) {
         dev = qemu_mallocz(sizeof(USBHostDevice));
-        if (!dev)
-            goto fail;
         dev->devfd = dfd;
 
         if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) {
@@ -372,7 +370,7 @@ USBDevice *usb_host_device_open(const char *devname)
                      "host:%s", devname);
 
         pstrcpy(dev->devpath, sizeof(dev->devpath), "/dev/");
-       strcat(dev->devpath, dev_info.udi_devnames[0]);
+        pstrcat(dev->devpath, sizeof(dev->devpath), dev_info.udi_devnames[0]);
 
         /* Mark the endpoints as not yet open */
         for (i = 0; i < USB_MAX_ENDPOINTS; i++)
@@ -413,7 +411,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
             if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
                 continue;
 
-#if __FreeBSD__
+#ifdef __FreeBSD__
             snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
 #else
             snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);
@@ -550,10 +548,10 @@ static const char *usb_class_str(uint8_t class)
     return p->class_name;
 }
 
-void usb_info_device(int bus_num, int addr, int class_id,
-                     int vendor_id, int product_id,
-                     const char *product_name,
-                     int speed)
+static void usb_info_device(int bus_num, int addr, int class_id,
+                            int vendor_id, int product_id,
+                            const char *product_name,
+                            int speed)
 {
     const char *class_str, *speed_str;