mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 01:43:50 +00:00
Problem: Magic number "2" in ip_resolver.cpp
Solution: introduced constant
This commit is contained in:
parent
16bb62e6f7
commit
7c9d058cdb
@ -218,10 +218,13 @@ int zmq::ip_resolver_t::resolve (ip_addr_t *ip_addr_, const char *name_)
|
|||||||
|
|
||||||
// Trim any square brackets surrounding the address. Used for
|
// Trim any square brackets surrounding the address. Used for
|
||||||
// IPv6 addresses to remove the confusion with the port
|
// IPv6 addresses to remove the confusion with the port
|
||||||
// delimiter. Should we validate that the brackets are present if
|
// delimiter.
|
||||||
|
// TODO Should we validate that the brackets are present if
|
||||||
// 'addr' contains ':' ?
|
// 'addr' contains ':' ?
|
||||||
if (addr.size () >= 2 && addr[0] == '[' && addr[addr.size () - 1] == ']') {
|
const size_t brackets_length = 2;
|
||||||
addr = addr.substr (1, addr.size () - 2);
|
if (addr.size () >= brackets_length && addr[0] == '['
|
||||||
|
&& addr[addr.size () - 1] == ']') {
|
||||||
|
addr = addr.substr (1, addr.size () - brackets_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for an interface name / zone_id in the address
|
// Look for an interface name / zone_id in the address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user