Am 14.01.2013 13:19, schrieb Markus Armbruster: > Andreas Färber <afaer...@suse.de> writes: > >> This allows to navigate partial well-known paths from an object. > > Why does making the argument const allow such navigation?
Without const, object_resolve_path_component(foo, "bar") results in a compile error (09/10 accesses "ide[1]" etc. to avoid exposing the full MacIOState). Apparently this function was so far only used on dynamically generated (non-const) arrays: qom/container.c: child = object_resolve_path_component(obj, parts[i]); qom/object.c: child = object_resolve_path_component(parent, parts[index]); >> Signed-off-by: Andreas Färber <afaer...@suse.de> >> Cc: Anthony Liguori <anth...@codemonkey.ws> >> --- >> include/qom/object.h | 2 +- >> qom/object.c | 2 +- >> 2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-) >> >> diff --git a/include/qom/object.h b/include/qom/object.h >> index d43b289..1ef2f0e 100644 >> --- a/include/qom/object.h >> +++ b/include/qom/object.h >> @@ -900,7 +900,7 @@ Object *object_resolve_path_type(const char *path, const >> char *typename, >> * >> * Returns: The resolved object or NULL on path lookup failure. >> */ >> -Object *object_resolve_path_component(Object *parent, gchar *part); >> +Object *object_resolve_path_component(Object *parent, const gchar *part); >> /** >> * object_property_add_child: >> diff --git a/qom/object.c b/qom/object.c >> index 351b88c..03e6f24 100644 >> --- a/qom/object.c >> +++ b/qom/object.c >> @@ -1017,7 +1017,7 @@ gchar *object_get_canonical_path(Object *obj) >> return newpath; >> } >> >> -Object *object_resolve_path_component(Object *parent, gchar *part) >> +Object *object_resolve_path_component(Object *parent, const gchar *part) >> { >> ObjectProperty *prop = object_property_find(parent, part, NULL); >> if (prop == NULL) { > > Unrelated: do we really want to go along with glib's basic type typedef > silliness? Elsewhere I have adopted the exact GLib signature since typedefs can be changed at any time. In particular the GCompareFunc using gconstpointer, gint, etc. Not saying I find their GLib usage useful. I admit I didn't review object_property_find(), which uses const char*. So I wouldn't mind sending a v2 if non-g is preferred. Or Anthony or Stefan could just edit the patch in my name before applying. :) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg