diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-11 11:44:59 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-11 12:42:27 -0700 |
| commit | 99136562aa5b8599e1e565d8dace29554c84c969 (patch) | |
| tree | 5f7ad3b6bf7061e480a4d7d94c3fa2285fa36b3c /lib/assoc_array.c | |
| parent | f4ae215f0a9319207984a9a1ab6c5eb9f56cec0c (diff) | |
| download | linux-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.c | 15 |
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); |
