static BusState *qbus_find(const char *path)

{

    DeviceState *dev;

    BusState *bus;

    char elem[128], msg[256];

    int pos, len;



    /* find start element */

    if (path[0] == '/') {

        bus = main_system_bus;

        pos = 0;

    } else {

        if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\")\n", path);

            return NULL;

        }

        bus = qbus_find_recursive(main_system_bus, elem, NULL);

        if (!bus) {

            qemu_error("bus \"%s\" not found\n", elem);

            return NULL;

        }

        pos = len;

    }



    for (;;) {

        if (path[pos] == '\0') {

            /* we are done */

            return bus;

        }



        /* find device */

        if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);

            return NULL;

        }

        pos += len;

        dev = qbus_find_dev(bus, elem);

        if (!dev) {

            qbus_list_dev(bus, msg, sizeof(msg));

            qemu_error("device \"%s\" not found\n%s\n", elem, msg);

            return NULL;

        }

        if (path[pos] == '\0') {

            /* last specified element is a device.  If it has exactly

             * one child bus accept it nevertheless */

            switch (dev->num_child_bus) {

            case 0:

                qemu_error("device has no child bus (%s)\n", path);

                return NULL;

            case 1:

                return LIST_FIRST(&dev->child_bus);

            default:

                qbus_list_bus(dev, msg, sizeof(msg));

                qemu_error("device has multiple child busses (%s)\n%s\n",

                           path, msg);

                return NULL;

            }

        }



        /* find bus */

        if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);

            return NULL;

        }

        pos += len;

        bus = qbus_find_bus(dev, elem);

        if (!bus) {

            qbus_list_bus(dev, msg, sizeof(msg));

            qemu_error("child bus \"%s\" not found\n%s\n", elem, msg);

            return NULL;

        }

    }

}

static BusState *qbus_find(const char *path)

{

    DeviceState *dev;

    BusState *bus;

    char elem[128], msg[256];

    int pos, len;



    

    if (path[0] == '/') {

        bus = main_system_bus;

        pos = 0;

    } else {

        if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\")\n", path);

            return NULL;

        }

        bus = qbus_find_recursive(main_system_bus, elem, NULL);

        if (!bus) {

            qemu_error("bus \"%s\" not found\n", elem);

            return NULL;

        }

        pos = len;

    }



    for (;;) {

        if (path[pos] == '\0') {

            

            return bus;

        }



        

        if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);

            return NULL;

        }

        pos += len;

        dev = qbus_find_dev(bus, elem);

        if (!dev) {

            qbus_list_dev(bus, msg, sizeof(msg));

            qemu_error("device \"%s\" not found\n%s\n", elem, msg);

            return NULL;

        }

        if (path[pos] == '\0') {

            



            switch (dev->num_child_bus) {

            case 0:

                qemu_error("device has no child bus (%s)\n", path);

                return NULL;

            case 1:

                return LIST_FIRST(&dev->child_bus);

            default:

                qbus_list_bus(dev, msg, sizeof(msg));

                qemu_error("device has multiple child busses (%s)\n%s\n",

                           path, msg);

                return NULL;

            }

        }



        

        if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {

            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);

            return NULL;

        }

        pos += len;

        bus = qbus_find_bus(dev, elem);

        if (!bus) {

            qbus_list_bus(dev, msg, sizeof(msg));

            qemu_error("child bus \"%s\" not found\n%s\n", elem, msg);

            return NULL;

        }

    }

}

static BusState *FUNC_0(const char *path)

{

    DeviceState *dev;

    BusState *bus;

    char VAR_0[128], VAR_1[256];

    int VAR_2, VAR_3;



    

    if (path[0] == '/') {

        bus = main_system_bus;

        VAR_2 = 0;

    } else {

        if (sscanf(path, "%127[^/]%n", VAR_0, &VAR_3) != 1) {

            qemu_error("path parse error (\"%s\")\n", path);

            return NULL;

        }

        bus = qbus_find_recursive(main_system_bus, VAR_0, NULL);

        if (!bus) {

            qemu_error("bus \"%s\" not found\n", VAR_0);

            return NULL;

        }

        VAR_2 = VAR_3;

    }



    for (;;) {

        if (path[VAR_2] == '\0') {

            

            return bus;

        }



        

        if (sscanf(path+VAR_2, "/%127[^/]%n", VAR_0, &VAR_3) != 1) {

            qemu_error("path parse error (\"%s\" VAR_2 %d)\n", path, VAR_2);

            return NULL;

        }

        VAR_2 += VAR_3;

        dev = qbus_find_dev(bus, VAR_0);

        if (!dev) {

            qbus_list_dev(bus, VAR_1, sizeof(VAR_1));

            qemu_error("device \"%s\" not found\n%s\n", VAR_0, VAR_1);

            return NULL;

        }

        if (path[VAR_2] == '\0') {

            



            switch (dev->num_child_bus) {

            case 0:

                qemu_error("device has no child bus (%s)\n", path);

                return NULL;

            case 1:

                return LIST_FIRST(&dev->child_bus);

            default:

                qbus_list_bus(dev, VAR_1, sizeof(VAR_1));

                qemu_error("device has multiple child busses (%s)\n%s\n",

                           path, VAR_1);

                return NULL;

            }

        }



        

        if (sscanf(path+VAR_2, "/%127[^/]%n", VAR_0, &VAR_3) != 1) {

            qemu_error("path parse error (\"%s\" VAR_2 %d)\n", path, VAR_2);

            return NULL;

        }

        VAR_2 += VAR_3;

        bus = qbus_find_bus(dev, VAR_0);

        if (!bus) {

            qbus_list_bus(dev, VAR_1, sizeof(VAR_1));

            qemu_error("child bus \"%s\" not found\n%s\n", VAR_0, VAR_1);

            return NULL;

        }

    }

}

static BusState *FUNC_0(const char *path)
{ DeviceState *dev; BusState *bus; char VAR_0[128], VAR_1[256]; int VAR_2, VAR_3; if (path[0] == '/') { bus = main_system_bus; VAR_2 = 0; } else { if (sscanf(path, "%127[^/]%n", VAR_0, &VAR_3) != 1) { qemu_error("path parse error (\"%s\")\n", path); return NULL; } bus = qbus_find_recursive(main_system_bus, VAR_0, NULL); if (!bus) { qemu_error("bus \"%s\" not found\n", VAR_0); return NULL; } VAR_2 = VAR_3; } for (;;) { if (path[VAR_2] == '\0') { return bus; } if (sscanf(path+VAR_2, "/%127[^/]%n", VAR_0, &VAR_3) != 1) { qemu_error("path parse error (\"%s\" VAR_2 %d)\n", path, VAR_2); return NULL; } VAR_2 += VAR_3; dev = qbus_find_dev(bus, VAR_0); if (!dev) { qbus_list_dev(bus, VAR_1, sizeof(VAR_1)); qemu_error("device \"%s\" not found\n%s\n", VAR_0, VAR_1); return NULL; } if (path[VAR_2] == '\0') { switch (dev->num_child_bus) { case 0:
qemu_error("device has no child bus (%s)\n", path); return NULL; case 1:
return LIST_FIRST(&dev->child_bus); default:
qbus_list_bus(dev, VAR_1, sizeof(VAR_1)); qemu_error("device has multiple child busses (%s)\n%s\n",
path, VAR_1); return NULL; } } if (sscanf(path+VAR_2, "/%127[^/]%n", VAR_0, &VAR_3) != 1) { qemu_error("path parse error (\"%s\" VAR_2 %d)\n", path, VAR_2); return NULL; } VAR_2 += VAR_3; bus = qbus_find_bus(dev, VAR_0); if (!bus) { qbus_list_bus(dev, VAR_1, sizeof(VAR_1)); qemu_error("child bus \"%s\" not found\n%s\n", VAR_0, VAR_1); return NULL; } } }