From 8a919f09087cf70e15196f79aa8e885a8fa01595 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 15 May 2012 20:38:47 -0400 Subject: [PATCH] uobject: Include package names in package fullname. Now that we have access to the package in deserialize, we can include its name. --- src/uobject/uobject.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/uobject/uobject.c b/src/uobject/uobject.c index df875b2..b8c2479 100644 --- a/src/uobject/uobject.c +++ b/src/uobject/uobject.c @@ -314,17 +314,17 @@ static int deserialize(UObject *uo) /* * Get the full hierarchical object name for an export, used for diagnostics. - * Currently, this does not include the package name (which is actually - * required for this to be a "full" name) as it's not yet passed to the - * deserialize method. + * The package name is passed in pname. * * Returns a buffer allocated by malloc on success, or NULL on failure. */ -static char *get_obj_fullname(const struct upkg_export *e) +static char *get_obj_fullname(const char *pname, const struct upkg_export *e) { - size_t total_len = 0, len; + size_t total_len = strlen(pname) + 1, len; char *fullname; + assert(e != NULL); + for (const struct upkg_export *c = e; c; c = c->parent) { len = strlen(c->name) + 1; if (total_len > SIZE_MAX - len) @@ -345,6 +345,10 @@ static char *get_obj_fullname(const struct upkg_export *e) fullname[total_len + len] = c == e ? '\0' : '.'; } + assert(total_len == strlen(pname)+1); + memcpy(fullname, pname, total_len-1); + fullname[total_len-1] = '.'; + return fullname; } @@ -371,7 +375,7 @@ int u_object_deserialize(GObject *obj, GTypeModule *pkg, unsigned long idx) e = upkg_get_export(upkg, idx); if (!e) return -1; - uo->pkg_name = get_obj_fullname(e); + uo->pkg_name = get_obj_fullname(pkg->name, e); if (!uo->pkg_name) return -1; -- 2.43.0