Problem: ipc_address data member does not conform with naming convention

Solution: rename data member
This commit is contained in:
Simon Giesecke 2019-02-06 07:12:21 -05:00
parent 808028fe02
commit 31015fdcfe
2 changed files with 16 additions and 16 deletions

View File

@ -39,16 +39,16 @@
zmq::ipc_address_t::ipc_address_t () zmq::ipc_address_t::ipc_address_t ()
{ {
memset (&address, 0, sizeof address); memset (&_address, 0, sizeof _address);
} }
zmq::ipc_address_t::ipc_address_t (const sockaddr *sa_, socklen_t sa_len_) zmq::ipc_address_t::ipc_address_t (const sockaddr *sa_, socklen_t sa_len_)
{ {
zmq_assert (sa_ && sa_len_ > 0); zmq_assert (sa_ && sa_len_ > 0);
memset (&address, 0, sizeof address); memset (&_address, 0, sizeof _address);
if (sa_->sa_family == AF_UNIX) if (sa_->sa_family == AF_UNIX)
memcpy (&address, sa_, sa_len_); memcpy (&_address, sa_, sa_len_);
} }
zmq::ipc_address_t::~ipc_address_t () zmq::ipc_address_t::~ipc_address_t ()
@ -58,7 +58,7 @@ zmq::ipc_address_t::~ipc_address_t ()
int zmq::ipc_address_t::resolve (const char *path_) int zmq::ipc_address_t::resolve (const char *path_)
{ {
const size_t path_len = strlen (path_); const size_t path_len = strlen (path_);
if (path_len >= sizeof address.sun_path) { if (path_len >= sizeof _address.sun_path) {
errno = ENAMETOOLONG; errno = ENAMETOOLONG;
return -1; return -1;
} }
@ -67,28 +67,28 @@ int zmq::ipc_address_t::resolve (const char *path_)
return -1; return -1;
} }
address.sun_family = AF_UNIX; _address.sun_family = AF_UNIX;
memcpy (address.sun_path, path_, path_len + 1); memcpy (_address.sun_path, path_, path_len + 1);
/* Abstract sockets start with '\0' */ /* Abstract sockets start with '\0' */
if (path_[0] == '@') if (path_[0] == '@')
*address.sun_path = '\0'; *_address.sun_path = '\0';
return 0; return 0;
} }
int zmq::ipc_address_t::to_string (std::string &addr_) const int zmq::ipc_address_t::to_string (std::string &addr_) const
{ {
if (address.sun_family != AF_UNIX) { if (_address.sun_family != AF_UNIX) {
addr_.clear (); addr_.clear ();
return -1; return -1;
} }
const char prefix[] = "ipc://"; const char prefix[] = "ipc://";
char buf[sizeof prefix + sizeof address.sun_path]; char buf[sizeof prefix + sizeof _address.sun_path];
char *pos = buf; char *pos = buf;
memcpy (pos, prefix, sizeof prefix - 1); memcpy (pos, prefix, sizeof prefix - 1);
pos += sizeof prefix - 1; pos += sizeof prefix - 1;
const char *src_pos = address.sun_path; const char *src_pos = _address.sun_path;
if (!address.sun_path[0] && address.sun_path[1]) { if (!_address.sun_path[0] && _address.sun_path[1]) {
*pos++ = '@'; *pos++ = '@';
src_pos++; src_pos++;
} }
@ -105,15 +105,15 @@ int zmq::ipc_address_t::to_string (std::string &addr_) const
const sockaddr *zmq::ipc_address_t::addr () const const sockaddr *zmq::ipc_address_t::addr () const
{ {
return reinterpret_cast<const sockaddr *> (&address); return reinterpret_cast<const sockaddr *> (&_address);
} }
socklen_t zmq::ipc_address_t::addrlen () const socklen_t zmq::ipc_address_t::addrlen () const
{ {
if (!address.sun_path[0] && address.sun_path[1]) if (!_address.sun_path[0] && _address.sun_path[1])
return static_cast<socklen_t> (strlen (address.sun_path + 1)) return static_cast<socklen_t> (strlen (_address.sun_path + 1))
+ sizeof (sa_family_t) + 1; + sizeof (sa_family_t) + 1;
return static_cast<socklen_t> (sizeof address); return static_cast<socklen_t> (sizeof _address);
} }
#endif #endif

View File

@ -57,7 +57,7 @@ class ipc_address_t
socklen_t addrlen () const; socklen_t addrlen () const;
private: private:
struct sockaddr_un address; struct sockaddr_un _address;
ipc_address_t (const ipc_address_t &); ipc_address_t (const ipc_address_t &);
const ipc_address_t &operator= (const ipc_address_t &); const ipc_address_t &operator= (const ipc_address_t &);