Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
846dbfde
Commit
846dbfde
authored
Jun 24, 2012
by
Mukund Sivaraman
Browse files
[1774] Use uint8_t instead of unsigned char
parent
31ee75a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/labelsequence.cc
View file @
846dbfde
...
...
@@ -23,7 +23,7 @@
namespace
isc
{
namespace
dns
{
const
u
nsigned
char
*
const
u
int8_t
*
LabelSequence
::
getData
(
size_t
*
len
)
const
{
*
len
=
getDataLength
();
return
(
&
name_
.
ndata_
[
name_
.
offsets_
[
first_label_
]]);
...
...
@@ -47,24 +47,22 @@ LabelSequence::getDataLength() const {
bool
LabelSequence
::
equals
(
const
LabelSequence
&
other
,
bool
case_sensitive
)
const
{
size_t
len
,
other_len
;
const
u
nsigned
char
*
data
=
getData
(
&
len
);
const
u
nsigned
char
*
other_data
=
other
.
getData
(
&
other_len
);
const
u
int8_t
*
data
=
getData
(
&
len
);
const
u
int8_t
*
other_data
=
other
.
getData
(
&
other_len
);
if
(
len
!=
other_len
)
{
return
(
false
);
}
if
(
case_sensitive
)
{
return
(
std
::
strncmp
((
const
char
*
)
data
,
(
const
char
*
)
other_data
,
len
)
==
0
);
return
(
std
::
memcmp
(
data
,
other_data
,
len
)
==
0
);
}
// As long as the data was originally validated as (part of) a name,
// label length must never be a capital ascii character, so we can
// simply compare them after converting to lower characters.
for
(
size_t
i
=
0
;
i
<
len
;
++
i
)
{
const
u
nsigned
char
ch
=
data
[
i
];
const
u
nsigned
char
other_ch
=
other_data
[
i
];
const
u
int8_t
ch
=
data
[
i
];
const
u
int8_t
other_ch
=
other_data
[
i
];
if
(
isc
::
dns
::
name
::
internal
::
maptolower
[
ch
]
!=
isc
::
dns
::
name
::
internal
::
maptolower
[
other_ch
])
{
return
(
false
);
...
...
@@ -99,14 +97,14 @@ LabelSequence::isAbsolute() const {
size_t
LabelSequence
::
getHash
(
bool
case_sensitive
)
const
{
size_t
length
;
const
u
nsigned
char
*
s
=
getData
(
&
length
);
const
u
int8_t
*
s
=
getData
(
&
length
);
if
(
length
>
16
)
{
length
=
16
;
}
size_t
hash_val
=
0
;
while
(
length
>
0
)
{
const
u
nsigned
char
c
=
*
s
++
;
const
u
int8_t
c
=
*
s
++
;
boost
::
hash_combine
(
hash_val
,
case_sensitive
?
c
:
isc
::
dns
::
name
::
internal
::
maptolower
[
c
]);
--
length
;
...
...
src/lib/dns/labelsequence.h
View file @
846dbfde
...
...
@@ -67,7 +67,7 @@ public:
/// \param len Pointer to a size_t where the length of the data
/// will be stored (in number of octets)
/// \return Pointer to the wire-format data of this label sequence
const
u
nsigned
char
*
getData
(
size_t
*
len
)
const
;
const
u
int8_t
*
getData
(
size_t
*
len
)
const
;
/// \brief Return the length of the wire-format data of this LabelSequence
///
...
...
src/lib/dns/messagerenderer.cc
View file @
846dbfde
...
...
@@ -100,8 +100,8 @@ struct NameCompare {
uint16_t
item_label_len
=
0
;
for
(
size_t
i
=
0
;
i
<
item
.
len_
;
++
i
,
++
item_pos
)
{
item_pos
=
nextPosition
(
*
buffer_
,
item_pos
,
item_label_len
);
const
u
nsigned
char
ch1
=
(
*
buffer_
)[
item_pos
];
const
u
nsigned
char
ch2
=
name_buf_
->
readUint8
();
const
u
int8_t
ch1
=
(
*
buffer_
)[
item_pos
];
const
u
int8_t
ch2
=
name_buf_
->
readUint8
();
if
(
CASE_SENSITIVE
)
{
if
(
ch1
!=
ch2
)
{
return
(
false
);
...
...
@@ -293,7 +293,7 @@ MessageRenderer::writeName(const Name& name, const bool compress) {
LabelSequence
sequence
(
name
);
const
size_t
nlabels
=
sequence
.
getLabelCount
();
size_t
data_len
;
const
u
nsigned
char
*
data
;
const
u
int8_t
*
data
;
// Find the offset in the offset table whose name gives the longest
// match against the name to be rendered.
...
...
src/lib/dns/tests/labelsequence_unittest.cc
View file @
846dbfde
...
...
@@ -130,14 +130,14 @@ getDataCheck(const char* expected_data, size_t expected_len,
const
LabelSequence
&
ls
)
{
size_t
len
;
const
u
nsigned
char
*
data
=
ls
.
getData
(
&
len
);
const
u
int8_t
*
data
=
ls
.
getData
(
&
len
);
ASSERT_EQ
(
expected_len
,
len
)
<<
"Expected data: "
<<
expected_data
<<
" name: "
<<
ls
.
getName
().
toText
();
EXPECT_EQ
(
expected_len
,
ls
.
getDataLength
())
<<
"Expected data: "
<<
expected_data
<<
" name: "
<<
ls
.
getName
().
toText
();
for
(
size_t
i
=
0
;
i
<
len
;
++
i
)
{
EXPECT_EQ
(
(
const
unsigned
char
)
expected_data
[
i
],
data
[
i
])
<<
EXPECT_EQ
(
static_cast
<
const
uint8_t
>
(
expected_data
[
i
]
)
,
data
[
i
])
<<
"Difference at pos "
<<
i
<<
": Expected data: "
<<
expected_data
<<
" name: "
<<
ls
.
getName
().
toText
();;
}
...
...
@@ -241,7 +241,7 @@ TEST_F(LabelSequenceTest, comparePart) {
// Data comparison
size_t
len
;
const
u
nsigned
char
*
data
=
ls1
.
getData
(
&
len
);
const
u
int8_t
*
data
=
ls1
.
getData
(
&
len
);
getDataCheck
((
const
char
*
)
data
,
len
,
ls8
);
}
...
...
Write
Preview
Supports
Markdown
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