BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)

{

    BusState *bus;

    char *buf;

    int i,len;



    bus = qemu_mallocz(info->size);

    bus->info = info;

    bus->parent = parent;



    if (name) {

        /* use supplied name */

        bus->name = qemu_strdup(name);

    } else if (parent && parent->id) {

        /* parent device has id -> use it for bus name */

        len = strlen(parent->id) + 16;

        buf = qemu_malloc(len);

        snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);

        bus->name = buf;

    } else {

        /* no id -> use lowercase bus type for bus name */

        len = strlen(info->name) + 16;

        buf = qemu_malloc(len);

        len = snprintf(buf, len, "%s.%d", info->name,

                       parent ? parent->num_child_bus : 0);

        for (i = 0; i < len; i++)

            buf[i] = qemu_tolower(buf[i]);

        bus->name = buf;

    }



    LIST_INIT(&bus->children);

    if (parent) {

        LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);

        parent->num_child_bus++;

    }

    return bus;

}

BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)

{

    BusState *bus;

    char *buf;

    int i,len;



    bus = qemu_mallocz(info->size);

    bus->info = info;

    bus->parent = parent;



    if (name) {

        

        bus->name = qemu_strdup(name);

    } else if (parent && parent->id) {

        

        len = strlen(parent->id) + 16;

        buf = qemu_malloc(len);

        snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);

        bus->name = buf;

    } else {

        

        len = strlen(info->name) + 16;

        buf = qemu_malloc(len);

        len = snprintf(buf, len, "%s.%d", info->name,

                       parent ? parent->num_child_bus : 0);

        for (i = 0; i < len; i++)

            buf[i] = qemu_tolower(buf[i]);

        bus->name = buf;

    }



    LIST_INIT(&bus->children);

    if (parent) {

        LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);

        parent->num_child_bus++;

    }

    return bus;

}

BusState *FUNC_0(BusInfo *info, DeviceState *parent, const char *name)

{

    BusState *bus;

    char *VAR_0;

    int VAR_1,VAR_2;



    bus = qemu_mallocz(info->size);

    bus->info = info;

    bus->parent = parent;



    if (name) {

        

        bus->name = qemu_strdup(name);

    } else if (parent && parent->id) {

        

        VAR_2 = strlen(parent->id) + 16;

        VAR_0 = qemu_malloc(VAR_2);

        snprintf(VAR_0, VAR_2, "%s.%d", parent->id, parent->num_child_bus);

        bus->name = VAR_0;

    } else {

        

        VAR_2 = strlen(info->name) + 16;

        VAR_0 = qemu_malloc(VAR_2);

        VAR_2 = snprintf(VAR_0, VAR_2, "%s.%d", info->name,

                       parent ? parent->num_child_bus : 0);

        for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++)

            VAR_0[VAR_1] = qemu_tolower(VAR_0[VAR_1]);

        bus->name = VAR_0;

    }



    LIST_INIT(&bus->children);

    if (parent) {

        LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);

        parent->num_child_bus++;

    }

    return bus;

}

BusState *FUNC_0(BusInfo *info, DeviceState *parent, const char *name)
{ BusState *bus; char *VAR_0; int VAR_1,VAR_2; bus = qemu_mallocz(info->size); bus->info = info; bus->parent = parent; if (name) { bus->name = qemu_strdup(name); } else if (parent && parent->id) { VAR_2 = strlen(parent->id) + 16; VAR_0 = qemu_malloc(VAR_2); snprintf(VAR_0, VAR_2, "%s.%d", parent->id, parent->num_child_bus); bus->name = VAR_0; } else { VAR_2 = strlen(info->name) + 16; VAR_0 = qemu_malloc(VAR_2); VAR_2 = snprintf(VAR_0, VAR_2, "%s.%d", info->name,
parent ? parent->num_child_bus : 0); for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) VAR_0[VAR_1] = qemu_tolower(VAR_0[VAR_1]); bus->name = VAR_0; } LIST_INIT(&bus->children); if (parent) { LIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; } return bus; }