[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_cano
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_canonical_path |
Date: |
Thu, 31 May 2018 19:12:25 +0200 |
Mostly a rewrite, in order to keep the loop simple.
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 0fc972030e..cb7a8cd589 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1669,25 +1669,29 @@ gchar *object_get_canonical_path(Object *obj)
Object *root = object_get_root();
char *newpath, *path = NULL;
- while (obj != root) {
+ if (obj == root) {
+ return g_strdup("/");
+ }
+
+ do {
char *component = object_get_canonical_path_component(obj);
- if (path) {
- newpath = g_strdup_printf("%s/%s", component, path);
- g_free(component);
+ if (!component) {
+ /* A canonical path must be complete, so discard what was
+ * collected so far.
+ */
g_free(path);
- path = newpath;
- } else {
- path = component;
+ return NULL;
}
+ newpath = g_strdup_printf("/%s%s", component, path ? path : "");
+ g_free(path);
+ g_free(component);
+ path = newpath;
obj = obj->parent;
- }
-
- newpath = g_strdup_printf("/%s", path ? path : "");
- g_free(path);
+ } while (obj != root);
- return newpath;
+ return path;
}
Object *object_resolve_path_component(Object *parent, const gchar *part)
--
2.17.0
- [Qemu-devel] [PULL 12/53] hw: Do not include "exec/ioport.h" if it is not necessary, (continued)
- [Qemu-devel] [PULL 12/53] hw: Do not include "exec/ioport.h" if it is not necessary, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 18/53] hw/misc/mips_itu: Cleanup includes, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 19/53] hw/misc/sga: Use the correct ISA include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 17/53] hw/block/nvme: Include "qemu/cutils.h" directly in the source file, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 14/53] hw: Do not include "sysemu/block-backend.h" if it is not necessary, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 22/53] hw/ide: Remove unused include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 21/53] hw/i386/pc: Remove unused include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 20/53] hw/hppa: Remove unused include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 23/53] hw: Clean "hw/devices.h" includes, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 24/53] qom: Document qom/device-list-properties implementation specific, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_canonical_path,
Paolo Bonzini <=
- [Qemu-devel] [PULL 26/53] virtio: free MemoryRegionCache when initialization fails, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 27/53] memory.h: Fix typo in documentation comment, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 28/53] memory: get rid of memory_region_init_reservation, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 30/53] hw/isa/superio: Fix inconsistent use of Chardev->be, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 31/53] mux: fix ctrl-a b again, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 33/53] exec.c: Initialize sa_flags passed to sigaction(), Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 29/53] memory: delete struct AddressSpaceOps, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 36/53] qemu-options: Mark the non-functional -clock option as deprecated, Paolo Bonzini, 2018/05/31