summaryrefslogtreecommitdiff
path: root/lib/assoc_array.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-11 11:44:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-11 12:42:27 -0700
commit99136562aa5b8599e1e565d8dace29554c84c969 (patch)
tree5f7ad3b6bf7061e480a4d7d94c3fa2285fa36b3c /lib/assoc_array.c
parentf4ae215f0a9319207984a9a1ab6c5eb9f56cec0c (diff)
downloadlinux-next-assoc-array-fixes.tar.gz
linux-next-assoc-array-fixes.zip
assoc_array: use assoc_array_parent_link() when splitting a shortcutassoc-array-fixes
assoc_array_insert_mid_shortcut() works out by hand which pointer leads to the shortcut it splits: the same cases as assoc_array_parent_link(), with a BUG() for a shortcut behind anything but a node. Use the function, and keep the check as a BUG_ON(). No functional change. Assisted-by: LLM Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/assoc_array.c')
-rw-r--r--lib/assoc_array.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index 7a63298a7885..729efdf83acd 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -869,7 +869,7 @@ static bool assoc_array_insert_mid_shortcut(struct assoc_array_edit *edit,
struct assoc_array_walk_result *result)
{
struct assoc_array_shortcut *shortcut, *new_s0, *new_s1;
- struct assoc_array_node *node, *new_n0, *side;
+ struct assoc_array_node *new_n0, *side;
unsigned long sc_segments, dissimilarity, blank;
size_t keylen;
int level, sc_level, diff;
@@ -895,14 +895,11 @@ static bool assoc_array_insert_mid_shortcut(struct assoc_array_edit *edit,
diff += sc_level & ~ASSOC_ARRAY_KEY_CHUNK_MASK;
pr_devel("diff=%d\n", diff);
- if (!shortcut->back_pointer) {
- edit->set[0].ptr = &edit->array->root;
- } else if (assoc_array_ptr_is_node(shortcut->back_pointer)) {
- node = assoc_array_ptr_to_node(shortcut->back_pointer);
- edit->set[0].ptr = &node->slots[shortcut->parent_slot];
- } else {
- BUG();
- }
+ BUG_ON(shortcut->back_pointer &&
+ !assoc_array_ptr_is_node(shortcut->back_pointer));
+ edit->set[0].ptr = assoc_array_parent_link(edit->array,
+ shortcut->back_pointer,
+ shortcut->parent_slot);
edit->excised_meta[0] = assoc_array_shortcut_to_ptr(shortcut);