git: cb205f5ed808 - main - pctrie_lookup_range: don't write the null
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 14 May 2025 23:57:45 UTC
The branch main has been updated by dougm:
URL: https://cgit.FreeBSD.org/src/commit/?id=cb205f5ed80867be747335e98cffad75873ba60b
commit cb205f5ed80867be747335e98cffad75873ba60b
Author: Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2025-05-14 23:56:34 +0000
Commit: Doug Moore <dougm@FreeBSD.org>
CommitDate: 2025-05-14 23:56:34 +0000
pctrie_lookup_range: don't write the null
There's no reason to write the NULL pointer value into the array when
pctrie_lookup_range finds an item missing.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D50353
---
sys/kern/subr_pctrie.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
index e91966652f80..67566a2d1bfe 100644
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -617,16 +617,16 @@ _pctrie_lookup_range(struct pctrie *ptree, struct pctrie_node *node,
struct pctrie_node **parent_out, smr_t smr, enum pctrie_access access)
{
struct pctrie_node *parent;
+ uint64_t *val;
int base, end, i;
parent = node;
for (i = 0; i < count;) {
node = _pctrie_lookup_node(ptree, parent, index + i, &parent,
smr, access);
- value[i] = pctrie_match_value(node, index + i);
- if (value[i] == NULL)
+ if ((val = pctrie_match_value(node, index + i)) == NULL)
break;
- ++i;
+ value[i++] = val;
base = (index + i) % PCTRIE_COUNT;
if (base == 0 || parent == NULL || parent->pn_clev != 0)
continue;
@@ -634,10 +634,9 @@ _pctrie_lookup_range(struct pctrie *ptree, struct pctrie_node *node,
while (i < end) {
node = pctrie_node_load(&parent->pn_child[base++],
smr, access);
- value[i] = pctrie_toval(node);
- if (value[i] == NULL)
+ if ((val = pctrie_toval(node)) == NULL)
break;
- ++i;
+ value[i++] = val;
}
if (i < end)
break;