void usb_desc_create_serial(USBDevice *dev)

{

    DeviceState *hcd = dev->qdev.parent_bus->parent;

    const USBDesc *desc = usb_device_get_usb_desc(dev);

    int index = desc->id.iSerialNumber;

    char serial[64];

    char *path;

    int dst;



    if (dev->serial) {

        /* 'serial' usb bus property has priority if present */

        usb_desc_set_string(dev, index, dev->serial);

        return;

    }



    assert(index != 0 && desc->str[index] != NULL);

    dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]);

    path = qdev_get_dev_path(hcd);

    if (path) {

        dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", path);

    }

    dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", dev->port->path);

    usb_desc_set_string(dev, index, serial);

    g_free(path);

}

void usb_desc_create_serial(USBDevice *dev)

{

    DeviceState *hcd = dev->qdev.parent_bus->parent;

    const USBDesc *desc = usb_device_get_usb_desc(dev);

    int index = desc->id.iSerialNumber;

    char serial[64];

    char *path;

    int dst;



    if (dev->serial) {

        

        usb_desc_set_string(dev, index, dev->serial);

        return;

    }



    assert(index != 0 && desc->str[index] != NULL);

    dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]);

    path = qdev_get_dev_path(hcd);

    if (path) {

        dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", path);

    }

    dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", dev->port->path);

    usb_desc_set_string(dev, index, serial);

    g_free(path);

}

void FUNC_0(USBDevice *VAR_0)

{

    DeviceState *hcd = VAR_0->qdev.parent_bus->parent;

    const USBDesc *VAR_1 = usb_device_get_usb_desc(VAR_0);

    int VAR_2 = VAR_1->id.iSerialNumber;

    char VAR_3[64];

    char *VAR_4;

    int VAR_5;



    if (VAR_0->VAR_3) {

        

        usb_desc_set_string(VAR_0, VAR_2, VAR_0->VAR_3);

        return;

    }



    assert(VAR_2 != 0 && VAR_1->str[VAR_2] != NULL);

    VAR_5 = snprintf(VAR_3, sizeof(VAR_3), "%s", VAR_1->str[VAR_2]);

    VAR_4 = qdev_get_dev_path(hcd);

    if (VAR_4) {

        VAR_5 += snprintf(VAR_3+VAR_5, sizeof(VAR_3)-VAR_5, "-%s", VAR_4);

    }

    VAR_5 += snprintf(VAR_3+VAR_5, sizeof(VAR_3)-VAR_5, "-%s", VAR_0->port->VAR_4);

    usb_desc_set_string(VAR_0, VAR_2, VAR_3);

    g_free(VAR_4);

}

void FUNC_0(USBDevice *VAR_0)
{ DeviceState *hcd = VAR_0->qdev.parent_bus->parent; const USBDesc *VAR_1 = usb_device_get_usb_desc(VAR_0); int VAR_2 = VAR_1->id.iSerialNumber; char VAR_3[64]; char *VAR_4; int VAR_5; if (VAR_0->VAR_3) { usb_desc_set_string(VAR_0, VAR_2, VAR_0->VAR_3); return; } assert(VAR_2 != 0 && VAR_1->str[VAR_2] != NULL); VAR_5 = snprintf(VAR_3, sizeof(VAR_3), "%s", VAR_1->str[VAR_2]); VAR_4 = qdev_get_dev_path(hcd); if (VAR_4) { VAR_5 += snprintf(VAR_3+VAR_5, sizeof(VAR_3)-VAR_5, "-%s", VAR_4); } VAR_5 += snprintf(VAR_3+VAR_5, sizeof(VAR_3)-VAR_5, "-%s", VAR_0->port->VAR_4); usb_desc_set_string(VAR_0, VAR_2, VAR_3); g_free(VAR_4); }