diff mbox series

[2/4] dissect: turn mk_name() into deanon()

Message ID 20200204165140.GA24343@redhat.com (mailing list archive)
State Mainlined, archived
Headers show
Series dissect: minor fixes/cleanups | expand

Commit Message

Oleg Nesterov Feb. 4, 2020, 4:51 p.m. UTC
Preparation. Change mk_name() to initialize base->ident itself, simplify it,
and rename to deanon().

Also change examine_sym_node() to accept "struct symbol *parent" rather than
"struct ident *root". Currently it is only used as ->ident holder, but this
will be changed.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 dissect.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/dissect.c b/dissect.c
index ff3a313..d34b38a 100644
--- a/dissect.c
+++ b/dissect.c
@@ -190,18 +190,22 @@  static struct symbol *report_symbol(usage_t mode, struct expression *expr)
 	return ret;
 }
 
-static inline struct ident *mk_name(struct ident *root, struct ident *node)
+static bool deanon(struct symbol *base, struct ident *node, struct symbol *parent)
 {
+	struct ident *pi = parent ? parent->ident : NULL;
 	char name[256];
 
+	if (!node)
+		return false;
+
 	snprintf(name, sizeof(name), "%.*s:%.*s",
-			root ? root->len : 0, root ? root->name : "",
-			node ? node->len : 0, node ? node->name : "");
+		pi ? pi->len : 0, pi ? pi->name : NULL, node->len, node->name);
 
-	return built_in_ident(name);
+	base->ident = built_in_ident(name);
+	return true;
 }
 
-static void examine_sym_node(struct symbol *node, struct ident *root)
+static void examine_sym_node(struct symbol *node, struct symbol *parent)
 {
 	struct symbol *base;
 	struct ident *name;
@@ -232,12 +236,12 @@  static void examine_sym_node(struct symbol *node, struct ident *root)
 				return;
 			base->evaluated = 1;
 
-			if (!base->ident && name)
-				base->ident = mk_name(root, name);
-			if (base->ident && reporter->r_symdef)
-				reporter->r_symdef(base);
+			if (base->ident || deanon(base, name, parent)) {
+				if (reporter->r_symdef)
+					reporter->r_symdef(base);
+			}
 			DO_LIST(base->symbol_list, mem,
-				examine_sym_node(mem, base->ident ?: root));
+				examine_sym_node(mem, base->ident ? base : parent));
 		default:
 			return;
 		}