target/i386/translate: avoid shadowed local variables
[qemu/kevin.git] / qom / container.c
blob455e8410c66dad02eee86ff94f3a77ed26216295
1 /*
2 * Device Container
4 * Copyright IBM, Corp. 2012
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "qom/object.h"
15 #include "qemu/module.h"
17 static const TypeInfo container_info = {
18 .name = "container",
19 .parent = TYPE_OBJECT,
22 static void container_register_types(void)
24 type_register_static(&container_info);
27 Object *container_get(Object *root, const char *path)
29 Object *obj, *child;
30 char **parts;
31 int i;
33 parts = g_strsplit(path, "/", 0);
34 assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
35 obj = root;
37 for (i = 1; parts[i] != NULL; i++, obj = child) {
38 child = object_resolve_path_component(obj, parts[i]);
39 if (!child) {
40 child = object_new("container");
41 object_property_add_child(obj, parts[i], child);
42 object_unref(child);
46 g_strfreev(parts);
48 return obj;
52 type_init(container_register_types)