Skip to content
GitLab
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
a071815c
Commit
a071815c
authored
Jan 27, 2014
by
Mukund Sivaraman
Browse files
[2749] Remove space between sizeof and (
parent
44b85098
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/lib/asiodns/tests/io_fetch_unittest.cc
View file @
a071815c
...
...
@@ -280,7 +280,8 @@ public:
cumulative_
+=
length
;
bool
complete
=
false
;
if
(
cumulative_
>
2
)
{
uint16_t
dns_length
=
readUint16
(
receive_buffer_
,
sizeof
(
receive_buffer_
));
uint16_t
dns_length
=
readUint16
(
receive_buffer_
,
sizeof
(
receive_buffer_
));
complete
=
((
dns_length
+
2
)
==
cumulative_
);
}
...
...
src/lib/asiolink/tests/tcp_socket_unittest.cc
View file @
a071815c
...
...
@@ -261,7 +261,7 @@ TEST(TCPSocket, processReceivedData) {
}
// Check that the method will handle various receive sizes.
writeUint16
(
PACKET_SIZE
,
inbuff
,
sizeof
(
inbuff
));
writeUint16
(
PACKET_SIZE
,
inbuff
,
sizeof
(
inbuff
));
cumulative
=
0
;
offset
=
0
;
...
...
src/lib/asiolink/tests/udp_socket_unittest.cc
View file @
a071815c
...
...
@@ -188,7 +188,7 @@ TEST(UDPSocket, processReceivedData) {
// two bytes of the buffer.
uint16_t
count
=
0
;
for
(
uint32_t
i
=
0
;
i
<
(
2
<<
16
);
++
i
,
++
count
)
{
writeUint16
(
count
,
inbuff
,
sizeof
(
inbuff
));
writeUint16
(
count
,
inbuff
,
sizeof
(
inbuff
));
// Set some random values
cumulative
=
5
;
...
...
src/lib/resolve/tests/recursive_query_unittest_2.cc
View file @
a071815c
...
...
@@ -463,7 +463,7 @@ public:
bool
complete
=
false
;
if
(
tcp_cumulative_
>
2
)
{
uint16_t
dns_length
=
readUint16
(
tcp_receive_buffer_
,
sizeof
(
tcp_receive_buffer_
));
sizeof
(
tcp_receive_buffer_
));
complete
=
((
dns_length
+
2
)
==
tcp_cumulative_
);
}
...
...
src/lib/resolve/tests/recursive_query_unittest_3.cc
View file @
a071815c
...
...
@@ -337,7 +337,7 @@ public:
bool
complete
=
false
;
if
(
tcp_cumulative_
>
2
)
{
uint16_t
dns_length
=
readUint16
(
tcp_receive_buffer_
,
sizeof
(
tcp_receive_buffer_
));
sizeof
(
tcp_receive_buffer_
));
complete
=
((
dns_length
+
2
)
==
tcp_cumulative_
);
}
...
...
src/lib/util/io_utilities.h
View file @
a071815c
...
...
@@ -34,7 +34,7 @@ namespace util {
/// \return Value of 16-bit integer
inline
uint16_t
readUint16
(
const
void
*
buffer
,
size_t
length
)
{
if
(
length
<
sizeof
(
uint16_t
))
{
if
(
length
<
sizeof
(
uint16_t
))
{
isc_throw
(
isc
::
OutOfRange
,
"Length ("
<<
length
<<
") of buffer is insufficient "
<<
"to read a uint16_t"
);
...
...
@@ -61,7 +61,7 @@ readUint16(const void* buffer, size_t length) {
/// \return pointer to the next byte after stored value
inline
uint8_t
*
writeUint16
(
uint16_t
value
,
void
*
buffer
,
size_t
length
)
{
if
(
length
<
sizeof
(
uint16_t
))
{
if
(
length
<
sizeof
(
uint16_t
))
{
isc_throw
(
isc
::
OutOfRange
,
"Length ("
<<
length
<<
") of buffer is insufficient "
<<
"to write a uint16_t"
);
...
...
@@ -85,7 +85,7 @@ writeUint16(uint16_t value, void* buffer, size_t length) {
/// \return Value of 32-bit unsigned integer
inline
uint32_t
readUint32
(
const
uint8_t
*
buffer
,
size_t
length
)
{
if
(
length
<
sizeof
(
uint32_t
))
{
if
(
length
<
sizeof
(
uint32_t
))
{
isc_throw
(
isc
::
OutOfRange
,
"Length ("
<<
length
<<
") of buffer is insufficient "
<<
"to read a uint32_t"
);
...
...
@@ -111,7 +111,7 @@ readUint32(const uint8_t* buffer, size_t length) {
/// \return pointer to the next byte after stored value
inline
uint8_t
*
writeUint32
(
uint32_t
value
,
uint8_t
*
buffer
,
size_t
length
)
{
if
(
length
<
sizeof
(
uint32_t
))
{
if
(
length
<
sizeof
(
uint32_t
))
{
isc_throw
(
isc
::
OutOfRange
,
"Length ("
<<
length
<<
") of buffer is insufficient "
<<
"to write a uint32_t"
);
...
...
src/lib/util/tests/io_utilities_unittest.cc
View file @
a071815c
...
...
@@ -42,14 +42,14 @@ TEST(asioutil, readUint16) {
data
[
0
]
=
i8
;
data
[
1
]
=
j8
;
buffer
.
setPosition
(
0
);
EXPECT_EQ
(
buffer
.
readUint16
(),
readUint16
(
data
,
sizeof
(
data
)));
EXPECT_EQ
(
buffer
.
readUint16
(),
readUint16
(
data
,
sizeof
(
data
)));
}
}
}
TEST
(
asioutil
,
readUint16OutOfRange
)
{
uint8_t
data
;
EXPECT_THROW
(
readUint16
(
&
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
EXPECT_THROW
(
readUint16
(
&
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
}
TEST
(
asioutil
,
writeUint16
)
{
...
...
@@ -68,7 +68,7 @@ TEST(asioutil, writeUint16) {
buffer
.
writeUint16
(
i16
);
// ... and the test data
writeUint16
(
i16
,
test
,
sizeof
(
test
));
writeUint16
(
i16
,
test
,
sizeof
(
test
));
// ... and compare
const
uint8_t
*
ref
=
static_cast
<
const
uint8_t
*>
(
buffer
.
getData
());
...
...
@@ -80,7 +80,7 @@ TEST(asioutil, writeUint16) {
TEST
(
asioutil
,
writeUint16OutOfRange
)
{
uint16_t
i16
=
42
;
uint8_t
data
;
EXPECT_THROW
(
writeUint16
(
i16
,
&
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
EXPECT_THROW
(
writeUint16
(
i16
,
&
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
}
// test data shared amount readUint32 and writeUint32 tests
...
...
@@ -103,14 +103,14 @@ TEST(asioutil, readUint32) {
uint32_t
tmp
=
htonl
(
test32
[
i
]);
memcpy
(
&
data
[
offset
],
&
tmp
,
sizeof
(
uint32_t
));
EXPECT_EQ
(
test32
[
i
],
readUint32
(
&
data
[
offset
],
sizeof
(
uint32_t
)));
EXPECT_EQ
(
test32
[
i
],
readUint32
(
&
data
[
offset
],
sizeof
(
uint32_t
)));
}
}
}
TEST
(
asioutil
,
readUint32OutOfRange
)
{
uint8_t
data
[
3
];
EXPECT_THROW
(
readUint32
(
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
EXPECT_THROW
(
readUint32
(
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
}
TEST
(
asioutil
,
writeUint32
)
{
...
...
@@ -121,7 +121,8 @@ TEST(asioutil, writeUint32) {
// it 4 times.
for
(
int
offset
=
0
;
offset
<
4
;
offset
++
)
{
for
(
int
i
=
0
;
i
<
sizeof
(
test32
)
/
sizeof
(
uint32_t
);
i
++
)
{
uint8_t
*
ptr
=
writeUint32
(
test32
[
i
],
&
data
[
offset
],
sizeof
(
uint32_t
));
uint8_t
*
ptr
=
writeUint32
(
test32
[
i
],
&
data
[
offset
],
sizeof
(
uint32_t
));
EXPECT_EQ
(
&
data
[
offset
]
+
sizeof
(
uint32_t
),
ptr
);
...
...
@@ -135,5 +136,5 @@ TEST(asioutil, writeUint32) {
TEST
(
asioutil
,
writeUint32OutOfRange
)
{
uint32_t
i32
=
28
;
uint8_t
data
[
3
];
EXPECT_THROW
(
writeUint32
(
i32
,
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
EXPECT_THROW
(
writeUint32
(
i32
,
data
,
sizeof
(
data
)),
isc
::
OutOfRange
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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