Commit 64a064ce authored by Rong Tao's avatar Rong Tao Committed by Alexei Starovoitov
Browse files

selftests/bpf: rbtree: Fix incorrect global variable usage



Within __add_three() function, should use function parameters instead of
global variables. So that the variables groot_nested.inner.root and
groot_nested.inner.glock in rbtree_add_nodes_nested() are tested
correctly.

Signed-off-by: default avatarRong Tao <rongtao@cestc.cn>
Link: https://lore.kernel.org/r/tencent_3DD7405C0839EBE2724AC5FA357B5402B105@qq.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent a570f386
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -61,19 +61,19 @@ static long __add_three(struct bpf_rb_root *root, struct bpf_spin_lock *lock)
	}
	m->key = 1;

	bpf_spin_lock(&glock);
	bpf_rbtree_add(&groot, &n->node, less);
	bpf_rbtree_add(&groot, &m->node, less);
	bpf_spin_unlock(&glock);
	bpf_spin_lock(lock);
	bpf_rbtree_add(root, &n->node, less);
	bpf_rbtree_add(root, &m->node, less);
	bpf_spin_unlock(lock);

	n = bpf_obj_new(typeof(*n));
	if (!n)
		return 3;
	n->key = 3;

	bpf_spin_lock(&glock);
	bpf_rbtree_add(&groot, &n->node, less);
	bpf_spin_unlock(&glock);
	bpf_spin_lock(lock);
	bpf_rbtree_add(root, &n->node, less);
	bpf_spin_unlock(lock);
	return 0;
}