[zeromq-dev] zmq::tcp_listener_t::get_address
Brian Knox
taotetek at gmail.com
Sat Feb 18 15:52:43 CET 2012
I was working on testing the zeromq rsyslog plugins against zeromq 3.1
today, and noticed I can no longer compile the libzmq master branch from
head. I wasn't sure if this was a known issue or not so figured I'd hit
the list before filing it as a bug.
I'm building libzmq master checked out this morning, on Centos 6.2. Here's
the error:
CXX libzmq_la-tcp_listener.lo
cc1plus: warnings being treated as errors
tcp_listener.cpp: In member function ‘int
zmq::tcp_listener_t::get_address(std::string*)’:
tcp_listener.cpp:148: error: dereferencing pointer ‘sa.120’ does break
strict-aliasing rules
tcp_listener.cpp:148: note: initialized from here
make[2]: *** [libzmq_la-tcp_listener.lo] Error 1
make[2]: Leaving directory `/home/bknox/src/libzmq/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/bknox/src/libzmq/src'
make: *** [all-recursive] Error 1
When I diff tcp_listener.cpp against zeromq-libzmq-75c5b67 (which does
build), I get this:
[bknox at centos1 src]$ diff tcp_listener.cpp
../../zeromq-libzmq-75c5b67/src/tcp_listener.cpp
25d24
< #include <sstream>
103c102
< options, NULL);
---
> options, NULL, NULL);
123,157d121
< int zmq::tcp_listener_t::get_address (std::string *addr_)
< {
< struct sockaddr sa;
< char host[INET6_ADDRSTRLEN];
< char serv_info[32];
< int port, rc;
< std::stringstream portnum;
<
< // Get the details of the TCP socket
< socklen_t sl = sizeof(sockaddr);
< rc = getsockname (s, &sa, &sl);
< if (rc != 0) {
< return rc;
< }
<
< // Split the retrieval between IPv4 and v6 addresses
< if ( sa.sa_family == AF_INET ) {
< getnameinfo(&sa, sizeof(struct sockaddr), host, INET6_ADDRSTRLEN,
serv_info, 32, NI_NUMERICHOST);
< port = ntohs( ((struct sockaddr_in *)&sa)->sin_port);
< portnum << port;
<
< // Store the address for retrieval by users using wildcards
< *addr_ = std::string("tcp://") + std::string(host) +
std::string(":") + portnum.str();
< } else {
< getnameinfo(&sa, sizeof(struct sockaddr), host, INET6_ADDRSTRLEN,
serv_info, 32, NI_NUMERICHOST);
< port = ntohs( ((struct sockaddr_in6 *)&sa)->sin6_port);
< portnum << port;
<
< // Store the address for retrieval by users using wildcards
< *addr_ = std::string("tcp://[") + std::string(host) +
std::string("]:") + portnum.str();
< }
<
< return 0;
< }
<
207d170
<
B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120218/29bc009a/attachment.htm>
More information about the zeromq-dev
mailing list