Commit 38fd1fdc authored by JaeSang Yoo's avatar JaeSang Yoo

Problem: some cond. compile may cause problem

Some ifdefs in condition checking may cause problem in some compiler or
static analyzers. When PGM and NORM both are disabled, some condition
will be derived as false || false.

Solution: Splitted condition checking for every ifdef conditions
parent 4f436ce0
......@@ -369,14 +369,14 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_) const
// Specifically, multicast protocols can't be combined with
// bi-directional messaging patterns (socket types).
#if defined ZMQ_HAVE_OPENPGM || defined ZMQ_HAVE_NORM
if ((false
#ifdef ZMQ_HAVE_OPENPGM
|| protocol_ == protocol_name::pgm || protocol_ == protocol_name::epgm
#endif
#ifdef ZMQ_HAVE_NORM
|| protocol_ == protocol_name::norm
#if defined ZMQ_HAVE_OPENPGM && defined ZMQ_HAVE_NORM
if ((protocol_ == protocol_name::pgm || protocol_ == protocol_name::epgm
|| protocol_ == protocol_name::norm)
#elif defined ZMQ_HAVE_OPENPGM
if ((protocol_ == protocol_name::pgm || protocol_ == protocol_name::epgm)
#else // defined ZMQ_HAVE_NORM
if (protocol_ == protocol_name::norm
#endif
|| false)
&& options.type != ZMQ_PUB && options.type != ZMQ_SUB
&& options.type != ZMQ_XPUB && options.type != ZMQ_XSUB) {
errno = ENOCOMPATPROTO;
......@@ -553,14 +553,15 @@ int zmq::socket_base_t::bind (const char *endpoint_uri_)
return rc;
}
if (false
#ifdef ZMQ_HAVE_OPENPGM
|| protocol == protocol_name::pgm || protocol == protocol_name::epgm
#endif
#ifdef ZMQ_HAVE_NORM
|| protocol == protocol_name::norm
#if defined ZMQ_HAVE_OPENPGM || defined ZMQ_HAVE_NORM
#if defined ZMQ_HAVE_OPENPGM && defined ZMQ_HAVE_NORM
if (protocol == protocol_name::pgm || protocol == protocol_name::epgm
|| protocol == protocol_name::norm) {
#elif defined ZMQ_HAVE_OPENPGM
if (protocol == protocol_name::pgm || protocol == protocol_name::epgm) {
#else // defined ZMQ_HAVE_NORM
if (protocol == protocol_name::norm) {
#endif
|| false) {
// For convenience's sake, bind can be used interchangeable with
// connect for PGM, EPGM, NORM transports.
rc = connect (endpoint_uri_);
......@@ -568,6 +569,7 @@ int zmq::socket_base_t::bind (const char *endpoint_uri_)
options.connected = true;
return rc;
}
#endif
if (protocol == protocol_name::udp) {
if (!(options.type == ZMQ_DGRAM || options.type == ZMQ_DISH)) {
......@@ -1035,15 +1037,20 @@ int zmq::socket_base_t::connect_internal (const char *endpoint_uri_)
// PGM does not support subscription forwarding; ask for all data to be
// sent to this pipe. (same for NORM, currently?)
const bool subscribe_to_all = false
#ifdef ZMQ_HAVE_OPENPGM
|| protocol == protocol_name::pgm
#if defined ZMQ_HAVE_OPENPGM && defined ZMQ_HAVE_NORM
const bool subscribe_to_all =
protocol == protocol_name::pgm || protocol == protocol_name::epgm
|| protocol == protocol_name::norm || protocol == protocol_name::udp;
#elif defined ZMQ_HAVE_OPENPGM
const bool subscribe_to_all = protocol == protocol_name::pgm
|| protocol == protocol_name::epgm
#endif
#ifdef ZMQ_HAVE_NORM
|| protocol == protocol_name::norm
#endif
|| protocol == protocol_name::udp;
#elif defined ZMQ_HAVE_NORM
const bool subscribe_to_all =
protocol == protocol_name::norm || protocol == protocol_name::udp;
#else
const bool subscribe_to_all = protocol == protocol_name::udp;
#endif
pipe_t *newpipe = NULL;
if (options.immediate != 1 || subscribe_to_all) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment