Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
24
Issues
24
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
f31e128e
Commit
f31e128e
authored
Oct 24, 2016
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'qp-coverity' into 'master'
QP coverity See merge request !596
parents
afa917bd
883b7c65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
src/contrib/qp-trie/qp.c
src/contrib/qp-trie/qp.c
+8
-3
No files found.
src/contrib/qp-trie/qp.c
View file @
f31e128e
...
...
@@ -611,11 +611,12 @@ int trie_get_leq(trie_t *tbl, const char *key, uint32_t len, trie_val_t **val)
*
val
=
NULL
;
// so on failure we can just return;
if
(
tbl
->
weight
==
0
)
return
KNOT_ENOENT
;
{
// Intentionally un-indented; until end of function, to bound cleanup attr.
// First find a key with longest-matching prefix
__attribute__
((
cleanup
(
ns_cleanup
)))
nstack_t
ns_local
;
ns_init
(
&
ns_local
,
tbl
);
nstack_t
*
ns
=
&
ns_local
;
ns_init
(
ns
,
tbl
);
branch_t
bp
;
int
un_leaf
;
// first unmatched character in the leaf
ERR_RETURN
(
ns_find_branch
(
ns
,
key
,
len
,
&
bp
,
&
un_leaf
));
...
...
@@ -657,6 +658,7 @@ success:
assert
(
!
isbranch
(
ns
->
stack
[
ns
->
len
-
1
]));
*
val
=
&
ns
->
stack
[
ns
->
len
-
1
]
->
leaf
.
val
;
return
1
;
}
}
/*! \brief Initialize a new leaf, copying the key, and returning failure code. */
...
...
@@ -690,11 +692,12 @@ trie_val_t* trie_get_ins(trie_t *tbl, const char *key, uint32_t len)
++
tbl
->
weight
;
return
&
tbl
->
root
.
leaf
.
val
;
}
{
// Intentionally un-indented; until end of function, to bound cleanup attr.
// Find the branching-point
__attribute__
((
cleanup
(
ns_cleanup
)))
nstack_t
ns_local
;
ns_init
(
&
ns_local
,
tbl
);
nstack_t
*
ns
=
&
ns_local
;
ns_init
(
ns
,
tbl
);
branch_t
bp
;
// branch-point: index and flags signifying the longest common prefix
int
k2
;
// the first unmatched character in the leaf
if
(
unlikely
(
ns_find_branch
(
ns
,
key
,
len
,
&
bp
,
&
k2
)))
...
...
@@ -734,7 +737,8 @@ trie_val_t* trie_get_ins(trie_t *tbl, const char *key, uint32_t len)
if
(
unlikely
(
!
twigs
))
goto
err_leaf
;
node_t
t2
=
*
t
;
// Save before overwriting t.
t
->
branch
=
bp
;
// copy flags and index
t
->
branch
.
flags
=
bp
.
flags
;
t
->
branch
.
index
=
bp
.
index
;
t
->
branch
.
twigs
=
twigs
;
bitmap_t
b1
=
twigbit
(
t
,
key
,
len
);
bitmap_t
b2
=
unlikely
(
k2
==
-
256
)
?
(
1
<<
0
)
:
nibbit
(
k2
,
bp
.
flags
);
...
...
@@ -747,6 +751,7 @@ trie_val_t* trie_get_ins(trie_t *tbl, const char *key, uint32_t len)
err_leaf:
mm_free
(
&
tbl
->
mm
,
leaf
.
leaf
.
key
);
return
NULL
;
}
}
/*! \brief Apply a function to every trie_val_t*, in order; a recursive solution. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment