Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
a6060674
Commit
a6060674
authored
May 28, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: Magic numbers "32" and "128" in tcp_address.cpp
Solution: introduced constants
parent
93e75fd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
tcp_address.cpp
src/tcp_address.cpp
+9
-6
No files found.
src/tcp_address.cpp
View file @
a6060674
...
...
@@ -48,6 +48,8 @@
#include <stdlib.h>
#endif
#include <limits.h>
zmq
::
tcp_address_t
::
tcp_address_t
()
:
_has_src_addr
(
false
)
{
memset
(
&
_address
,
0
,
sizeof
(
_address
));
...
...
@@ -227,17 +229,18 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_)
return
rc
;
// Parse the cidr mask number.
const
int
full_mask_ipv4
=
sizeof
(
_address
.
ipv4
.
sin_addr
)
*
CHAR_BIT
;
const
int
full_mask_ipv6
=
sizeof
(
_address
.
ipv6
.
sin6_addr
)
*
CHAR_BIT
;
if
(
mask_str
.
empty
())
{
if
(
_address
.
family
()
==
AF_INET6
)
_address_mask
=
128
;
else
_address_mask
=
32
;
_address_mask
=
_address
.
family
()
==
AF_INET6
?
full_mask_ipv6
:
full_mask_ipv4
;
}
else
if
(
mask_str
==
"0"
)
_address_mask
=
0
;
else
{
const
int
mask
=
atoi
(
mask_str
.
c_str
());
if
((
mask
<
1
)
||
(
_address
.
family
()
==
AF_INET6
&&
mask
>
128
)
||
(
_address
.
family
()
!=
AF_INET6
&&
mask
>
32
))
{
if
((
mask
<
1
)
||
(
_address
.
family
()
==
AF_INET6
&&
mask
>
full_mask_ipv6
)
||
(
_address
.
family
()
!=
AF_INET6
&&
mask
>
full_mask_ipv4
))
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
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