Skip to contentSkip to conversation

dissect: simplify lookup_member()

PATCH Applied Oleg Nesterov 3 participants 4 messages Dec 14, 2006 – Feb 28, 2007 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dissect: simplify lookup_member()

Change examine_sym_node() to recursively inspect the members of SYM_STRUCT. This allows us to simplify lookup_member(): no need to do examine_sym_node(), the member was already examined.

This is also good because now ->r_symdef(member) is called on declaration, not when dissect detects the first usage of ->member.

dissect.c renamed from dissect.c~ +9 -12
@@ -210,13 +210,16 @@ static void examine_sym_node(struct symb
 		case SYM_STRUCT: case SYM_UNION: //case SYM_ENUM:
 			if (base->evaluated)
 				return;
+			if (!base->symbol_list)
+				return;
+			base->evaluated = 1;
+
 			if (!base->ident && name)
 				base->ident = mk_name(root, name);
-			if (!base->ident || !base->symbol_list)
-				return;
-			if (reporter->r_symdef)
+			if (base->ident && reporter->r_symdef)
 				reporter->r_symdef(base);
-			base->evaluated = 1;
+			DO_LIST(base->symbol_list, mem,
+				examine_sym_node(mem, base->ident ?: root));
 		default:
 			return;
 		}
@@ -263,14 +266,8 @@ found:
 
 static struct symbol *lookup_member(struct symbol *type, struct ident *name, int *addr)
 {
-	struct symbol *node = __lookup_member(type, name, addr);
-
-	if (node != NULL)
-		examine_sym_node(node, type->ident);
-	else
-		node = no_member(name);
-
-	return node;
+	return __lookup_member(type, name, addr)
+		?: no_member(name);
 }
 
 static struct expression *peek_preop(struct expression *expr, int op)
#1 lore raw
Quoted 8 lines · Oleg Nesterov

Change examine_sym_node() to recursively inspect the members of SYM_STRUCT. This allows us to simplify lookup_member(): no need to do examine_sym_node(), the member was already examined.

This is also good because now ->r_symdef(member) is called on declaration, not when dissect detects the first usage of ->member.

Applied.

- Josh Triplett

#2 lore raw
Quoted 11 lines · Josh Triplett
Quoted 8 lines · Oleg Nesterov

Change examine_sym_node() to recursively inspect the members of SYM_STRUCT. This allows us to simplify lookup_member(): no need to do examine_sym_node(), the member was already examined.

This is also good because now ->r_symdef(member) is called on declaration, not when dissect detects the first usage of ->member.

Applied.

Josh, I'll really appreciate if you push your changes to the publicly available repository as soon as you post "applied". This way, when I have some time for sparse, I read the list, see your post, update sparse and see how it's affecting my projects.

If the changes are only available the next day, I'll probably be busy with other things.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw

Git mirror delay

Quoted 12 lines · Pavel Roskin
Quoted 10 lines · Josh Triplett
Quoted 8 lines · Oleg Nesterov

Change examine_sym_node() to recursively inspect the members of SYM_STRUCT. This allows us to simplify lookup_member(): no need to do examine_sym_node(), the member was already examined.

This is also good because now ->r_symdef(member) is called on declaration, not when dissect detects the first usage of ->member.

Applied.

Quoted 7 lines

Josh, I'll really appreciate if you push your changes to the publicly available repository as soon as you post "applied". This way, when I have some time for sparse, I read the list, see your post, update sparse and see how it's affecting my projects.

If the changes are only available the next day, I'll probably be busy with other things.

To the best of my knowledge, I always push out changes before I send the corresponding "applied" mail. However, I often send the mail a few moments after pushing out the change, and the kernel.org mirroring processes do not run the instant I push changes out. In particular, I just confirmed that a fresh clone of git://git.kernel.org/pub/scm/linux/kernel/git/josh/sparse.git
did not include the changes I've pushed about 8 hours ago today.

The new git.kernel.org server may help alleviate some of the issues that lead to this high mirroring delay.

- Josh Triplett