0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-31 01:43:02 +08:00

Fixed 7 MSVC2008 Compiler Warning (level 3) C4800: 'const int' : forcing value to bool 'true' or 'false' (performance warning)

- added explicit test "(xxx != 0)" to get a "bool" value out of the "int" expression
- see the MSDN recommandation http://msdn.microsoft.com/en-us/library/b6801kcy(v=vs.90).aspx
This commit is contained in:
Sébastien Rombauts 2013-02-19 14:18:50 +01:00
parent 42be4d13a7
commit 927000fe2f
5 changed files with 7 additions and 7 deletions

View File

@ -143,7 +143,7 @@ int zmq::ctx_t::set (int option_, int optval_)
else
if (option_ == ZMQ_IPV6 && optval_ >= 0) {
opt_sync.lock ();
ipv6 = optval_;
ipv6 = (optval_ != 0);
opt_sync.unlock ();
}
else {

View File

@ -185,7 +185,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
/* Deprecated in favor of ZMQ_IPV6 */
case ZMQ_IPV4ONLY:
if (is_int && (value == 0 || value == 1))
ipv6 = 1 - value;
ipv6 = (value == 0);
else
valid = false;
break;
@ -193,7 +193,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
/* To replace the somewhat surprising IPV4ONLY */
case ZMQ_IPV6:
if (is_int && (value == 0 || value == 1))
ipv6 = value;
ipv6 = (value != 0);
else
valid = false;
break;

View File

@ -88,14 +88,14 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
return -1;
}
if (option_ == ZMQ_ROUTER_RAW) {
raw_sock = *static_cast <const int*> (optval_);
raw_sock = (*static_cast <const int*> (optval_) != 0);
if (raw_sock) {
options.recv_identity = false;
options.raw_sock = true;
}
}
else
mandatory = *static_cast <const int*> (optval_);
mandatory = (*static_cast <const int*> (optval_) != 0);
return 0;
}

View File

@ -135,7 +135,7 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) :
monitor_events (0)
{
options.socket_id = sid_;
options.ipv6 = parent_->get (ZMQ_IPV6);
options.ipv6 = (parent_->get (ZMQ_IPV6) != 0);
}
zmq::socket_base_t::~socket_base_t ()

View File

@ -98,7 +98,7 @@ int zmq::xpub_t::xsetsockopt (int option_, const void *optval_,
errno = EINVAL;
return -1;
}
verbose = *static_cast <const int*> (optval_);
verbose = (*static_cast <const int*> (optval_) != 0);
return 0;
}