Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot Resolver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
126
Issues
126
List
Boards
Labels
Milestones
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot Resolver
Commits
6174b57a
Verified
Commit
6174b57a
authored
Oct 09, 2018
by
Vladimír Čunát
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie_get_leq(): fix confusion in char signedness in keys
parent
d782766d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
lib/generic/trie.c
lib/generic/trie.c
+4
-2
No files found.
lib/generic/trie.c
View file @
6174b57a
...
...
@@ -509,6 +509,8 @@ static inline int ns_longer(nstack_t *ns)
* \param info Set position of the point of first mismatch (in index and flags).
* \param first Set the value of the first non-matching character (from trie),
* optionally; end-of-string character has value -256 (that's why it's int).
* Note: the character is converted to *unsigned* char (i.e. 0..255),
* as that's the ordering used in the trie.
*
* \return KNOT_EOK or KNOT_ENOMEM.
*/
...
...
@@ -541,7 +543,7 @@ static int ns_find_branch(nstack_t *ns, const char *key, uint32_t len,
}
info
->
index
=
index
;
if
(
first
)
*
first
=
lkey
->
len
>
index
?
lkey
->
chars
[
index
]
:
-
256
;
*
first
=
lkey
->
len
>
index
?
(
unsigned
char
)
lkey
->
chars
[
index
]
:
-
256
;
// Find flags: which half-byte has matched.
uint
flags
;
if
(
index
==
len
&&
len
==
lkey
->
len
)
{
// found equivalent key
...
...
@@ -697,7 +699,7 @@ int trie_get_leq(trie_t *tbl, const char *key, uint32_t len, trie_val_t **val)
branch_t
bp
;
int
un_leaf
;
// first unmatched character in the leaf
ERR_RETURN
(
ns_find_branch
(
ns
,
key
,
len
,
&
bp
,
&
un_leaf
));
int
un_key
=
bp
.
index
<
len
?
key
[
bp
.
index
]
:
-
256
;
int
un_key
=
bp
.
index
<
len
?
(
unsigned
char
)
key
[
bp
.
index
]
:
-
256
;
node_t
*
t
=
ns
->
stack
[
ns
->
len
-
1
];
if
(
bp
.
flags
==
0
)
{
// found exact match
*
val
=
&
t
->
leaf
.
val
;
...
...
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